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
|
|
|
1185.74.13
by James Blackwell
Final wrapup on doc generation |
18 |
"""%(prog)s - generate information from built-in bzr help
|
19 |
||
20 |
%(prog)s creates a file with information on bzr in one of
|
|
21 |
several different output formats:
|
|
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
22 |
|
23 |
man man page
|
|
24 |
bash_completion bash completion script
|
|
25 |
...
|
|
26 |
||
|
1185.74.13
by James Blackwell
Final wrapup on doc generation |
27 |
Examples:
|
28 |
||
29 |
python2.4 generated-docs.py man
|
|
30 |
python2.4 generated-docs.py bash_completion
|
|
31 |
||
32 |
Run "%(prog)s --help" for the option reference.
|
|
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
33 |
"""
|
34 |
||
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
35 |
# Plan (devised by jblack and ndim 2005-12-10):
|
|
1185.74.11
by James Blackwell
Updating plan |
36 |
# * one generate_doc.py script in top level dir right beside bzr
|
|
1185.74.13
by James Blackwell
Final wrapup on doc generation |
37 |
# * one tools/doc_generate/ directory (python module)
|
|
1185.74.11
by James Blackwell
Updating plan |
38 |
# We did not put the stuff into bzrlib because we thought
|
|
1185.75.7
by Hans Ulrich Niedermann
more bzr-infogen docs |
39 |
# that all this stuff doesn't need to get loaded every time you run bzr.
|
40 |
# However, I'm not sure that is actually true (ndim 2005-12-11).
|
|
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
41 |
# * several generator scripts like
|
|
1185.74.13
by James Blackwell
Final wrapup on doc generation |
42 |
# tools/doc_generate/autodoc_man_page.py
|
43 |
# autodoc_docbook_xml.py
|
|
44 |
# autodoc_html.py
|
|
45 |
# autodoc_bash_completion.py
|
|
46 |
# autodoc_zsh_completion.py
|
|
|
1185.75.7
by Hans Ulrich Niedermann
more bzr-infogen docs |
47 |
# * scripts are called by running something like
|
|
1185.74.11
by James Blackwell
Updating plan |
48 |
# "python2.4 generated_docs.py --man-page" or
|
49 |
# "python2.4 generated_docs.py --bash-completion" or
|
|
50 |
# "pytohn2.4 generated_docs.py --all"
|
|
51 |
#
|
|
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
52 |
# * one test case which iterates through all gen_*.py scripts and
|
53 |
# tries to generate all the file types, checking that all generators
|
|
|
1185.75.7
by Hans Ulrich Niedermann
more bzr-infogen docs |
54 |
# work (we'll let bzrinfogen/__init__.py provide the list to walk through)
|
|
1185.75.5
by Hans Ulrich Niedermann
bzr-infogen.py cosmetics |
55 |
# * those generator scripts walk through the command and option data
|
56 |
# structures to extract the required information
|
|
57 |
# * the actual names are just prototypes and subject to change
|
|
58 |
||
59 |
||
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
60 |
import sys |
|
1185.74.13
by James Blackwell
Final wrapup on doc generation |
61 |
import tools.doc_generate |
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
62 |
|
63 |
def main(argv): |
|
64 |
from optparse import OptionParser |
|
65 |
parser = OptionParser(usage="%prog [options] OUTPUT_FORMAT") |
|
|
1185.74.12
by James Blackwell
Better help for doc_generate |
66 |
|
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
67 |
parser.add_option("-s", "--show-filename", |
68 |
action="store_true", dest="show_filename", default=False, |
|
69 |
help="print default filename on stdout") |
|
|
1185.74.12
by James Blackwell
Better help for doc_generate |
70 |
|
71 |
parser.add_option("-o", "--output", dest="filename", metavar="FILE", |
|
72 |
help="write output to FILE") |
|
73 |
||
74 |
parser.add_option("-b", "--bzr-name", |
|
75 |
dest="bzr_name", default="bzr", metavar="EXEC_NAME", |
|
76 |
help="name of bzr executable") |
|
77 |
||
78 |
parser.add_option("-e", "--examples", |
|
79 |
action="callback", callback=print_extended_help, |
|
80 |
help="Examples of ways to call generate_doc") |
|
81 |
||
82 |
||
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
83 |
(options, args) = parser.parse_args(argv) |
84 |
||
85 |
if len(args) != 2: |
|
|
1185.74.12
by James Blackwell
Better help for doc_generate |
86 |
parser.print_help() |
87 |
sys.exit(1) |
|
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
88 |
|
89 |
infogen_type = args[1] |
|
|
1185.74.13
by James Blackwell
Final wrapup on doc generation |
90 |
infogen_mod = tools.doc_generate.get_module(infogen_type) |
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
91 |
|
92 |
if options.filename: |
|
93 |
outfilename = options.filename |
|
94 |
else: |
|
95 |
outfilename = infogen_mod.get_filename(options) |
|
96 |
||
97 |
if outfilename == "-": |
|
98 |
outfile = sys.stdout |
|
99 |
else: |
|
100 |
outfile = open(outfilename,"w") |
|
101 |
||
102 |
if options.show_filename and (outfilename != "-"): |
|
103 |
print >>sys.stdout, outfilename |
|
104 |
||
105 |
infogen_mod.infogen(options, outfile) |
|
106 |
||
|
1185.74.12
by James Blackwell
Better help for doc_generate |
107 |
def print_extended_help(option, opt, value, parser): |
|
1185.74.13
by James Blackwell
Final wrapup on doc generation |
108 |
print >>sys.stdout, __doc__ % {"prog":sys.argv[0]} |
109 |
sys.exit(0) |
|
|
1185.75.4
by Hans Ulrich Niedermann
Implement the bzr documentation/information autogeneration plan: |
110 |
|
111 |
if __name__ == '__main__': |
|
112 |
main(sys.argv) |