/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: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

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 brz help
 
19
"""%(prog)s - generate information from built-in bzr help
20
20
 
21
 
%(prog)s creates a file with information on brz in one of
 
21
%(prog)s creates a file with information on bzr 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
 
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
 
 
 
41
from bzrlib import commands, doc_generate
50
42
 
51
43
def main(argv):
52
44
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
64
56
    parser.add_option("-o", "--output", dest="filename", metavar="FILE",
65
57
                      help="write output to FILE")
66
58
 
67
 
    parser.add_option("-b", "--brz-name",
68
 
                      dest="brz_name", default="brz", metavar="EXEC_NAME",
69
 
                      help="name of brz executable")
 
59
    parser.add_option("-b", "--bzr-name",
 
60
                      dest="bzr_name", default="bzr", metavar="EXEC_NAME",
 
61
                      help="name of bzr executable")
70
62
 
71
63
    parser.add_option("-e", "--examples",
72
64
                      action="callback", callback=print_extended_help,
79
71
        parser.print_help()
80
72
        sys.exit(1)
81
73
 
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
 
 
 
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)
99
94
 
100
95
def print_extended_help(option, opt, value, parser):
101
96
    """ Program help examples