/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 generate_docs.py

  • Committer: Sabin Iacob
  • Date: 2009-03-23 14:59:43 UTC
  • mto: (4189.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4193.
  • Revision ID: iacobs@m0n5t3r.info-20090323145943-3s3p1px5q1rkh2e5
update FSF mailing address

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3
 
1
#!/usr/bin/python
2
2
 
3
3
# Copyright 2005 Canonical Ltd.
4
4
#
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
25
25
    bash_completion  bash completion script
26
26
    ...
27
27
 
28
 
Examples:
 
28
Examples: 
29
29
 
30
 
    python generated-docs.py man
31
 
    python generated-docs.py bash_completion
 
30
    python2.4 generated-docs.py man
 
31
    python2.4 generated-docs.py bash_completion
32
32
 
33
33
Run "%(prog)s --help" for the option reference.
34
34
"""
35
 
import os
 
35
 
36
36
import sys
37
37
from optparse import OptionParser
38
38
 
39
 
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
40
 
 
41
 
import breezy
42
 
from breezy import (
43
 
    commands,
44
 
    doc_generate,
45
 
    )
46
 
 
 
39
import tools.doc_generate
47
40
 
48
41
def main(argv):
49
42
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
61
54
    parser.add_option("-o", "--output", dest="filename", metavar="FILE",
62
55
                      help="write output to FILE")
63
56
 
64
 
    parser.add_option("-b", "--brz-name",
65
 
                      dest="brz_name", default="brz", metavar="EXEC_NAME",
66
 
                      help="name of brz executable")
 
57
    parser.add_option("-b", "--bzr-name",
 
58
                      dest="bzr_name", default="bzr", metavar="EXEC_NAME",
 
59
                      help="name of bzr executable")
67
60
 
68
61
    parser.add_option("-e", "--examples",
69
62
                      action="callback", callback=print_extended_help,
76
69
        parser.print_help()
77
70
        sys.exit(1)
78
71
 
79
 
    with breezy.initialize():
80
 
        # Import breezy.bzr for format registration, see <http://pad.lv/956860>
81
 
        from breezy import bzr as _
82
 
        commands.install_bzr_command_hooks()
83
 
        infogen_type = args[1]
84
 
        infogen_mod = doc_generate.get_module(infogen_type)
85
 
        if options.filename:
86
 
            outfilename = options.filename
87
 
        else:
88
 
            outfilename = infogen_mod.get_filename(options)
89
 
        if outfilename == "-":
90
 
            outfile = sys.stdout
91
 
        else:
92
 
            outfile = open(outfilename, "w")
93
 
        if options.show_filename and (outfilename != "-"):
94
 
            sys.stdout.write(outfilename)
95
 
            sys.stdout.write('\n')
96
 
        infogen_mod.infogen(options, outfile)
97
 
 
 
72
    infogen_type = args[1]
 
73
    infogen_mod = tools.doc_generate.get_module(infogen_type)
 
74
 
 
75
    if options.filename:
 
76
        outfilename = options.filename
 
77
    else:
 
78
        outfilename = infogen_mod.get_filename(options)
 
79
 
 
80
    if outfilename == "-":
 
81
        outfile = sys.stdout
 
82
    else:
 
83
        outfile = open(outfilename,"w")
 
84
 
 
85
    if options.show_filename and (outfilename != "-"):
 
86
        sys.stdout.write(outfilename)
 
87
        sys.stdout.write('\n')
 
88
    
 
89
    infogen_mod.infogen(options, outfile)
98
90
 
99
91
def print_extended_help(option, opt, value, parser):
100
92
    """ Program help examples
101
93
 
102
 
    Prints out the examples stored in the docstring.
 
94
    Prints out the examples stored in the docstring. 
103
95
 
104
96
    """
105
 
    sys.stdout.write(__doc__ % {"prog": sys.argv[0]})
 
97
    sys.stdout.write(__doc__ % {"prog":sys.argv[0]})
106
98
    sys.stdout.write('\n')
107
99
    sys.exit(0)
108
100