Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix liquid variable leakage in navigation components #1243

Merged
merged 10 commits into from
May 9, 2023

Conversation

pdmosses
Copy link
Contributor

Fix #1118

Improve the modularity of building the nav-panel, breadcrumbs, and children-nav by making them independent. This also significantly simplifies the Liquid code.

This is purely a refactoring, and shouldn't affect the generated site (modulo layout).

Fix just-the-docs#1118

Improve the modularity of building the nav-panel, breadcrumbs, and children-nav
by making them independent. This also significantly simplifies the Liquid code.
Revert to the previous layout in the HTML, to allow the use of `diff` to check the built site.
Revert inclusion of single breadcrumb for top-level pages.
Revert to the previous layout in the HTML, to allow the use of `diff` to check the built site.
Revert to the previous layout in the HTML, to allow the use of `diff` to check the built site.
@pdmosses
Copy link
Contributor Author

pdmosses commented Apr 30, 2023

Building the just-the-docs-tests repo with this PR branch gives the same site as when using [email protected] (modulo white space):

just-the-docs-tests: diff -rBwtb -x "*.js*" -x "*.map" -I "published_time|dateModified" _site-0.5.1 _site-fix-leakage       
diff -rBwtb -x *.js* -x *.map -I published_time|dateModified _site-0.5.1/customization/nav-footer/index.html _site-fix-leakage/customization/nav-footer/index.html
369c369
< just-the-docs/just-the-docs @v0.5.1</p>
---
> pdmosses/just-the-docs @fix-leakage</p>
diff -rBwtb -x *.js* -x *.map -I published_time|dateModified _site-0.5.1/index.html _site-fix-leakage/index.html
339c339
<   <dd>just-the-docs/just-the-docs @v0.5.1</dd>
---
>   <dd>pdmosses/just-the-docs @fix-leakage</dd>
just-the-docs-tests: 

Ironically, diff may itself differ, depending on the platform. The version used above is from macOS 13.3. diff --version reports only Apple diff (based on FreeBSD diff). The man pages include:

The diff utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification.

The flags [-AaDdIiLlNnPpqSsTtwXxy] are extensions to that specification.

We need to avoid diff ignoring significant differences that might affect the appearance or navigation of our websites. The following simplified set of options gives the same result as shown above:

just-the-docs-tests: diff -rw -x "*.js*" -x "*.map" -I "published_time" -I "dateModified" _site-0.5.1 _site-fix-leakage | more

Regarding the options used:

  • -r: Causes application of diff recursively to common subdirectories encountered.
  • -w: […] causes whitespace (blanks and tabs) to be totally ignored.
  • -x "*.js*" -x "*.map": Exclude JavaScript and CSS map files and subdirectories
  • -I "published_time" -I "dateModified": Ignores changes of build-dependent metadata.

In practice, changes in the Liquid code used to build HTML can easily affect where lines are broken, causing diff to report irrelevant differences on all pages. Some of the commits in this PR were merely to ensure the line breaks are the same.

@pdmosses
Copy link
Contributor Author

pdmosses commented Apr 30, 2023

@mattxwang This PR is partly preparation for updating #462 to 0.5.

Copy link
Member

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super impressive work!

Based on the previous modularization-PR, am I correct that this also means we can remove the special code in _layouts/minimal.html? If so, it'd be nice to bundle that change into this PR as well.

@mattxwang mattxwang changed the title Fix variable leakage Fix liquid variable leakage in navigation components May 1, 2023
Remove the previously required workaround involving `nav.html`.
The aim of the initial version of these docs pages is to illustrate the difference between the default and minimal layouts.
@pdmosses
Copy link
Contributor Author

pdmosses commented May 2, 2023

Based on the previous modularization-PR, am I correct that this also means we can remove the special code in _layouts/minimal.html?

Yes

If so, it'd be nice to bundle that change into this PR as well.

That was easy enough…

In a separate commit, I've also added some basic docs pages about layout. You're welcome to review those for accuracy, but let's defer discussion of improvements to them (as that can be done independently of releases).

Copy link
Member

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub's provided diff is a bit tricky to grok, but looking through the change I think I'm confident in these changes; paired with your diff-based test, I think this is good to merge.

Re: documentation, I appreciate the initiative on writing this up! Don't have any criticism with this; in fact, it may also help users who are struggling to get layout: default to work (there have been a few issues I've triaged with that as the problem).

Whenver you feel ready, feel free to squash-merge + add the changelog entry!

@pdmosses
Copy link
Contributor Author

pdmosses commented May 3, 2023

Whenver you feel ready, feel free to squash-merge + add the changelog entry!

It's a very long time since I last tried merging anything into main

  1. Do I need to merge main into the PR branch before the squash-merge?
  2. And to add the changeling entry, should I simply edit it on GitHub, or should that be documented by a separate PR?

@pdmosses pdmosses mentioned this pull request May 3, 2023
@mattxwang
Copy link
Member

Sorry for the late response, things have been hectic.

Do I need to merge main into the PR branch before the squash-merge?

Nope! Though, you can if it helps you debug and/or gives you peace of mind; it has no impact on the final commit (if squashed).

And to add the changelog entry, should I simply edit it on GitHub, or should that be documented by a separate PR?

Simply editing it on GitHub is fine; in this case, you can also bundle it into this commit, if you'd like.

@pdmosses pdmosses merged commit 8e38759 into just-the-docs:main May 9, 2023
18 checks passed
@pdmosses pdmosses deleted the fix-leakage branch May 9, 2023 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolve liquid variable leakage between components
2 participants