From 908e944bddb146fda6ac2ba0ede19c9f394e6b29 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 17 Oct 2015 21:53:09 +0200 Subject: [PATCH] include the help offered by borg help in the usage docs, fixes #293 it's not pretty yet, but better than nothing. --- docs/usage.rst | 6 ++++++ setup.py | 30 ++++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index ae50fc120..731efc26f 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -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 ---------------- diff --git a/setup.py b/setup.py index 5c3e31d8f..6a5ed5863 100644 --- a/setup.py +++ b/setup.py @@ -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']