~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_docs.py

  • Committer: Jelmer Vernooij
  • Date: 2012-06-29 08:19:21 UTC
  • mfrom: (0.40.147 trunk)
  • mto: This revision was merged to the branch mainline in revision 6555.
  • Revision ID: jelmer@samba.org-20120629081921-m3asg03n6z9fzcxn
Ship the grep plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 bzrlib
 
42
from bzrlib 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
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 bzrlib.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