Skip to content
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

Adding CMD Flags to Docs Generation #4123

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions website/generate_terminal_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,13 @@ def process_cmd_parsers(ctrl: ControllerDoc) -> List[Dict[str, str]]:
# We do this to fix multiline docstrings for the markdown
doc = " ".join(doc.split()).replace(*USER_PATH)

if (flags := action.option_strings) is not None:
flags = " ".join(flags)

actions.append(
{
"opt_name": action.dest if action.dest else "",
"flags": flags if flags else "",
"doc": doc if doc else "",
"default": f"{default}".replace(*USER_PATH),
"optional": not action.required,
Expand Down Expand Up @@ -170,14 +174,18 @@ def generate_markdown(

markdown += "---\n\n## Parameters\n\n"
if cmd_meta["actions"]:
markdown += "| Name | Description | Default | Optional | Choices |\n"
markdown += "| ---- | ----------- | ------- | -------- | ------- |\n"
markdown += (
"| Name | Parameter | Description | Default | Optional | Choices |\n"
)
markdown += (
"| ---- | --------- | ----------- | ------- | -------- | ------- |\n"
)

for param in cmd_meta["actions"]:
if isinstance(param, dict):
markdown += (
f"| {param['opt_name']} | {param['doc']} | {param['default']} "
f"| {param['optional']} | {param['choices']} |\n"
f"| {param['opt_name']} | {param['flags']} | {param['doc']} "
f"| {param['default']} | {param['optional']} | {param['choices']} |\n"
)
else:
markdown += "This command has no parameters\n\n"
Expand Down