You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by nk...@apache.org on 2019/11/14 15:57:32 UTC

[flink] 02/08: [FLINK-13724][docs] Remove unnecessary whitespace from the generated pages

This is an automated email from the ASF dual-hosted git repository.

nkruber pushed a commit to branch release-1.8
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 6d55ababf05f24070053cafd177c9b69cabeff60
Author: Nico Kruber <ni...@ververica.com>
AuthorDate: Wed Aug 14 16:18:06 2019 +0200

    [FLINK-13724][docs] Remove unnecessary whitespace from the generated pages
    
    Starting command tags with "{%-" will drop all whitespace to the left and ending
    with "-%}" will drop all whitespace to the right (including newlines!).
    Code like the following would otherwise create quite some unnecessary
    whitespace:
    
      {% if parent_id %}
        {% assign parent_id = current[0].nav-parent_id %}
      {% else %}
        {% break %}
      {% endif %}
    
    This closes #9440
---
 docs/_includes/sidenav.html | 152 ++++++++++++++++++++++----------------------
 docs/_layouts/base.html     |   6 +-
 docs/_layouts/plain.html    |  46 +++++++-------
 3 files changed, 102 insertions(+), 102 deletions(-)

diff --git a/docs/_includes/sidenav.html b/docs/_includes/sidenav.html
index 3011387..3132955 100644
--- a/docs/_includes/sidenav.html
+++ b/docs/_includes/sidenav.html
@@ -17,30 +17,30 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-{% comment %}
+{%- comment -%}
 ==============================================================================
 Extract the active nav IDs.
 ==============================================================================
-{% endcomment %}
-
-{% assign active_nav_ids = site.array %}
-{% assign parent_id = page.nav-parent_id %}
-
-{% for i in (1..10) %}
-  {% if parent_id %}
-    {% assign active_nav_ids = active_nav_ids | push: parent_id %}
-    {% assign current = (site.pages | where: "nav-id" , parent_id | sort: "nav-pos") %}
-    {% if current.size > 0 %}
-      {% assign parent_id = current[0].nav-parent_id %}
-    {% else %}
-      {% break %}
-    {% endif %}
-  {% else %}
-    {% break %}
-  {% endif %}
-{% endfor %}
-
-{% comment %}
+{%- endcomment -%}
+
+{%- assign active_nav_ids = site.array -%}
+{%- assign parent_id = page.nav-parent_id -%}
+
+{%- for i in (1..10) -%}
+  {%- if parent_id -%}
+    {%- assign active_nav_ids = active_nav_ids | push: parent_id -%}
+    {%- assign current = (site.pages | where: "nav-id" , parent_id | sort: "nav-pos") -%}
+    {%- if current.size > 0 -%}
+      {%- assign parent_id = current[0].nav-parent_id -%}
+    {%- else -%}
+      {%- break -%}
+    {%- endif -%}
+  {%- else -%}
+    {%- break -%}
+  {%- endif -%}
+{%- endfor -%}
+
+{%- comment -%}
 ==============================================================================
 Build the nested list from nav-id and nav-parent_id relations.
 ==============================================================================
@@ -57,74 +57,74 @@ Level 0 is made up of all pages, which have nav-parent_id set to 'root'.
 The 'title' of the page is used as the default link text. You can
 override this via 'nav-title'. The relative position per navigational
 level is determined by 'nav-pos'.
-{% endcomment %}
+{%- endcomment -%}
 
-{% assign elementsPosStack = site.array %}
-{% assign posStack = site.array %}
+{%- assign elementsPosStack = site.array -%}
+{%- assign posStack = site.array -%}
 
-{% assign elements = site.array %}
-{% assign children = (site.pages | where: "nav-parent_id" , "root" | sort: "nav-pos") %}
-{% if children.size > 0 %}
-  {% assign elements = elements | push: children %}
-{% endif %}
+{%- assign elements = site.array -%}
+{%- assign children = (site.pages | where: "nav-parent_id" , "root" | sort: "nav-pos") -%}
+{%- if children.size > 0 -%}
+  {%- assign elements = elements | push: children -%}
+{%- endif -%}
 
-{% assign elementsPos = 0 %}
-{% assign pos = 0 %}
+{%- assign elementsPos = 0 -%}
+{%- assign pos = 0 -%}
 
 <div class="sidenav-logo">
   <p><a href="{{ site.baseurl }}"><img class="bottom" alt="Apache Flink" src="{{ site.baseurl }}/page/img/navbar-brand-logo.jpg"></a> v{{ site.version_title }}</p>
 </div>
 <ul id="sidenav">
