/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/generate_docs.py

  • Committer: Jelmer Vernooij
  • Author(s): Richard Wilbur
  • Date: 2017-05-30 23:37:11 UTC
  • mto: This revision was merged to the branch mainline in revision 6645.
  • Revision ID: jelmer@jelmer.uk-20170530233711-r0m0qp8hpkqzpopw
Fix order in which files are processed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
 
"""%(prog)s - generate information from built-in bzr help
 
19
"""%(prog)s - generate information from built-in brz help
20
20
 
21
 
%(prog)s creates a file with information on bzr in one of
 
21
%(prog)s creates a file with information on brz in one of
22
22
several different output formats:
23
23
 
24
24
    man              man page
38
38
 
39
39
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
40
40
 
41
 
from bzrlib import commands, doc_generate
 
41
import breezy
 
42
from breezy import (
 
43
    commands,
 
44
    # Don't remove the following import, it triggers a format registration that
 
45
    # avoid http://pad.lv/956860
 
46
    branch,
 
47
    doc_generate,
 
48
    )
 
49
 
42
50
 
43
51
def main(argv):
44
52
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
56
64
    parser.add_option("-o", "--output", dest="filename", metavar="FILE",
57
65
                      help="write output to FILE")
58
66
 
59
 
    parser.add_option("-b", "--bzr-name",
60
 
                      dest="bzr_name", default="bzr", metavar="EXEC_NAME",
61
 
                      help="name of bzr executable")
 
67
    parser.add_option("-b", "--brz-name",
 
68
                      dest="brz_name", default="brz", metavar="EXEC_NAME",
 
69
                      help="name of brz executable")
62
70
 
63
71
    parser.add_option("-e", "--examples",
64
72
                      action="callback", callback=print_extended_help,
71
79
        parser.print_help()
72
80
        sys.exit(1)
73
81
 
74
 
    commands.install_bzr_command_hooks()
75
 
 
76
 
    infogen_type = args[1]
77
 
    infogen_mod = doc_generate.get_module(infogen_type)
78
 
 
79
 
    if options.filename:
80
 
        outfilename = options.filename
81
 
    else:
82
 
        outfilename = infogen_mod.get_filename(options)
83
 
 
84
 
    if outfilename == "-":
85
 
        outfile = sys.stdout
86
 
    else:
87
 
        outfile = open(outfilename,"w")
88
 
 
89
 
    if options.show_filename and (outfilename != "-"):
90
 
        sys.stdout.write(outfilename)
91
 
        sys.stdout.write('\n')
92
 
    
93
 
    infogen_mod.infogen(options, outfile)
 
82
    with breezy.initialize():
 
83
        commands.install_bzr_command_hooks()
 
84
        infogen_type = args[1]
 
85
        infogen_mod = doc_generate.get_module(infogen_type)
 
86
        if options.filename:
 
87
            outfilename = options.filename
 
88
        else:
 
89
            outfilename = infogen_mod.get_filename(options)
 
90
        if outfilename == "-":
 
91
            outfile = sys.stdout
 
92
        else:
 
93
            outfile = open(outfilename,"w")
 
94
        if options.show_filename and (outfilename != "-"):
 
95
            sys.stdout.write(outfilename)
 
96
            sys.stdout.write('\n')
 
97
        infogen_mod.infogen(options, outfile)
 
98
 
94
99
 
95
100
def print_extended_help(option, opt, value, parser):
96
101
    """ Program help examples