Skip to content

Commit

Permalink
[FLINK-13791][docs] Speed up sidenav by using group_by
Browse files Browse the repository at this point in the history
_includes/sidenav.html parses through pages_by_language over and over again
trying to find children when building the (recursive) side navigation. By doing
this once with a group_by, we can gain considerable savings in building the
docs via `./build_docs.sh` without any change to the generated HTML pages:

This closes apache#9487
  • Loading branch information
NicoK committed Nov 14, 2019
1 parent cb7e904 commit a8868dd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/_includes/sidenav.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
{%- assign posStack = site.array -%}

{%- assign elements = site.array -%}
{%- assign children = (site.pages_by_language[page.language] | where: "nav-parent_id" , "root" | sort: "nav-pos") -%}
{%- assign all_pages_by_nav_parent = (site.pages_by_language[page.language] | where_exp: "item", "item.nav-parent_id != nil" | group_by: "nav-parent_id") -%}
{%- assign children = (all_pages_by_nav_parent | where: "name" , "root") -%}
{%- assign children = (children[0].items | sort: "nav-pos") -%}
{%- if children.size > 0 -%}
{%- assign elements = elements | push: children -%}
{%- endif -%}
Expand Down Expand Up @@ -111,8 +113,9 @@

{%- assign pos = pos | plus: 1 -%}
{%- if this.nav-id -%}
{%- assign children = (site.pages_by_language[page.language] | where: "nav-parent_id" , this.nav-id | sort: "nav-pos") -%}
{%- assign children = (all_pages_by_nav_parent | where: "name" , this.nav-id) -%}
{%- if children.size > 0 -%}
{%- assign children = (children[0].items | sort: "nav-pos") -%}
{%- 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>
Expand Down

0 comments on commit a8868dd

Please sign in to comment.