-{% for i in (1..10000) %}
-  {% if pos >= elements[elementsPos].size %}
-    {% if elementsPos == 0 %}
-      {% break %}
-    {% else %}
-      {% assign elementsPos = elementsPosStack | last %}
-      {% assign pos = posStack | last %}
+{%- for i in (1..10000) -%}
+  {%- if pos >= elements[elementsPos].size -%}
+    {%- if elementsPos == 0 -%}
+      {%- break -%}
+    {%- else -%}
+      {%- assign elementsPos = elementsPosStack | last -%}
+      {%- assign pos = posStack | last %}
 </ul></div></li>
-      {% assign elementsPosStack = elementsPosStack | pop %}
-      {% assign posStack = posStack | pop %}
-    {% endif %}
-  {% else %}
-    {% assign this = elements[elementsPos][pos] %}
-
-    {% if this.url == page.url %}
-      {% assign active = true %}
-    {% elsif this.nav-id and active_nav_ids contains this.nav-id %}
-      {% assign active = true %}
-    {% else %}
-      {% assign active = false %}
-    {% endif %}
-
-    {% capture title %}{% if this.nav-title %}{{ this.nav-title }}{% else %}{{ this.title }}{% endif %}{% endcapture %}
-    {% capture target %}"{{ site.baseurl }}{{ this.url }}"{% if active %} class="active"{% endif %}{% endcapture %}
-    {% capture overview_target %}"{{ site.baseurl }}{{ this.url }}"{% if this.url == page.url %} class="active"{% endif %}{% endcapture %}
+      {%- assign elementsPosStack = elementsPosStack | pop -%}
+      {%- assign posStack = posStack | pop -%}
+    {%- endif -%}
+  {%- else -%}
+    {%- assign this = elements[elementsPos][pos] -%}
+
+    {%- if this.url == page.url -%}
+      {%- assign active = true -%}
+    {%- elsif this.nav-id and active_nav_ids contains this.nav-id -%}
+      {%- assign active = true -%}
+    {%- else -%}
+      {%- assign active = false -%}
+    {%- endif -%}
+
+    {%- capture title -%}{%- if this.nav-title -%}{{ this.nav-title }}{%- else -%}{{ this.title }}{%- endif -%}{%- endcapture -%}
+    {%- capture target -%}"{{ site.baseurl }}{{ this.url }}"{%- if active %} class="active"{%- endif -%}{%- endcapture -%}
+    {%- capture overview_target -%}"{{ site.baseurl }}{{ this.url }}"{%- if this.url == page.url -%} class="active"{%- endif -%}{%- endcapture -%}
 
     {% if this.section-break %}<hr class="section-break"></hr>{% endif %}
 
-    {% assign pos = pos | plus: 1 %}
-    {% if this.nav-id %}
-      {% assign children = (site.pages | where: "nav-parent_id" , this.nav-id | sort: "nav-pos") %}
-      {% if children.size > 0 %}
-        {% capture collapse_target %}"#collapse-{{ i }}" data-toggle="collapse"{% if active %} class="active"{% endif %}{% endcapture %}
-        {% capture expand %}{% unless active %} <i class="fa fa-caret-down pull-right" aria-hidden="true" style="padding-top: 4px"></i>{% endunless %}{% endcapture %}
+    {%- assign pos = pos | plus: 1 -%}
+    {%- if this.nav-id -%}
+      {%- assign children = (site.pages | where: "nav-parent_id" , this.nav-id | sort: "nav-pos") -%}
+      {%- if children.size > 0 -%}
+        {%- capture collapse_target -%}"#collapse-{{ i }}" data-toggle="collapse"{%- if active -%} class="active"{%- endif -%}{%- endcapture -%}
+        {%- capture expand -%}{%- unless active -%} <i class="fa fa-caret-down pull-right" aria-hidden="true" style="padding-top: 4px"></i>{%- endunless -%}{%- endcapture %}
 <li><a href={{ collapse_target }}>{{ title }}{{ expand }}</a><div class="collapse{% if active %} in{% endif %}" id="collapse-{{ i }}"><ul>
-  {% if this.nav-show_overview %}<li><a href={{ overview_target }}>Overview</a></li>{% endif %}
-        {% assign elements = elements | push: children %}
-        {% assign elementsPosStack = elementsPosStack | push: elementsPos %}
-        {% assign posStack = posStack | push: pos %}
-
-        {% assign elementsPos = elements.size | minus: 1 %}
-        {% assign pos = 0 %}
-      {% else %}
+  {%- if this.nav-show_overview %}<li><a href={{ overview_target }}>Overview</a></li>{%- endif -%}
+        {%- assign elements = elements | push: children -%}
+        {%- assign elementsPosStack = elementsPosStack | push: elementsPos -%}
+        {%- assign posStack = posStack | push: pos -%}
+
+        {%- assign elementsPos = elements.size | minus: 1 -%}
+        {%- assign pos = 0 -%}
+      {%- else %}
 <li><a href={{ target }}>{{ title }}</a></li>
