Example #1
0
 def run(self):
     print('generating usage docs')
     # allows us to build docs without the C modules fully loaded during help generation
     from borg.archiver import Archiver
     parser = Archiver().build_parser(prog='borg')
     choices = {}
     for action in parser._actions:
         if action.choices is not None:
             choices.update(action.choices)
     print('found commands: %s' % list(choices.keys()))
     if not os.path.exists('docs/usage'):
         os.mkdir('docs/usage')
     for command, parser in choices.items():
         print('generating help for %s' % command)
         with open('docs/usage/%s.rst.inc' % command, 'w') as doc:
             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)
Example #2
0
 def run(self):
     print('generating usage docs')
     # allows us to build docs without the C modules fully loaded during help generation
     from borg.archiver import Archiver
     parser = Archiver().build_parser(prog='borg')
     choices = {}
     for action in parser._actions:
         if action.choices is not None:
             choices.update(action.choices)
     print('found commands: %s' % list(choices.keys()))
     if not os.path.exists('docs/usage'):
         os.mkdir('docs/usage')
     for command, parser in choices.items():
         print('generating help for %s' % command)
         with open('docs/usage/%s.rst.inc' % command, 'w') as doc:
             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)
Example #3
0
    def run(self):
        print('generating usage docs')
        import borg
        borg.doc_mode = 'build_man'
        if not os.path.exists('docs/usage'):
            os.mkdir('docs/usage')
        # allows us to build docs without the C modules fully loaded during help generation
        from borg.archiver import Archiver
        parser = Archiver(prog='borg').build_parser()
        borgfs_parser = Archiver(prog='borgfs').build_parser()

        self.generate_level("", parser, Archiver, {'borgfs': borgfs_parser})
Example #4
0
    def run(self):
        print('building man pages (in docs/man)', file=sys.stderr)
        import borg
        borg.doc_mode = 'build_man'
        os.makedirs('docs/man', exist_ok=True)
        # allows us to build docs without the C modules fully loaded during help generation
        from borg.archiver import Archiver
        parser = Archiver(prog='borg').build_parser()
        borgfs_parser = Archiver(prog='borgfs').build_parser()

        self.generate_level('', parser, Archiver, {'borgfs': borgfs_parser})
        self.build_topic_pages(Archiver)
        self.build_intro_page()
Example #5
0
 def run(self):
     print('generating usage docs')
     # allows us to build docs without the C modules fully loaded during help generation
     from borg.archiver import Archiver
     parser = Archiver(prog='borg').parser
     choices = {}
     for action in parser._actions:
         if action.choices is not None:
             choices.update(action.choices)
     print('found commands: %s' % list(choices.keys()))
     if not os.path.exists('docs/usage'):
         os.mkdir('docs/usage')
     for command, parser in choices.items():
         print('generating help for %s' % command)
         with open('docs/usage/%s.rst.inc' % command, 'w') as doc:
             doc.write(
                 ".. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!\n\n"
             )
             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".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    borg {command}"
                     .format(**params))
                 self.write_usage(parser, doc)
                 epilog = parser.epilog
                 parser.epilog = None
                 self.write_options(parser, doc)
                 doc.write("\n\nDescription\n~~~~~~~~~~~\n")
                 doc.write(epilog)
     common_options = [
         group for group in choices['create']._action_groups
         if group.title == 'Common options'
     ][0]
     with open('docs/usage/common-options.rst.inc', 'w') as doc:
         self.write_options_group(common_options, doc, False)
Example #6
0
    def run(self):
        print('generating usage docs')
        import borg
        borg.doc_mode = 'build_man'
        if not os.path.exists('docs/usage'):
            os.mkdir('docs/usage')
        # allows us to build docs without the C modules fully loaded during help generation
        from borg.archiver import Archiver
        parser = Archiver(prog='borg').build_parser()
        # borgfs has a separate man page to satisfy debian's "every program from a package
        # must have a man page" requirement, but it doesn't need a separate HTML docs page
        #borgfs_parser = Archiver(prog='borgfs').build_parser()

        self.generate_level("", parser, Archiver)
Example #7
0
 def run(self):
     print('generating usage docs')
     # allows us to build docs without the C modules fully loaded during help generation
     from borg.archiver import Archiver
     parser = Archiver(prog='borg').parser
     choices = {}
     for action in parser._actions:
         if action.choices is not None:
             choices.update(action.choices)
     print('found commands: %s' % list(choices.keys()))
     if not os.path.exists('docs/usage'):
         os.mkdir('docs/usage')
     for command, parser in choices.items():
         print('generating help for %s' % command)
         with open('docs/usage/%s.rst.inc' % command, 'w') as doc:
             doc.write(".. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!\n\n")
             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".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    borg {command}".format(**params))
                 self.write_usage(parser, doc)
                 epilog = parser.epilog
                 parser.epilog = None
                 self.write_options(parser, doc)
                 doc.write("\n\nDescription\n~~~~~~~~~~~\n")
                 doc.write(epilog)
     common_options = [group for group in choices['create']._action_groups if group.title == 'Common options'][0]
     with open('docs/usage/common-options.rst.inc', 'w') as doc:
         self.write_options_group(common_options, doc, False)