-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
cli: generate man-page #55268
base: main
Are you sure you want to change the base?
cli: generate man-page #55268
Conversation
fc27a80
to
7a99181
Compare
7a99181
to
343508c
Compare
f602715
to
9efb731
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #55268 +/- ##
==========================================
- Coverage 88.41% 88.41% -0.01%
==========================================
Files 653 654 +1
Lines 187476 187552 +76
Branches 36083 36081 -2
==========================================
+ Hits 165763 165826 +63
- Misses 14946 14959 +13
Partials 6767 6767 |
Can you attach comparison of the result before and after? |
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.
There are a lot of string manipulation operations happening here, and a lot of regular expressions.
It'd be great if you extracted those regex into constants and explained them and added more inline docs regarding the string operations you're doing and why (+ attaching relevant docs to the manfile spec that are relevant for the changes here)
I even wonder if this should live here? I have the feeling this could live under the api-docs-tooling
as this is certainly an API documentation but for the CLI aspect of Node.
And since a the api-docs-tooling
already has a lot of builtin pieces for manipulating and parsing the Markdown and generating things, maybe it'd be a good addition there, but that's a nit.
What makes this PR hard to review are the unknowns and little documentation, which in the end creates a "trust me, bro" sentiment since (at least I, as a reviewer) was given very little to be able to review these changes. It lacks more context and references to what is relevant for me to verify that it is working as expected. + It'd be great to have unit testing of the individual domain logic pieces of your tooling (extract them from the main function, into separate smaller functions, which allow us to better understand their in-and-outs) I'd also love some JSDoc here, that would also be very helpful :) |
Thanks for the detailed review! I hadn't even thought of it before, but I think you're right that
Yes, I should add documentation... Moving to draft until: |
Appreciate you! |
Ditto back to you :-) |
See nodejs/api-docs-tooling#125, which implements this using the already established parsers, allowing for more details (more than 1 sentence) for the mandoc. Leaving this as a draft in case that is a no-go. |
CLI.md
9efb731
to
1615b2d
Compare
CLI.md
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.
LGTM! Awesome stuff ✨
I'm concerned that contributors may forget to regenerate this file when they modify the CLI file, so I'll add a network test (network to download api-docs-tooling) to ensure it's properly generated. |
c9de3c3
to
15c207e
Compare
15c207e
to
551d4f7
Compare
@nodejs/build this causes |
There haven't been any objections in a few days to my comment above, if a new CI is started, can this land anytime soon? |
child_process.execFileSync(process.execPath, [ | ||
npxPath, | ||
'--yes', | ||
'github:nodejs/api-docs-tooling', | ||
'-i', path, | ||
'-o', '.tmp.1', | ||
'-t', 'man-page', | ||
]); | ||
manPageContent = fs.readFileSync('.tmp.1', 'utf-8'); | ||
isManPageModified = manPageContent !== fs.readFileSync(manFilePath, 'utf-8'); | ||
fs.rmSync('.tmp.1'); |
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.
Instead of reading a file to delete it right away, why not use stdout? Also using sync operations seems unwise, and re-reading the same man file in the loop looks like a mistake
child_process.execFileSync(process.execPath, [ | |
npxPath, | |
'--yes', | |
'github:nodejs/api-docs-tooling', | |
'-i', path, | |
'-o', '.tmp.1', | |
'-t', 'man-page', | |
]); | |
manPageContent = fs.readFileSync('.tmp.1', 'utf-8'); | |
isManPageModified = manPageContent !== fs.readFileSync(manFilePath, 'utf-8'); | |
fs.rmSync('.tmp.1'); | |
const cp = child_process.spawn(process.execPath, [ | |
npxPath, | |
'--yes', | |
'github:nodejs/api-docs-tooling', | |
'-i', path, | |
'-o', '-', | |
'-t', 'man-page', | |
], { stdio: ['inherit', 'pipe', 'inherit']}); | |
manPageContent = Buffer.concat(await cp.stdout.toArray()); | |
isManPageModified = manPageContent.compare(actualManPageContent); |
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.
Yes. If nodejs/api-docs-tooling#137 lands, this will be a lot simpler, as child_process
won't be needed at all.
npxPath, | ||
'--yes', | ||
'github:nodejs/api-docs-tooling', |
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.
Using npx sounds like very bad DX, we will end up with different versions on different machines, won't we? I'm -1 on that, let's do like we do for linting the version number: the linter may or may not get the info from the env, if not it doesn't check it, and the CI can still report problems, and the devs stay happy:
node/.github/workflows/linters.yml
Lines 107 to 116 in 8de2695
- name: Get release version numbers | |
if: ${{ github.event.pull_request && github.event.pull_request.base.ref == github.event.pull_request.base.repo.default_branch }} | |
id: get-released-versions | |
run: ./tools/lint-md/list-released-versions-from-changelogs.mjs >> $GITHUB_OUTPUT | |
- name: Lint markdown files | |
run: | | |
echo "::add-matcher::.github/workflows/remark-lint-problem-matcher.json" | |
NODE=$(command -v node) make lint-md | |
env: | |
NODE_RELEASED_VERSIONS: ${{ steps.get-released-versions.outputs.NODE_RELEASED_VERSIONS }} |
This PR adds a tool to generate the
node.1
file. See nodejs/api-docs-tooling#125