Skip to content

Commit 7748841

Browse files
committed
allow skipping sections
this is useful when you have an argument group that is used in all subcommands, but you do not want to repeat it over and over again.
1 parent ee542af commit 7748841

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/extend.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ You can also add classifiers, which will change how these definitions are incorp
6262
--upgrade : @after
6363
The after directive is the default, so you needn't specify it.
6464

65+
advanced arguments : @skip
66+
skip advanced arguments
67+
6568

6669
@before
6770
Insert content before the parsed help/description message of the argument/option/subcommand/argument-group.
@@ -71,3 +74,6 @@ You can also add classifiers, which will change how these definitions are incorp
7174

7275
@replace
7376
Replace content of help/description message of argument/option/subcommand/argument-group.
77+
78+
@skip
79+
Skip the content of help/description message of subcommand/argument-group.

sphinxarg/ext.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def map_nested_definitions(nested_content):
3232
if len(ci.children) > 0:
3333
classifier = ci.children[0].astext()
3434
if classifier is not None and classifier not in (
35-
'@replace', '@before', '@after'):
35+
'@replace', '@before', '@after', '@skip'):
3636
raise Exception('Unknown classifier: %s' % classifier)
3737
idx = subitem.first_child_matching_class(nodes.term)
3838
if idx is not None:
@@ -93,6 +93,8 @@ def print_action_groups(data, nested_content, markDownHelp=False, settings=None)
9393
desc.append(s)
9494
elif classifier == '@before':
9595
desc.insert(0, s)
96+
elif classifier == '@skip':
97+
continue
9698
if len(subContent) > 0:
9799
for k, v in map_nested_definitions(subContent).items():
98100
definitions[k] = v

0 commit comments

Comments
 (0)