~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrinfogen/big_man.py

Implement the bzr documentation/information autogeneration plan:
  * Add new module bzrinfogen.
  * Add bzrinfogen/__init__py which implements the infogen infrastructure.
  * Add bzrinfogen/big_bash_completion.py:
    Generates (unusable prototype) bash completion script from internal
    information on bzr commands and options
  * Moved bzr_man.py to bzrinfogen/big_man.py and ported it to the new
    interface.
Still missing:
  * test case for autogeneration
  * actual implementation of bash completion script

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
 
"""bzr_man.py - create man page from built-in bzr help and static text
20
 
 
21
 
Plan (devised by jblack and ndim 2005-12-10):
22
 
  * one bzr_gen_stuff.py script in top level dir right beside bzr
23
 
  * one gen_stuff_extras/ directory
24
 
  * several generator scripts like
25
 
          gen_stuff_extras/gen_man_page.py
26
 
                           gen_docbook_xml.py
27
 
                           gen_html.py
28
 
                           gen_bash_completion.py
29
 
                           gen_zsh_completion.py
30
 
  * scripts are called by running "bzr_gen_stuff.py --man-page" or
31
 
    "--bash-completion"
32
 
  * one test case which iterates through all gen_*.py scripts and
33
 
    tries to generate all the file types, checking that all generators
34
 
    work
35
 
  * those generator scripts walk through the command and option data
36
 
    structures to extract the required information
37
 
  * the actual names are just prototypes and subject to change
38
 
 
39
 
TODO (for man page):
 
19
"""big_man.py - create man page from built-in bzr help and static text
 
20
 
 
21
TODO:
 
22
  * use usage information instead of simple "bzr foo" in COMMAND OVERVIEW
40
23
  * add command aliases
41
24
"""
42
25
 
44
27
import bzrlib, bzrlib.help, bzrlib.commands
45
28
import textwrap
46
29
import time
47
 
import re
48
 
 
49
 
def main():
 
30
 
 
31
 
 
32
def get_filename(options):
 
33
    return "%s.1" % (options.bzr_name)
 
34
 
 
35
 
 
36
def infogen(options, outfile):
50
37
    t = time.time()
51
38
    tt = time.gmtime(t)
52
39
    params = \
53
 
           { "bzrcmd": "bzr",
 
40
           { "bzrcmd": options.bzr_name,
54
41
             "datestamp": time.strftime("%Y-%m-%d",tt),
55
42
             "timestamp": time.strftime("%Y-%m-%d %H:%M:%S +0000",tt),
56
43
             "version": bzrlib.__version__,
57
44
             }
58
45
 
59
 
    filename = "bzr.1"
60
 
    if len(sys.argv) == 2:
61
 
        filename = sys.argv[1]
62
 
    if filename == "-":
63
 
        outfile = sys.stdout
64
 
    else:
65
 
        outfile = open(filename,"w")
66
 
 
67
46
    outfile.write(man_preamble % params)
68
47
    outfile.write(man_escape(man_head % params))
69
48
 
261
240
  check_signatures=check-available
262
241
  create_signatures=when-required
263
242
 
 
243
.TP
 
244
.I "~/.bazaar/branches.conf"
 
245
Override settings for a specific branch in this file. The sections in this file are named after the locations of the branch, and the settings in that section look just like the ones in the
 
246
.B DEFAULT
 
247
section of the
 
248
.I "~/.bazaar/bazaar.conf"
 
249
file. Example:
 
250
 
 
251
  [/home/john/src/boofar.dev-john]
 
252
  email="John Doe <john@boofar.example.com>
 
253
 
 
254
  [http://erk.example.com/boo]
 
255
  check_signatures=always
 
256
 
264
257
.SH "SEE ALSO"
265
258
.UR http://www.bazaar-ng.org/
266
259
.BR http://www.bazaar-ng.org/,
281
274
.\\\" Generation time: %(timestamp)s
282
275
.\\\"
283
276
"""
284
 
 
285
 
 
286
 
if __name__ == '__main__':
287
 
    main()