Skip to content

Commit

Permalink
hide "Undocumented" for subparser help on RTD (#385)
Browse files Browse the repository at this point in the history
* adjust documentation for RTD and display

Now, the parser docstring is used as the help string for a given
subparser. This ensures ReadTheDocs displays a string rather than
“Undocumented”

* readthedocs test

* give a blank string for subparser help if the parser function docstring 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 authored Jun 30, 2016
1 parent 6ace9b6 commit 983ef66
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions util/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,14 @@ def make_parser(commands, description):
parser = argparse.ArgumentParser(description=description, usage='%(prog)s subcommand', add_help=False)
parser.add_argument('--help', '-h', action=_HelpAction, help=argparse.SUPPRESS)
parser.add_argument('--version', '-V', action='version', version=__version__, help=argparse.SUPPRESS)
subparsers = parser.add_subparsers(title='subcommands', dest='command')
subparsers = parser.add_subparsers(title='subcommands', dest='command', metavar='\033[F') # \033[F moves cursor up
for cmd_name, cmd_parser in commands:
p = subparsers.add_parser(cmd_name)
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 983ef66

Please sign in to comment.