From f4c5c12fe48643b7ff306fb995b0324b9a9d3d6a Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sat, 16 Nov 2024 08:21:06 -0500 Subject: [PATCH 1/2] feat: show doc of variants after links Signed-off-by: Jinzhe Zeng --- dargs/dargs.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dargs/dargs.py b/dargs/dargs.py index b590074..20930eb 100644 --- a/dargs/dargs.py +++ b/dargs/dargs.py @@ -952,6 +952,13 @@ 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 = "\n".join( + [ + f"* {ll}: {cc.doc}" + for ll, cc in zip(l_choice, self.choice_dict.values()) + if cc.doc + ] + ) allparts = [ anchor, headdoc, @@ -960,6 +967,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]) From 1a77262f07843d403b19bec07d6a9d9b0631b152 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sat, 16 Nov 2024 08:25:35 -0500 Subject: [PATCH 2/2] indent Signed-off-by: Jinzhe Zeng --- dargs/dargs.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dargs/dargs.py b/dargs/dargs.py index 20930eb..caf8dc6 100644 --- a/dargs/dargs.py +++ b/dargs/dargs.py @@ -952,12 +952,15 @@ 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 = "\n".join( - [ - f"* {ll}: {cc.doc}" - for ll, cc in zip(l_choice, self.choice_dict.values()) - if cc.doc - ] + 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,