~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/doc_generate/autodoc_man.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
  * add command aliases
22
22
"""
23
23
 
24
 
from __future__ import absolute_import
25
 
 
26
 
PLUGINS_TO_DOCUMENT = ["launchpad"]
27
 
 
 
24
import os
 
25
import sys
28
26
import textwrap
29
27
import time
30
28
 
33
31
import bzrlib.help_topics
34
32
import bzrlib.commands
35
33
 
36
 
from bzrlib.plugin import load_plugins
37
 
load_plugins()
38
 
 
39
34
 
40
35
def get_filename(options):
41
36
    """Provides name of manpage"""
56
51
    outfile.write(man_escape(man_head % params))
57
52
    outfile.write(man_escape(getcommand_list(params)))
58
53
    outfile.write(man_escape(getcommand_help(params)))
59
 
    outfile.write("".join(environment_variables()))
60
54
    outfile.write(man_escape(man_foot % params))
61
55
 
62
56
 
63
57
def man_escape(string):
64
58
    """Escapes strings for man page compatibility"""
65
59
    result = string.replace("\\","\\\\")
66
 
    result = result.replace("`","\\'")
67
 
    result = result.replace("'","\\*(Aq")
 
60
    result = result.replace("`","\\`")
 
61
    result = result.replace("'","\\'")
68
62
    result = result.replace("-","\\-")
69
63
    return result
70
64
 
72
66
def command_name_list():
73
67
    """Builds a list of command names from bzrlib"""
74
68
    command_names = bzrlib.commands.builtin_command_names()
75
 
    for cmdname in bzrlib.commands.plugin_command_names():
76
 
        cmd_object = bzrlib.commands.get_cmd_object(cmdname)
77
 
        if (PLUGINS_TO_DOCUMENT is None or
78
 
            cmd_object.plugin_name() in PLUGINS_TO_DOCUMENT):
79
 
            command_names.append(cmdname)
80
69
    command_names.sort()
81
70
    return command_names
82
71
 
116
105
    return output
117
106
 
118
107
 
119
 
def format_command(params, cmd):
 
108
def format_command (params, cmd):
120
109
    """Provides long help for each public command"""
121
110
    subsection_header = '.SS "%s"\n' % (cmd._usage())
122
111
    doc = "%s\n" % (cmd.__doc__)
123
112
    doc = bzrlib.help_topics.help_as_plain_text(cmd.help())
124
113
 
125
 
    # A dot at the beginning of a line is interpreted as a macro.
126
 
    # Simply join lines that begin with a dot with the previous
127
 
    # line to work around this.
128
 
    doc = doc.replace("\n.", ".")
129
 
 
130
114
    option_str = ""
131
115
    options = cmd.options()
132
116
    if options:
145
129
                    subsequent_indent=30*' ',
146
130
                    break_long_words=False,
147
131
                    )
148
 
                option_str += wrapped + '\n'
 
132
                option_str = option_str + wrapped + '\n'       
149
133
 
150
134
    aliases_str = ""
151
135
    if cmd.aliases:
172
156
    return help
173
157
 
174
158
 
175
 
def environment_variables():
176
 
    yield ".SH \"ENVIRONMENT\"\n"
177
 
 
178
 
    from bzrlib.help_topics import known_env_variables
179
 
    for k, desc in known_env_variables:
180
 
        yield ".TP\n"
181
 
        yield ".I \"%s\"\n" % k
182
 
        yield man_escape(desc) + "\n"
183
 
 
184
 
 
185
159
man_preamble = """\
186
160
.\\\"Man page for Bazaar (%(bzrcmd)s)
187
161
.\\\"
189
163
.\\\"     \"%(bzrcmd)s help commands\"
190
164
.\\\"     \"%(bzrcmd)s help <cmd>\"
191
165
.\\\"
192
 
 
193
 
.ie \\n(.g .ds Aq \\(aq
194
 
.el .ds Aq '
 
166
.\\\" Generation time: %(timestamp)s
 
167
.\\\"
195
168
"""
196
169
 
197
170
 
213
186
.B "help"
214
187
.I "command"
215
188
.SH "DESCRIPTION"
216
 
 
217
 
Bazaar (or %(bzrcmd)s) is a distributed version control system that is powerful, 
218
 
friendly, and scalable.  Bazaar is a project of Canonical Ltd and part of 
219
 
the GNU Project to develop a free operating system.
220
 
 
221
 
Bazaar keeps track of changes to software source code (or similar information);
222
 
lets you explore who changed it, when, and why; merges concurrent changes; and
223
 
helps people work together in a team.
 
189
Bazaar (or %(bzrcmd)s) is a project of Canonical to develop an free
 
190
distributed version control system that is powerful, friendly, and scalable.
 
191
Version control means a system that keeps track of previous revisions
 
192
of software source code or similar information and helps people work on it in teams.
224
193
"""
225
194
 
226
195
man_foot = """\
 
196
.SH "ENVIRONMENT"
 
197
.TP
 
198
.I "BZRPATH"
 
199
Path where
 
200
.B "%(bzrcmd)s"
 
201
is to look for shell plugin external commands.
 
202
.TP
 
203
.I "BZR_EMAIL"
 
204
E-Mail address of the user. Overrides default user config.
 
205
.TP
 
206
.I "EMAIL"
 
207
E-Mail address of the user. Overrides default user config.
 
208
.TP
 
209
.I "BZR_EDITOR"
 
210
Editor for editing commit messages
 
211
.TP
 
212
.I "EDITOR"
 
213
Editor for editing commit messages
 
214
.TP
 
215
.I "BZR_PLUGIN_PATH"
 
216
Paths where bzr should look for plugins
 
217
.TP
 
218
.I "BZR_HOME"
 
219
Home directory for bzr
227
220
.SH "FILES"
228
221
.TP
229
222
.I "~/.bazaar/bazaar.conf"