-
Notifications
You must be signed in to change notification settings - Fork 288
Update agent cli reference docs generation #2406
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
Update agent cli reference docs generation #2406
Conversation
Certain help text in the agent will display the user's home directory as part of a default value. But this does not make sense in the docs.
Now, we will encase code blocks in `shell` backtick blocks. In the input, we will use 2 spaces for indentation, and we will use 4 spaces to indicate the start of a code block. We also substitute prime symbols in more places. And we will prevent the user's home directory from leaking into the docs via this script.
Previously, there was a state machine that was controlled by 2 boolean variables. But there were only 3 valid states. Now, because the state machine is explicit, we can avoid the invalid state.
|
Preview URL: https://2406--bk-docs-preview.netlify.app |
99fea56 to
9c0af63
Compare
| # Replace all prime symbols with backticks. We use prime symbols instead of backticks in CLI | ||
| # helptext because Go does not support escaping backticks in backtick delimited strings. | ||
| # See: https://github.com/buildkite/agent/blob/main/clicommand/prime-signs.md | ||
| line.tr!("′", "`") |
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.
Woah, my browser is not rendering this very well, but you should be able to copy this into your text editor and see that is prime sign.
scripts/cli2md.rb
Outdated
| ARGF.each_with_index do |line, line_num| | ||
| # Headings | ||
| # Replace all prime symbols with backticks. We use prime symbols instead of backticks in CLI | ||
| # helptext because Go does not support escaping backticks in backtick delimited strings. |
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.
because Go does not support escaping backticks in backtick delimited strings
this is true, but not why we avoid backticks in usage strings; we actually avoid them because urfave/cli has special handling for backtick-enclosed substrings in usage docs, and mangles usage strings that have backticked strings in them
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.
admittedly i probably could have put that there instead of just writing "reasons"
d7423a9 to
bda8578
Compare
This is the script
cli2md.rbthat generates the agent cli reference docs.Its input is the output of
buildkite-agentcommands with the flag--help.We've changed some of the practices since when this script was first written. Now:
shellbacktick blocks. In the input, we will use 4 spaces to indicate the start of a code block.There is a companion PR to adjust the cli commands in the agent to work consistently with this script. If you checkout that version of the agent, compile it and run
scripts/update-agent-help.sh, it should be a no-op.