-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
docs: generate cli flags docs from code #21270
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
base: main
Are you sure you want to change the base?
Conversation
sapphi-red
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's better to generate the json when bundling the vite package. Then, cli.js would always exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add this file to
Line 3 in 181d870
| git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF docs package.json pnpm-lock.yaml netlify.toml packages/vite/package.json scripts/docs-check.sh |
so that the docs are built when this file changes.
| <!-- render as html --> | ||
| <div v-html="data.viteDevFlags"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One downside of using HTML tags is that the md files does not contain the content: https://deploy-preview-21270--vite-docs-main.netlify.app/guide/cli.md
I guess it's ok for now.
| ## Shared Options | ||
|
|
||
| These options are available for all commands. | ||
|
|
||
| <div v-html="data.globalFlags"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should put this as the first item? I think it's difficult to notice that these options exists.
An alternative would be to link to this section from all "Options" sections or duplicating these into all "Options".
Related: #19436
Preview link: https://deploy-preview-21270--vite-docs-main.netlify.app/guide/cli
The flow:
docs/_data/cli-vite.jsonfromdocs/.vitepress/updateData.config.ts(called on vitepress config load)docs/_data/cli-vite.data.tsloads the JSON and formats as HTML.docs/guide/cli.mdloads the HTML and renders it.I separated step 1 & 2 as two steps so that translators can directly translate on the
docs/_data/cli-core.jsonfile. Maybe there's a better way to organize the source of truth but I went with this for now to prevent editing the CLI code too much.Other changes:
--profileflag to CLI help message, so the generation also picks it up. A caveat however is that it's missing a link to the performance page.