From 467e1d4f6ae40ada48ae82fd1240ad9701d255ad Mon Sep 17 00:00:00 2001 From: Jingwen Chen Date: Wed, 16 Dec 2020 21:24:00 -0800 Subject: [PATCH] Make the navigation sidebar versioned MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: #6937 This adds versioning support to the navigation sidebar in the default documentation page layout, conditionally loading a sidebar partial based on the current version's major version, or use the latest one in the case for rolling releases. This also means that the navigation sidebar list is [extracted out from the `documentation.html` layout file](https://github.com/bazelbuild/bazel/pull/12708/files#diff-9f04c21a8bdeaac5a1ca37b571ac0e343acbf1a8d50f5d3d11a4ffb7962198f8), into an include partial. This gets rid of the many conditionals littered all over the navigation list items. Currently, the biggest differences are between the groups of v0, v1-3, and master. This implementation allows v1 and v2's sidebar to just be a symlink to v3. For rolling releases, the sidebar is versioned as `master`. ``` % tree _includes/documentation-sidebar _includes/documentation-sidebar ├── 0 │   └── sidebar.html ├── 1 -> 3 ├── 2 -> 3 ├── 3 │   └── sidebar.html └── master └── sidebar.html ``` We can also allow finer-grained versioning with the full major.minor.patch, but I think major versions are a good enough start. Closes #12708. PiperOrigin-RevId: 347954483 --- .../documentation-sidebar/0/sidebar.html | 299 ++++++++++++++++ .../documentation-sidebar/1/sidebar.html | 228 ++++++++++++ .../documentation-sidebar/2/sidebar.html | 228 ++++++++++++ .../documentation-sidebar/3/sidebar.html | 228 ++++++++++++ .../documentation-sidebar/master/sidebar.html | 229 ++++++++++++ site/_layouts/documentation.html | 338 +----------------- .../shell/bazel/list_source_repository.bzl | 2 +- 7 files changed, 1221 insertions(+), 331 deletions(-) create mode 100644 site/_includes/documentation-sidebar/0/sidebar.html create mode 100644 site/_includes/documentation-sidebar/1/sidebar.html create mode 100644 site/_includes/documentation-sidebar/2/sidebar.html create mode 100644 site/_includes/documentation-sidebar/3/sidebar.html create mode 100644 site/_includes/documentation-sidebar/master/sidebar.html diff --git a/site/_includes/documentation-sidebar/0/sidebar.html b/site/_includes/documentation-sidebar/0/sidebar.html new file mode 100644 index 00000000000000..49c2e3d3683d9d --- /dev/null +++ b/site/_includes/documentation-sidebar/0/sidebar.html @@ -0,0 +1,299 @@ +

Home

+ + +

Installing Bazel

+ + +

Tutorials

+ + +

Using Bazel

+ + +

Rules

+ + +

Reference

+ + +

Extending Bazel

+ diff --git a/site/_includes/documentation-sidebar/1/sidebar.html b/site/_includes/documentation-sidebar/1/sidebar.html new file mode 100644 index 00000000000000..0cc4b853565e3a --- /dev/null +++ b/site/_includes/documentation-sidebar/1/sidebar.html @@ -0,0 +1,228 @@ +

Home

+ + +

Installing Bazel

+ + +

Tutorials

+ + +

Using Bazel

+ + +

Reference

+ + +

Extending Bazel

+ diff --git a/site/_includes/documentation-sidebar/2/sidebar.html b/site/_includes/documentation-sidebar/2/sidebar.html new file mode 100644 index 00000000000000..0cc4b853565e3a --- /dev/null +++ b/site/_includes/documentation-sidebar/2/sidebar.html @@ -0,0 +1,228 @@ +

Home

+ + +

Installing Bazel

+ + +

Tutorials

+ + +

Using Bazel

+ + +

Reference

+ + +

Extending Bazel

+ diff --git a/site/_includes/documentation-sidebar/3/sidebar.html b/site/_includes/documentation-sidebar/3/sidebar.html new file mode 100644 index 00000000000000..0cc4b853565e3a --- /dev/null +++ b/site/_includes/documentation-sidebar/3/sidebar.html @@ -0,0 +1,228 @@ +

Home

+ + +

Installing Bazel

+ + +

Tutorials

+ + +

Using Bazel

+ + +

Reference

+ + +

Extending Bazel

+ diff --git a/site/_includes/documentation-sidebar/master/sidebar.html b/site/_includes/documentation-sidebar/master/sidebar.html new file mode 100644 index 00000000000000..1fc4f3892a8620 --- /dev/null +++ b/site/_includes/documentation-sidebar/master/sidebar.html @@ -0,0 +1,229 @@ +

Home

+ + +

Installing Bazel

+ + +

Tutorials

+ + +

Using Bazel

+ + +

Reference

+ + +

Extending Bazel

+ diff --git a/site/_layouts/documentation.html b/site/_layouts/documentation.html index 15fd2087ddbfe5..d8ab958deced2e 100644 --- a/site/_layouts/documentation.html +++ b/site/_layouts/documentation.html @@ -41,335 +41,14 @@ {% endfor %} -

Home

- - -

Installing Bazel

- - -

Tutorials

- - -

Using Bazel

- - - {% if major_version == 0 %} -

Rules

- - {% endif %} - -

Reference

- - -

Extending Bazel

- + + {% if site.doc_versions contains current_version %} + {% capture sidebar %}documentation-sidebar/{{major_version}}/sidebar.html{% endcapture %} + {% else %} + + {% capture sidebar %}documentation-sidebar/master/sidebar.html{% endcapture %} + {% endif %} + {% include {{ sidebar }} current_version=current_version %} @@ -424,4 +103,3 @@

Extending Bazel

{% include footer.html %} - diff --git a/src/test/shell/bazel/list_source_repository.bzl b/src/test/shell/bazel/list_source_repository.bzl index 682b55e24a6aa7..732576bc1d0fb7 100644 --- a/src/test/shell/bazel/list_source_repository.bzl +++ b/src/test/shell/bazel/list_source_repository.bzl @@ -31,7 +31,7 @@ def _impl(rctx): if "SRCS_EXCLUDES" in rctx.os.environ: srcs_excludes = rctx.os.environ["SRCS_EXCLUDES"] - r = rctx.execute(["find", str(workspace), "-type", "f"]) + r = rctx.execute(["find", "-L", str(workspace), "-type", "f"]) rctx.file("find.result.raw", r.stdout.replace(str(workspace) + "/", "")) rctx.file("BUILD", """ genrule(