-      {% endif %}
-    {% else %}
+      {%- endif -%}
+    {%- else %}
 <li><a href={{ target }}>{{ title }}</a></li>
-    {% endif %}
-  {% endif %}
-{% endfor %}
+    {%- endif -%}
+  {%- endif -%}
+{%- endfor %}
   <li class="divider"></li>
   <li><a href="{{ site.javadocs_baseurl }}/api/java"><i class="fa fa-external-link title" aria-hidden="true"></i> Javadocs</a></li>
   <li><a href="{{ site.javadocs_baseurl }}/api/scala/index.html#org.apache.flink.api.scala.package"><i class="fa fa-external-link title" aria-hidden="true"></i> Scaladocs</a></li>
@@ -145,9 +145,9 @@ level is determined by 'nav-pos'.
     <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Pick Docs Version
     <span class="caret"></span></button>
     <ul class="dropdown-menu">
-      {% for d in site.previous_docs %}
+      {%- for d in site.previous_docs %}
       <li><a href="{{ d[1] }}">v{{ d[0] }}</a></li>
-      {% endfor %}
+      {%- endfor %}
     </ul>
   </div>
 </div>
diff --git a/docs/_layouts/base.html b/docs/_layouts/base.html
index 1dbaa76..8be5cc7 100644
--- a/docs/_layouts/base.html
+++ b/docs/_layouts/base.html
@@ -72,9 +72,9 @@ under the License.
           {% include sidenav.html %}
         </div>
         <div class="col-lg-9 content" id="contentcol">
-          {% if page.mathjax %}
-          {% include latex_commands.html %}
-          {% endif %}
+          {%- if page.mathjax -%}
+          {%- include latex_commands.html -%}
+          {%- endif %}
 
           {{ content }}
         </div>
diff --git a/docs/_layouts/plain.html b/docs/_layouts/plain.html
index 44f9e1a..62cae1b 100644
--- a/docs/_layouts/plain.html
+++ b/docs/_layouts/plain.html
@@ -20,36 +20,36 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-{% assign active_pages = site.array %}
-{% assign active = page %}
-
-{% for i in (1..10) %}
-  {% assign active_pages = active_pages | push: active %}
-  {% if active.nav-parent_id %}
-    {% assign next = site.pages | where: "nav-id" , active.nav-parent_id %}
-    {% if next.size > 0 %}
-      {% assign active = next[0] %}
-    {% else %}
-      {% break %}
-    {% endif %}
-  {% else %}
-    {% break %}
-  {% endif %}
-{% endfor %}
+{%- assign active_pages = site.array -%}
+{%- assign active = page -%}
+
+{%- for i in (1..10) -%}
+  {%- assign active_pages = active_pages | push: active -%}
+  {%- if active.nav-parent_id -%}
+    {%- assign next = site.pages | where: "nav-id" , active.nav-parent_id -%}
+    {%- if next.size > 0 -%}
+      {%- assign active = next[0] -%}
+    {%- else -%}
+      {%- break -%}
+    {%- endif -%}
+  {%- else -%}
+    {%- break -%}
+  {%- endif -%}
+{%- endfor -%}
 
 {% assign active_pages = active_pages | reverse %}
 
 <ol class="breadcrumb">
-{% for p in active_pages %}
+{%- for p in active_pages %}
   {% capture title %}{% if p.nav-title %}{{ p.nav-title }}{% else %}{{ p.title }}{% endif %}{% endcapture %}
-  {% if forloop.last == true %}
+  {%- if forloop.last == true %}
     <li class="active">{{ title }}</li>
-  {% elsif p.nav-show_overview %}
+  {%- elsif p.nav-show_overview %}
     <li><a href="{{ site.baseurl }}{{ p.url }}">{{ title }}</a></li>
-  {% else %}
+  {%- else %}
     <li>{{ title }}</li>
-  {% endif %}
-{% endfor %}
+  {%- endif -%}
+{%- endfor %}
 </ol>
 
 <h1>{{ page.title }}{% if page.is_beta %} <span class="beta">Beta</span>{% endif %}</h1>
@@ -57,6 +57,6 @@ under the License.
 <div class="alert alert-danger" role="alert">
   <strong>This documentation is for an out-of-date version of Apache Flink. We recommend you use <a href="https://ci.apache.org/projects/flink/flink-docs-stable/">the latest stable version</a>.</strong>
 </div>
-{% endif %}
+{%- endif %}
 
 {{ content }}