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

chore: fix documentation CLI #6566

Merged
merged 11 commits into from Mar 25, 2024

Conversation

jeluard
Copy link
Member

@jeluard jeluard commented Mar 19, 2024

Motivation

Make sure documentation CLI properly allow access to command arguments.

Note: format changes are the result of yarn docs:lint:fix

@jeluard jeluard force-pushed the jeluard/fix-documentation-cli branch from 21acc05 to 567a95e Compare March 19, 2024 13:55
@jeluard jeluard marked this pull request as ready for review March 19, 2024 20:56
@jeluard jeluard requested a review from a team as a code owner March 19, 2024 20:56
@@ -38,14 +38,13 @@ jobs:
- name: Check wordlist is sorted
run: scripts/wordlist_sort_check.sh

- name: Spellcheck
Copy link
Member Author

@jeluard jeluard Mar 20, 2024

Choose a reason for hiding this comment

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

Moved before the CLI reference generation as otherwise spellcheck fails on all custom headers ids.
We use custom header ids for subcommand arguments (- instead of --) so that previous links are not broken.

CLI docs are already checked as they are part of the source code.

Copy link
Member

Choose a reason for hiding this comment

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

CLI docs are already checked as they are part of the source code.

What do you mean here? I don't think we are spellchecking the source code

Copy link
Member Author

@jeluard jeluard Mar 21, 2024

Choose a reason for hiding this comment

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

Hmm that's unfortunate.

Spellchecking the CLIs docs fail because spellcheck wants to validate all ids. Not providing custom ids would potentially break external links.
Apparently there is no alternative with latest docusaurus.

Copy link
Member Author

Choose a reason for hiding this comment

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

The solution probably is to switch to mdx and explicitly export TOC metadata via the toc global. See facebook/docusaurus#6201 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

so before did it pass validation because we used backticks `` for those values, and can't we use this approach as well or does it not format as we want it to?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately spellcheck is also applied to the custom id part, and this part can't be escaped.
e.g. ### `--myArg` {#-myArg}

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed it by programmatically generating the TOC. This open the door for more customizations down the line.

Capture d’écran 2024-03-25 à 10 19 04

Copy link
Member

Choose a reason for hiding this comment

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

Do you have these changes deployed somewhere to review? I guess I can run the branch locally as well to review the rendered UI. This is similar to ethereum/beacon-APIs#415 would be great to have but likely a bit of effort.

Copy link
Member

Choose a reason for hiding this comment

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

But since we plan to add more complex / interactive code examples in the docs, it might be warranted to implement as it makes reviewing so much easier

Copy link
Member Author

Choose a reason for hiding this comment

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

@jeluard jeluard force-pushed the jeluard/fix-documentation-cli branch from 192e438 to 2c3b4f1 Compare March 21, 2024 10:30
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Merging #6566 (ecaee03) into unstable (da69a7b) will increase coverage by 0.00%.
Report is 4 commits behind head on unstable.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #6566   +/-   ##
=========================================
  Coverage     61.48%   61.49%           
=========================================
  Files           556      556           
  Lines         58891    58895    +4     
  Branches       1854     1856    +2     
=========================================
+ Hits          36212    36216    +4     
  Misses        22638    22638           
  Partials         41       41           

@jeluard jeluard mentioned this pull request Mar 21, 2024
8 tasks
@jeluard jeluard force-pushed the jeluard/fix-documentation-cli branch from 8515b31 to 0c2bebb Compare March 23, 2024 08:45
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@docusaurus/theme-mermaid": "^3.1.1",
"@docusaurus/core": "0.0.0-5872",
Copy link
Member

Choose a reason for hiding this comment

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

Do we wanna wait until this fix is in a stable release? Deadline would be the 1.18.0 if it is not released by then we can go ahead and merge this

Copy link
Member Author

Choose a reason for hiding this comment

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

I would lean towards merging, as it would allow to work on things like optimizing SEO in parallel.
Given that this dependency is docs specifics, I think it's fine.

});

