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

doc: add possibility to patch static HTML files #36495

Closed
wants to merge 1 commit into from

Conversation

tniessen
Copy link
Member

While it is great that our documentation is static, it does bring some downsides. For example, when a user selects an older version of Node.js from the dropdown menu at the top, they won't be able to switch to a newer version because the dropdown menu in the older version doesn't know about the newer version. We've also had significant formatting issues in some versions of the documentation, and there is no way to fix that apart from releasing a new version.

This PR is a suggestion that adds a single script tag to the end of the body, therefore not slowing down the page. The referenced file would be in the static/js directory in the website repository and could be changed at any time to apply arbitrary (visual) patches to static documentation files.

Again, this is just a suggestion. This is only useful if we add it as soon as possible, since it can only affect versions and releases that include this patch. I'd be happy to hear opinions!

My primary concern is adding a dependency on the nodejs.org domain -- however unlikely it may be that it will ever go away. That's why the script should only apply visual patches, not content patches, in my opinion. In rare cases when users do not have internet access and are looking at a local copy, the page should still work just fine. (We are already loading a stylesheet from Google servers so there is an external dependency already.)

I also fully understand if people feel like this adds unnecessary complexity. Again, the main point is that this is not something we can patch in later. We could even leave the JavaScript file empty, just to have the option of using this feature in the future. (Updating the version dropdown would be really neat, though.)

An alternative would be to just let static files be static files, and forget about them as soon as we release a new version. Or we could somehow patch them server-side, but I am not a huge fan of that approach.

Long story short, I am looking for opinions regarding this idea! Thank you!

cc @nodejs/website @nodejs/documentation

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Dec 12, 2020
@@ -53,5 +53,6 @@ <h2>Table of Contents</h2>
</div>
</div>
</div>
<script src="https://nodejs.org/static/js/doc-patches.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<script src="https://nodejs.org/static/js/doc-patches.js"></script>
<script src="https://nodejs.org/static/js/doc-patches.js" type="module"></script>
<script src="https://nodejs.org/static/js/doc-patches.js" nomodule defer async></script>

@mscdex
Copy link
Contributor

mscdex commented Dec 12, 2020

What exactly would be in this script if it's going to be included for every node version going forward? It seems like it'd quickly turn into a maintenance nightmare if the intent is to more or less backport doc fixes on the client side instead of relying on the traditional git-based process?

@tniessen
Copy link
Member Author

What exactly would be in this script if it's going to be included for every node version going forward?

For example, a few lines to add newer versions to the incomplete dropdown menu shown by older versions. Primarily, it's about the ability to apply changes in the future without having to rebuild docs.

@Trott
Copy link
Member

Trott commented Dec 15, 2020

I guess this might solve the problem preventing #33466 from being workable. If so, I'd like that.

@tniessen
Copy link
Member Author

@Trott I believe it would allow solving that problem.

@tniessen tniessen marked this pull request as ready for review January 3, 2021 14:08
@tniessen tniessen added the review wanted PRs that need reviews. label Jan 3, 2021
@tniessen
Copy link
Member Author

@nodejs/documentation If there's no interest in this feature, feel free to close this PR.

@Trott
Copy link
Member

Trott commented Feb 22, 2021

I very much like the idea of being able to solve the version picker problem. It's a not-insignificant UX issue that confuses/frustrates users who use the version picker. On the other hand, I wish we didn't have to couple it to an asset that doesn't live in this repo. This may cause a minor issue (error loading the script) for folks who build the docs locally and use them when offline. I think that's an acceptable trade-off though and I don't have a better idea, as is evidenced from #33466 stalling.

/ping @codebytere (who at least at one time was keen to solve the version picker problem)

@Trott Trott added the blocked PRs that are blocked by other issues or PRs. label Feb 22, 2021
@Trott
Copy link
Member

Trott commented Feb 22, 2021

Added blocked label because this can't land until the file is created on the website.

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

Needs a rebase but LGTM

@tniessen
Copy link
Member Author

On the other hand, I wish we didn't have to couple it to an asset that doesn't live in this repo.

I'm not a fan of this either, I just can't think of any alternatives. Also, this won't solve the version picker problem for older versions without this patch.

@aduh95
Copy link
Contributor

aduh95 commented Feb 22, 2021

This may cause a minor issue (error loading the script) for folks who build the docs locally and use them when offline.

We could have the <script> tag added only if the docs are build with a CLI flag / some env variable, this way folks building the docs locally wouldn't be affected.

@tniessen
Copy link
Member Author

We could have the <script> tag added only if the docs are build with a CLI flag / some env variable, this way folks building the docs locally wouldn't be affected.

True, but then we'd end up with multiple different versions of the docs. I believe that's something we'd like to avoid. If we do allow it, we don't even need to add this at all, and can just edit the HTML files of previous versions on nodejs.org.

@tniessen
Copy link
Member Author

tniessen commented Aug 7, 2021

Closing due to the apparent lack of interest from Node.js.

@tniessen tniessen closed this Aug 7, 2021
@DerekNonGeneric
Copy link
Contributor

I would prefer if we do not close this just yet as it is probably the only issue tracking the version picker problem.

@Trott
Copy link
Member

Trott commented Aug 7, 2021

I'm super-busy cleaning my floors right now, but I'm going to stop long enough to post a roadmap for landing this.

  • Get the file on the website so the blocked label can be removed. I imagine it may be possible to get it on the website by opening a PR in the nodejs.org repository.
  • Rebase and wait for green GitHub Actions results.
  • I approved it and no one has objected and it's been more than 7 days. So once those other things are done, this can technically land. DARE YOU GO FOR IT??!!!!11!!111!!?????//!???!?!

@@ -53,5 +53,6 @@ <h2>Table of Contents</h2>
</div>
</div>
</div>
<script src="https://nodejs.org/static/js/doc-patches.js"></script>
Copy link
Member

Choose a reason for hiding this comment

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

sorry, I have 404 error with this link https://nodejs.org/static/js/doc-patches.js are you sure about the link (I can made error)

@tniessen
Copy link
Member Author

While this won't be solved within the API docs, it seems that the website rework team has an approach that works, even if it requires some additional complexity.

@tniessen tniessen closed this Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked PRs that are blocked by other issues or PRs. doc Issues and PRs related to the documentations. review wanted PRs that need reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants