bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
1 |
#!/usr/bin/python
|
2 |
||
3 |
# Copyright 2005 Canonical Ltd.
|
|
4 |
||
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.
|
|
9 |
||
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.
|
|
14 |
||
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
|
|
17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
||
19 |
"""bzr-infogen.py - generate information from built-in bzr help
|
|
20 |
||
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
21 |
bzr-infogen.py creates a file with information on bzr in one of
|
22 |
several different output formats:
|
|
23 |
||
24 |
man man page
|
|
25 |
bash_completion bash completion script
|
|
26 |
...
|
|
27 |
||
28 |
Run "bzr-infogen.py --help" for usage information.
|
|
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
29 |
"""
|
30 |
||
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
31 |
# Plan (devised by jblack and ndim 2005-12-10):
|
|
1185.75.7
by Hans Ulrich Niedermann
more bzr-infogen docs |
32 |
# * one bzr-infogen.py script in top level dir right beside bzr
|
33 |
# * one bzrinfogen/ directory (python module)
|
|
34 |
# We did not put the stuff into bzrlib/infogen/ because we thought
|
|
35 |
# that all this stuff doesn't need to get loaded every time you run bzr.
|
|
36 |
# However, I'm not sure that is actually true (ndim 2005-12-11).
|
|
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
37 |
# * several generator scripts like
|
38 |
# bzrinfogen/gen_man_page.py
|
|
39 |
# gen_docbook_xml.py
|
|
|
1185.75.7
by Hans Ulrich Niedermann
more bzr-infogen docs |
40 |
# gen_html.py
|
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
41 |
# gen_bash_completion.py
|
42 |
# gen_zsh_completion.py
|
|
|
1185.75.7
by Hans Ulrich Niedermann
more bzr-infogen docs |
43 |
# * scripts are called by running something like
|
44 |
# "bzr-infogen.py --man-page" or "bzr-infogen.py --bash-completion"
|
|
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
45 |
# * one test case which iterates through all gen_*.py scripts and
|
46 |
# tries to generate all the file types, checking that all generators
|
|
|
1185.75.7
by Hans Ulrich Niedermann
more bzr-infogen docs |
47 |
# work (we'll let bzrinfogen/__init__.py provide the list to walk through)
|
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
48 |
# * those generator scripts walk through the command and option data
|
49 |
# structures to extract the required information
|
|
50 |
# * the actual names are just prototypes and subject to change
|
|
51 |
||
52 |
||
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
53 |
import sys |
|
1185.74.8
by James Blackwell
Hacked up ndim's code |
54 |
import doc_generate |
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
55 |
|
56 |
||
57 |
def main(argv): |
|
58 |
from optparse import OptionParser |
|
59 |
parser = OptionParser(usage="%prog [options] OUTPUT_FORMAT") |
|
60 |
parser.add_option("-s", "--show-filename", |
|
61 |
action="store_true", dest="show_filename", default=False, |
|
62 |
help="print default filename on stdout") |
|
|
1185.75.6
by Hans Ulrich Niedermann
rename bzr-infogen.py option -f to more standard-like -o |
63 |
parser.add_option("-o", "--output", dest="filename", |
64 |
help="write output to FILE", metavar="FILE") |
|
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
65 |
parser.add_option("-b", "--bzr-name", dest="bzr_name", default="bzr", |
66 |
help="name of bzr executable", metavar="EXEC_NAME") |
|
67 |
parser.add_option("-q", "--quiet", |
|
68 |
action="store_false", dest="verbose", default=True, |
|
69 |
help="don't print status messages to stdout") |
|
70 |
(options, args) = parser.parse_args(argv) |
|
71 |
||
72 |
if len(args) != 2: |
|
73 |
parser.error("incorrect number of arguments") |
|
74 |
||
75 |
infogen_type = args[1] |
|
|
1185.74.10
by James Blackwell
Fixing up autodoc |
76 |
infogen_mod = doc_generate.generate(infogen_type) |
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
77 |
|
78 |
if options.filename: |
|
79 |
outfilename = options.filename |
|
80 |
else: |
|
81 |
outfilename = infogen_mod.get_filename(options) |
|
82 |
||
83 |
if outfilename == "-": |
|
84 |
outfile = sys.stdout |
|
85 |
else: |
|
86 |
outfile = open(outfilename,"w") |
|
87 |
||
88 |
if options.show_filename and (outfilename != "-"): |
|
89 |
print >>sys.stdout, outfilename |
|
90 |
||
91 |
infogen_mod.infogen(options, outfile) |
|
92 |
||
93 |
||
94 |
if __name__ == '__main__': |
|
95 |
main(sys.argv) |