lightclient.emitter.on(LightclientEvent.lightClientOptimisticHeader, async (optimisticUpdate) => {
logger.info(optimisticUpdate);
Copy link
Member

Choose a reason for hiding this comment

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

How did you find all these formatting issues, just manual review?

Copy link
Member Author

Choose a reason for hiding this comment

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

Those were identified by yarn docs:lint

Copy link
Member

Choose a reason for hiding this comment

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

ah right sorry, you already noted that in the PR description but I am a bit confused, how was this not caught by the CI

- name: Check docs format
run: yarn docs:lint:fix

Copy link
Member Author

Choose a reason for hiding this comment

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

This line actually fixes the format directly without failing, then the workflow proceeds.

Copy link
Member

@nflaig nflaig Mar 25, 2024

Choose a reason for hiding this comment

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

This line actually fixes the format directly without failing, then the workflow proceeds.

this seems wrong, at least in .github/workflows/docs-check.yml it doesn't seem right to run lint:fix, should just do lint check instead

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, changed so that it runs yarn docs:lint

Copy link
Member

@nflaig nflaig Mar 25, 2024

Choose a reason for hiding this comment

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

Makes sense, changed so that it runs yarn docs:lint

Would be good to double check that it now also fails if there is a lint issue. Ideally, we should not have this change in this PR (Im ok with having it here tho)

Copy link
Member Author

Choose a reason for hiding this comment

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

It does, I had to fix an extra lint issue :)

Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

@@ -90,7 +90,7 @@ function renderExamplesSection(examples: CliExample[], sectionTitle?: string, lo
function renderOption(optionName: string, option: CliOptionDefinition): string | undefined {
if (option.hidden) return;

const commandOption = [`<h3 id='-${optionName}'><code>--${optionName}</code><a href="#-${optionName}" class="hash-link" title="--${optionName}"></a></h3>`];
const commandOption = [`### \`--${optionName}\` {#-${optionName}}`];
Copy link
Member

Choose a reason for hiding this comment

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

The cli flag headers look much bigger than what we currently have

Copy link
Member

Choose a reason for hiding this comment

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

looks like we add 4x # previously

const commandOption = [`#### \`--${optionName}\``];

@jeluard
Copy link
Member Author

jeluard commented Mar 25, 2024

Actually I realize that my solution of generating the TOC doesn't help with the spell-check issue, as there is still a need to generate the html anchor using custom-ids.

So we are back to the same 2 options:

  • do not spell-check generated CLI docs
  • have links pointing to CLI args broken (- vs --)

Note that there is a way to handle link redirects with docusaurus, so we could handle if the number of broken links is not too big.

My preference would be to bite the bullet and fix links at the source as much as we can and adopt the new link format.

@nflaig
Copy link
Member

nflaig commented Mar 25, 2024

Some nav links from toc on the sidebar don't work

image

Results in this URL: https://jeluard.github.io/lodestar/validator-management/validator-cli/#slashing-protection%20%3Ccommand%3E

@nflaig
Copy link
Member

nflaig commented Mar 25, 2024

My preference would be to bite the bullet and fix links at the source as much as we can and adopt the new link format.

The majority of broken links were actually due to splitting docs up and moving into different sub paths. Since linking to specific CLI flag is quite new, the amount of broken links will be limited, and worst case the user still ends up on the right CLI docs page, just not navigated to the flag directly.

Let's go ahead and use the approach that works with our new docs setup the best and without workarounds, I think I know pretty well were to fix docs, and will do that once we release the new docs

@jeluard
Copy link
Member Author

jeluard commented Mar 25, 2024

Latest version using the out-of-the-box docusaurus solution is deployed. Sounds like a more robust approach.

Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

LGTM, I think before we do the release we should do another sweep and compare the new docs vs currently deployed docs

@jeluard jeluard merged commit 948de61 into ChainSafe:unstable Mar 25, 2024
18 of 20 checks passed
@jeluard jeluard deleted the jeluard/fix-documentation-cli branch March 25, 2024 14:43
@jeluard
Copy link
Member Author

jeluard commented Mar 25, 2024

I deployed unstable here: https://jeluard.github.io/lodestar/
I did some sanity checks, looks good to me.

@nflaig
Copy link
Member

nflaig commented Mar 25, 2024

I deployed unstable here: https://jeluard.github.io/lodestar/ I did some sanity checks, looks good to me.

Yes looks mostly correct, I opened a PR with some minor fixes #6590. Also gave this a try locally, devex is very good now :)

@wemeetagain
Copy link
Member

🎉 This PR is included in v1.18.0 🎉

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.

None yet

3 participants