From a8868dd2219468c4528011c85551a33b4fe0ee9b Mon Sep 17 00:00:00 2001 From: Nico Kruber Date: Mon, 19 Aug 2019 23:48:57 +0200 Subject: [PATCH] [FLINK-13791][docs] Speed up sidenav by using group_by _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 #9487 --- docs/_includes/sidenav.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/_includes/sidenav.html b/docs/_includes/sidenav.html index 1073d99caae72..70a24a78096da 100644 --- a/docs/_includes/sidenav.html +++ b/docs/_includes/sidenav.html @@ -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 -%} @@ -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 -%} {%- endunless -%}{%- endcapture %}
  • {{ title }}{{ expand }}