/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1551.3.11 by Aaron Bentley
Merge from Robert
1
#!/usr/bin/python
2
3
# Copyright 2005 Canonical Ltd.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
4
#
1551.3.11 by Aaron Bentley
Merge from Robert
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
9
#
1551.3.11 by Aaron Bentley
Merge from Robert
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
14
#
1551.3.11 by Aaron Bentley
Merge from Robert
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
18
6622.1.16 by Jelmer Vernooij
s/bzr/brz/
19
"""%(prog)s - generate information from built-in brz help
1551.3.11 by Aaron Bentley
Merge from Robert
20
6622.1.16 by Jelmer Vernooij
s/bzr/brz/
21
%(prog)s creates a file with information on brz in one of
1551.3.11 by Aaron Bentley
Merge from Robert
22
several different output formats:
23
24
    man              man page
25
    bash_completion  bash completion script
26
    ...
27
28
Examples: 
29
6691.1.1 by Jelmer Vernooij
Avoid reference to python2.4.
30
    python generated-docs.py man
31
    python generated-docs.py bash_completion
1551.3.11 by Aaron Bentley
Merge from Robert
32
33
Run "%(prog)s --help" for the option reference.
34
"""
4526.11.2 by John Arbash Meinel
instead of updating PYTHONPATH in Makefile, update generate_docs to find bzrlib.
35
import os
1551.3.11 by Aaron Bentley
Merge from Robert
36
import sys
37
from optparse import OptionParser
38
4526.11.2 by John Arbash Meinel
instead of updating PYTHONPATH in Makefile, update generate_docs to find bzrlib.
39
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
40
6770.1.1 by Martin
Defer format registration in generate_docs script
41
import breezy
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
42
from breezy import (
6161.1.1 by Vincent Ladeuil
Allow config options to be overridden from the command line
43
    commands,
44
    doc_generate,
45
    )
46
1551.3.11 by Aaron Bentley
Merge from Robert
47
48
def main(argv):
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
49
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
50
51
Available OUTPUT_FORMAT:
52
53
    man              man page
54
    rstx             man page in ReStructuredText format
55
    bash_completion  bash completion script""")
1551.3.11 by Aaron Bentley
Merge from Robert
56
57
    parser.add_option("-s", "--show-filename",
58
                      action="store_true", dest="show_filename", default=False,
59
                      help="print default filename on stdout")
60
61
    parser.add_option("-o", "--output", dest="filename", metavar="FILE",
62
                      help="write output to FILE")
63
6622.1.16 by Jelmer Vernooij
s/bzr/brz/
64
    parser.add_option("-b", "--brz-name",
65
                      dest="brz_name", default="brz", metavar="EXEC_NAME",
66
                      help="name of brz executable")
1551.3.11 by Aaron Bentley
Merge from Robert
67
68
    parser.add_option("-e", "--examples",
69
                      action="callback", callback=print_extended_help,
70
                      help="Examples of ways to call generate_doc")
71
72
73
    (options, args) = parser.parse_args(argv)
74
75
    if len(args) != 2:
76
        parser.print_help()
77
        sys.exit(1)
4526.11.2 by John Arbash Meinel
instead of updating PYTHONPATH in Makefile, update generate_docs to find bzrlib.
78
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
79
    with breezy.initialize():
6770.1.1 by Martin
Defer format registration in generate_docs script
80
        # Import breezy.bzr for format registration, see <http://pad.lv/956860>
81
        from breezy import bzr as _
6161.1.1 by Vincent Ladeuil
Allow config options to be overridden from the command line
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
1551.3.11 by Aaron Bentley
Merge from Robert
98
99
def print_extended_help(option, opt, value, parser):
100
    """ Program help examples
101
102
    Prints out the examples stored in the docstring. 
103
104
    """
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
105
    sys.stdout.write(__doc__ % {"prog":sys.argv[0]})
106
    sys.stdout.write('\n')
1551.3.11 by Aaron Bentley
Merge from Robert
107
    sys.exit(0)
108
109
if __name__ == '__main__':
110
    main(sys.argv)