-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
add script to automatically dump CLI usage into documentation #3589
Conversation
|
||
Commands: | ||
init <path> initialize a client-side mocha setup at <path> | ||
init <path> initialize a client-side mocha setup at <path> | ||
``` |
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.
Why was indentation removed? Running --help
on most programs displays cmdline options with indentation.
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.
probably has to do with the lack of a tty somewhere.
the actual bin/mocha --help
output has indents.
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.
That's what I thought this was supposed to do -- run mocha --help
and paste its exact content.
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.
it does, but the exact content when run without a terminal window doesn't have the leading indents, ostensibly because process.stdout.columns
is undefined.
I don't know how to force this value to be present unless I monkeypatch it; it comes out of Node.js internals. it'd need to be monkeypatched for this script only, which is honestly more effort than I'd like to go to... if you can figure out how to fake a tty for this, go ahead and make the necessary changes. I'm curious about the solution, anyway!
c3d90a1
to
80e45a3
Compare
} | ||
|
||
if (sections.length === 3) { | ||
// this is triggered if we already have stuff in between the comments |
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.
So if a usage codefence is already present? When would that not be the case?
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.
no, meaning, if we have
<!-- usage -->
STUFF
<!-- usagestop -->
we hit the first branch, otherwise if we have this (whitespace or nothing):
<!-- usage -->
<!-- usagestop -->
we hit the second.
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.
no, meaning, if we have
<!-- usage --> STUFF <!-- usagestop -->
we hit the first branch, otherwise if we have this (whitespace or nothing):
<!-- usage --> <!-- usagestop -->
we hit the second.
Well, that was what I assumed, where STUFF=code fence. Just not following when the second case would ever occur.
80e45a3
to
8db64d2
Compare
- rename `scripts/docs-update-toc.js` to reflect that it does more than just that
8db64d2
to
bded805
Compare
merging this; if there are further concerns, please send edits |
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.
Well, guess it doesn't matter since it's already merged...
@@ -512,6 +513,7 @@ | |||
"markdownlint-cli": "^0.9.0", | |||
"nps": "^5.7.1", | |||
"nyc": "^11.7.3", | |||
"mississippi": "^3.0.0", |
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.
Move "mississippi" to L513.5
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.
Why not done alphabetically?
} | ||
|
||
if (sections.length === 3) { | ||
// this is triggered if we already have stuff in between the comments |
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.
no, meaning, if we have
<!-- usage --> STUFF <!-- usagestop -->
we hit the first branch, otherwise if we have this (whitespace or nothing):
<!-- usage --> <!-- usagestop -->
we hit the second.
Well, that was what I assumed, where STUFF=code fence. Just not following when the second case would ever occur.
}); | ||
} | ||
|
||
updateTOC().then(updateUsage()); |
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.
Don't you need a catch
here?
updateTOC().then(updateUsage()).catch((err) => {
const script = path.basename(
require.main.filename, path.extname(require.main.filename)
);
console.error(`${script}:`, err);
});
this looks for
<!-- usage -->
and<!-- usagestop -->
indocs/index.md
and replaces everything between these two comments with the current output ofbin/mocha --help
.