include the help offered by borg help <topic> in the usage docs, fixes #293

it's not pretty yet, but better than nothing.
This commit is contained in:
Thomas Waldmann 2015-10-17 21:53:09 +02:00
parent 0e9c524266
commit 908e944bdd
2 changed files with 24 additions and 12 deletions

View File

@ -371,6 +371,12 @@ Examples
command="borg serve --restrict-to-path /mnt/backup" ssh-rsa AAAAB3[...]
Miscellaneous Help
------------------
.. include:: usage/help.rst.inc
Additional Notes
----------------

View File

@ -150,19 +150,25 @@ class build_usage(Command):
if not os.path.exists('docs/usage'):
os.mkdir('docs/usage')
for command, parser in choices.items():
if command is 'help':
continue
print('generating help for %s' % command)
with open('docs/usage/%s.rst.inc' % command, 'w') as doc:
print('generating help for %s' % command)
params = {"command": command,
"underline": '-' * len('borg ' + command)}
doc.write(".. _borg_{command}:\n\n".format(**params))
doc.write("borg {command}\n{underline}\n::\n\n".format(**params))
epilog = parser.epilog
parser.epilog = None
doc.write(re.sub("^", " ", parser.format_help(), flags=re.M))
doc.write("\nDescription\n~~~~~~~~~~~\n")
doc.write(epilog)
if command == 'help':
for topic in Archiver.helptext:
params = {"topic": topic,
"underline": '~' * len('borg help ' + topic)}
doc.write(".. _borg_{topic}:\n\n".format(**params))
doc.write("borg help {topic}\n{underline}\n::\n\n".format(**params))
doc.write(Archiver.helptext[topic])
else:
params = {"command": command,
"underline": '-' * len('borg ' + command)}
doc.write(".. _borg_{command}:\n\n".format(**params))
doc.write("borg {command}\n{underline}\n::\n\n".format(**params))
epilog = parser.epilog
parser.epilog = None
doc.write(re.sub("^", " ", parser.format_help(), flags=re.M))
doc.write("\nDescription\n~~~~~~~~~~~\n")
doc.write(epilog)
# return to regular Cython configuration, if we changed it
if os.environ.get('BORG_CYTHON_DISABLE') == self.__class__.__name__:
del os.environ['BORG_CYTHON_DISABLE']