Skip to content

Commit

Permalink
feat: show doc of variants after links (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz authored Nov 16, 2024
1 parent 7147389 commit 4909b22
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dargs/dargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,16 @@ def gen_doc_flag(self, path: list[str] | None = None, **kwargs) -> str:
choicedoc = indent("| possible choices: " + ", ".join(l_choice), INDENT)
realdoc = indent(self.doc + "\n", INDENT) if self.doc else None
anchor = make_rst_refid(arg_path) if kwargs.get("make_anchor") else None
abstractdoc = indent(
"\n".join(
[
f"* {ll}: {cc.doc}"
for ll, cc in zip(l_choice, self.choice_dict.values())
if cc.doc
]
),
INDENT,
)
allparts = [
anchor,
headdoc,
Expand All @@ -960,6 +970,9 @@ def gen_doc_flag(self, path: list[str] | None = None, **kwargs) -> str:
choicedoc,
"",
realdoc,
"",
abstractdoc,
"",
targetdoc,
]
return "\n".join([x for x in allparts if x is not None])
Expand Down

0 comments on commit 4909b22

Please sign in to comment.