-
Notifications
You must be signed in to change notification settings - Fork 579
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
Adjusting cobra help text #3465
Conversation
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.
Thanks so much for this! I left a couple small requests.
src/python/gen-rpk-help-doc.py
Outdated
import re | ||
|
||
class Flag: | ||
def __init__(self, value, type,explanation): |
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.
Let's run a linter on this to fix these small formatting inconsistencies. There's already a yapf config.
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.
Fixed!
src/python/gen-rpk-help-doc.py
Outdated
def get_explanation(process_line): | ||
return process_line[:process_line.find("Usage")].rstrip("\n") | ||
|
||
def get_usage(process_line): |
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.
For each function which receives a line and parses it, could you please add comments about the structure of the line it expects, and the output?
The python script The changes in the golang files in this PR to fix capitalization and whitespacing LGTM. |
In addition, because An example of using cobra to generate docs for the GitHub CLI golang project can be found here: https://github.com/cli/cli/blob/trunk/cmd/gen-docs/main.go Using cobra's doc generation may be easier than trying to line up |
Yeah, we considered it in our original ticket |
We could have a hidden help flag, |
After discussion in our slack channel, this script won't be integrated into the pipeline. I'll be removing the .md file from this PR in result of that. |
Addressing the reported issues (formatting) as well. Docs PR: For this PR we will only keep the change to the .go files |
@twmb since the output won't be directly integrated into the pipeline anymore, I guess there's not much reason to change the script now. Thank you for looking it up tho! |
A comma-delimited list of the addresses (<host:port>) of all the redpanda nodes | ||
in a cluster. The port must be the one configured for the nodes' admin API | ||
(%d by default)`, | ||
fmt.Sprintf(`A comma-delimited list of the addresses (<host>:<port>) of all the redpanda nodes in a cluster. The port must be the one configured for the nodes' admin API (%d by default)`, |
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'm ok with this change (and may shorten the wording a bit later), but why merge in this PR?
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.
Since the script that I wrote try to read each line, this extra was giving me some trouble. So it's a good idea to standardize it now.
cmd.Flags().StringVar(&toFile, "to-file", "", "seek to offsets as specified in the file") | ||
cmd.Flags().StringArrayVar(&topics, "topics", nil, "only seek these topics, if any are specified") | ||
cmd.Flags().BoolVar(&allowNewTopics, "allow-new-topics", false, "allow seeking to new topics not currently consumed (implied with --to-group or --to-file)") | ||
cmd.Flags().StringVar(&to, "to", "", "Where to seek (start, end, unix second | millisecond | nanosecond)") |
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'm ok with this, and I think we should standardize around capitlizing the first word in short help text lines. I previously thought that short help (the text after the flag itself) was lowercased usually, but looking at ls --help
and rg --help
, first-word-capitalization seems to be common.
@twmb All points addressed. |
We created a python script that autogen docs for rpk based on the texts retrieved from
rpk [command] -h
generated by Cobra.This script is living in a private tooling repo for now.
This PR adapts some texts in Cobra CLI to better reflect the expected output in the docs and to avoid unexpected results.