~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_docs.py

  • Committer: Vincent Ladeuil
  • Date: 2010-10-26 08:08:23 UTC
  • mfrom: (5514.1.1 665100-content-type)
  • mto: This revision was merged to the branch mainline in revision 5516.
  • Revision ID: v.ladeuil+lp@free.fr-20101026080823-3wggo03b7cpn9908
Correctly set the Content-Type header when POSTing http requests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
3
3
# Copyright 2005 Canonical Ltd.
4
 
 
 
4
#
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
7
7
# the Free Software Foundation; either version 2 of the License, or
8
8
# (at your option) any later version.
9
 
 
 
9
#
10
10
# This program is distributed in the hope that it will be useful,
11
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
# GNU General Public License for more details.
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
18
 
18
19
"""%(prog)s - generate information from built-in bzr help
19
20
 
20
21
%(prog)s creates a file with information on bzr in one of
31
32
 
32
33
Run "%(prog)s --help" for the option reference.
33
34
"""
34
 
 
 
35
import os
35
36
import sys
36
37
from optparse import OptionParser
37
38
 
38
 
import tools.doc_generate
 
39
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
 
40
 
 
41
from bzrlib import commands, doc_generate
39
42
 
40
43
def main(argv):
41
 
    parser = OptionParser(usage="%prog [options] OUTPUT_FORMAT")
 
44
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
 
45
 
 
46
Available OUTPUT_FORMAT:
 
47
 
 
48
    man              man page
 
49
    rstx             man page in ReStructuredText format
 
50
    bash_completion  bash completion script""")
42
51
 
43
52
    parser.add_option("-s", "--show-filename",
44
53
                      action="store_true", dest="show_filename", default=False,
62
71
        parser.print_help()
63
72
        sys.exit(1)
64
73
 
 
74
    commands.install_bzr_command_hooks()
 
75
 
65
76
    infogen_type = args[1]
66
 
    infogen_mod = tools.doc_generate.get_module(infogen_type)
 
77
    infogen_mod = doc_generate.get_module(infogen_type)
67
78
 
68
79
    if options.filename:
69
80
        outfilename = options.filename
76
87
        outfile = open(outfilename,"w")
77
88
 
78
89
    if options.show_filename and (outfilename != "-"):
79
 
        print >>sys.stdout, outfilename
 
90
        sys.stdout.write(outfilename)
 
91
        sys.stdout.write('\n')
80
92
    
81
93
    infogen_mod.infogen(options, outfile)
82
94
 
86
98
    Prints out the examples stored in the docstring. 
87
99
 
88
100
    """
89
 
    print >>sys.stdout, __doc__ % {"prog":sys.argv[0]}
 
101
    sys.stdout.write(__doc__ % {"prog":sys.argv[0]})
 
102
    sys.stdout.write('\n')
90
103
    sys.exit(0)
91
104
 
92
105
if __name__ == '__main__':