~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to generate_docs.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-03-28 06:58:22 UTC
  • mfrom: (2379.2.3 hpss-chroot)
  • Revision ID: pqm@pqm.ubuntu.com-20070328065822-999550a858a3ced3
(robertc) Fix chroot urls to not expose the url of the transport they are protecting, allowing regular url operations to work on them. (Robert Collins, Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
19
"""%(prog)s - generate information from built-in bzr help
20
20
 
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 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
 
 
 
39
import tools.doc_generate
50
40
 
51
41
def main(argv):
52
42
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
79
69
        parser.print_help()
80
70
        sys.exit(1)
81
71
 
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
 
 
 
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
        print >>sys.stdout, outfilename
 
87
    
 
88
    infogen_mod.infogen(options, outfile)
99
89
 
100
90
def print_extended_help(option, opt, value, parser):
101
91
    """ Program help examples
103
93
    Prints out the examples stored in the docstring. 
104
94
 
105
95
    """
106
 
    sys.stdout.write(__doc__ % {"prog":sys.argv[0]})
107
 
    sys.stdout.write('\n')
 
96
    print >>sys.stdout, __doc__ % {"prog":sys.argv[0]}
108
97
    sys.exit(0)
109
98
 
110
99
if __name__ == '__main__':