~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_docs.py

  • Committer: Jelmer Vernooij
  • Date: 2012-08-28 20:49:22 UTC
  • mto: This revision was merged to the branch mainline in revision 6556.
  • Revision ID: jelmer@samba.org-20120828204922-o8ok2komaeab6o2v
Inline traceback specification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
Run "%(prog)s --help" for the option reference.
34
34
"""
35
 
 
36
 
import bzrlib.commands
 
35
import os
37
36
import sys
38
37
from optparse import OptionParser
39
38
 
40
 
import tools.doc_generate
 
39
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
 
40
 
 
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
 
41
50
 
42
51
def main(argv):
43
52
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
69
78
    if len(args) != 2:
70
79
        parser.print_help()
71
80
        sys.exit(1)
72
 
    
73
 
    bzrlib.commands.install_bzr_command_hooks()
74
 
 
75
 
    infogen_type = args[1]
76
 
    infogen_mod = tools.doc_generate.get_module(infogen_type)
77
 
 
78
 
    if options.filename:
79
 
        outfilename = options.filename
80
 
    else:
81
 
        outfilename = infogen_mod.get_filename(options)
82
 
 
83
 
    if outfilename == "-":
84
 
        outfile = sys.stdout
85
 
    else:
86
 
        outfile = open(outfilename,"w")
87
 
 
88
 
    if options.show_filename and (outfilename != "-"):
89
 
        sys.stdout.write(outfilename)
90
 
        sys.stdout.write('\n')
91
 
    
92
 
    infogen_mod.infogen(options, outfile)
 
81
 
 
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
 
93
99
 
94
100
def print_extended_help(option, opt, value, parser):
95
101
    """ Program help examples