~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/doc_generate/autodoc_man.py

  • Committer: Ian Clatworthy
  • Date: 2007-08-13 14:16:53 UTC
  • mto: (2733.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2734.
  • Revision ID: ian.clatworthy@internode.on.net-20070813141653-3cbrp00xowq58zv1
Added mini tutorial

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright 2005 Canonical Ltd.
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""man.py - create man page from built-in bzr help and static text
18
18
 
92
92
def getcommand_help(params):
93
93
    """Shows individual options for a bzr command"""
94
94
    output='.SH "COMMAND REFERENCE"\n'
95
 
    formatted = {}
96
95
    for cmd_name in command_name_list():
97
96
        cmd_object = bzrlib.commands.get_cmd_object(cmd_name)
98
97
        if cmd_object.hidden:
99
98
            continue
100
 
        formatted[cmd_name] = format_command(params, cmd_object)
101
 
        for alias in cmd_object.aliases:
102
 
            formatted[alias] = format_alias(params, alias, cmd_name)
103
 
    for cmd_name in sorted(formatted):
104
 
        output += formatted[cmd_name]
 
99
        output = output + format_command(params, cmd_object)
105
100
    return output
106
101
 
107
102
 
117
112
        option_str = "\nOptions:\n"
118
113
        for option_name, option in sorted(options.items()):
119
114
            for name, short_name, argname, help in option.iter_switches():
120
 
                if option.is_hidden(name):
121
 
                    continue
122
115
                l = '    --' + name
123
116
                if argname is not None:
124
117
                    l += ' ' + argname
125
118
                if short_name:
 
119
                    assert len(short_name) == 1
126
120
                    l += ', -' + short_name
127
121
                l += (30 - len(l)) * ' ' + (help or '')
128
122
                wrapped = textwrap.fill(l, initial_indent='',
129
 
                    subsequent_indent=30*' ',
130
 
                    break_long_words=False,
131
 
                    )
 
123
                                        subsequent_indent=30*' ')
132
124
                option_str = option_str + wrapped + '\n'       
133
125
 
134
126
    aliases_str = ""
150
142
    return subsection_header + option_str + aliases_str + see_also_str + "\n" + doc + "\n"
151
143
 
152
144
 
153
 
def format_alias(params, alias, cmd_name):
154
 
    help = '.SS "bzr %s"\n' % alias
155
 
    help += 'Alias for "%s", see "bzr %s".\n' % (cmd_name, cmd_name)
156
 
    return help
157
 
 
158
 
 
159
145
man_preamble = """\
160
 
.\\\"Man page for Bazaar (%(bzrcmd)s)
 
146
Man page for Bazaar (%(bzrcmd)s)
161
147
.\\\"
162
148
.\\\" Large parts of this file are autogenerated from the output of
163
149
.\\\"     \"%(bzrcmd)s help commands\"
171
157
man_head = """\
172
158
.TH bzr 1 "%(datestamp)s" "%(version)s" "Bazaar"
173
159
.SH "NAME"
174
 
%(bzrcmd)s - Bazaar next-generation distributed version control
 
160
Bazaar (%(bzrcmd)s) - next-generation distributed version control
175
161
.SH "SYNOPSIS"
176
162
.B "%(bzrcmd)s"
177
163
.I "command"
186
172
.B "help"
187
173
.I "command"
188
174
.SH "DESCRIPTION"
189
 
Bazaar (or %(bzrcmd)s) is a project of Canonical to develop an free
 
175
Bazaar (or %(bzrcmd)s) is a project of Canonical to develop an open source
190
176
distributed version control system that is powerful, friendly, and scalable.
191
177
Version control means a system that keeps track of previous revisions
192
178
of software source code or similar information and helps people work on it in teams.
241
227
.br
242
228
log10 = log --short -r -10..-1
243
229
.SH "SEE ALSO"
244
 
.UR http://bazaar.canonical.com/
245
 
.BR http://bazaar.canonical.com/
 
230
.UR http://www.bazaar-vcs.org/
 
231
.BR http://www.bazaar-vcs.org/
246
232
"""
247
233