Skip to content

Commit

Permalink
give a blank string for subparser help if the parser function docstri…
Browse files Browse the repository at this point in the history
…ng is null so sphinx-argparse doesn't render "Undocumented"

give a blank string for subparser help if the parser function docstring
is null so sphinx-argparse doesn't render "Undocumented"
  • Loading branch information
tomkinsc committed Jun 29, 2016
1 parent 195d343 commit 65212f5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions util/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ def make_parser(commands, description):
parser.add_argument('--version', '-V', action='version', version=__version__, help=argparse.SUPPRESS)
subparsers = parser.add_subparsers(title='subcommands', dest='command', metavar='\033[F') # \033[F moves cursor up
for cmd_name, cmd_parser in commands:
if os.environ.get('READTHEDOCS'):
p = subparsers.add_parser(cmd_name, help=" ")
else:
help_str = cmd_parser.__doc__ if cmd_parser.__doc__ and len(cmd_parser.__doc__) else None
p = subparsers.add_parser(cmd_name, help=help_str)
help_str = cmd_parser.__doc__ if cmd_parser.__doc__ and len(cmd_parser.__doc__) else None
# give a blank string for help if the parser docstring is null
# so sphinx-argparse doesnt't render "Undocumented"
if (not help_str) and os.environ.get('READTHEDOCS') or 'sphinx' in sys.modules:
help_str = " "
p = subparsers.add_parser(cmd_name, help=help_str)
cmd_parser(p)
return parser

Expand Down

0 comments on commit 65212f5

Please sign in to comment.