~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/doc_generate/autodoc_man.py

(vila) Fix bzrlib.tests.test_gpg.TestVerify.test_verify_revoked_signature
 with recent versions of gpg. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
  * add command aliases
22
22
"""
23
23
 
24
 
import os
25
 
import sys
 
24
from __future__ import absolute_import
 
25
 
 
26
PLUGINS_TO_DOCUMENT = ["launchpad"]
 
27
 
26
28
import textwrap
27
29
import time
28
30
 
31
33
import bzrlib.help_topics
32
34
import bzrlib.commands
33
35
 
 
36
from bzrlib.plugin import load_plugins
 
37
load_plugins()
 
38
 
34
39
 
35
40
def get_filename(options):
36
41
    """Provides name of manpage"""
51
56
    outfile.write(man_escape(man_head % params))
52
57
    outfile.write(man_escape(getcommand_list(params)))
53
58
    outfile.write(man_escape(getcommand_help(params)))
 
59
    outfile.write("".join(environment_variables()))
54
60
    outfile.write(man_escape(man_foot % params))
55
61
 
56
62
 
57
63
def man_escape(string):
58
64
    """Escapes strings for man page compatibility"""
59
65
    result = string.replace("\\","\\\\")
60
 
    result = result.replace("`","\\`")
61
 
    result = result.replace("'","\\'")
 
66
    result = result.replace("`","\\'")
 
67
    result = result.replace("'","\\*(Aq")
62
68
    result = result.replace("-","\\-")
63
69
    return result
64
70
 
66
72
def command_name_list():
67
73
    """Builds a list of command names from bzrlib"""
68
74
    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)
69
80
    command_names.sort()
70
81
    return command_names
71
82
 
105
116
    return output
106
117
 
107
118
 
108
 
def format_command (params, cmd):
 
119
def format_command(params, cmd):
109
120
    """Provides long help for each public command"""
110
121
    subsection_header = '.SS "%s"\n' % (cmd._usage())
111
122
    doc = "%s\n" % (cmd.__doc__)
112
123
    doc = bzrlib.help_topics.help_as_plain_text(cmd.help())
113
124
 
 
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
 
114
130
    option_str = ""
115
131
    options = cmd.options()
116
132
    if options:
129
145
                    subsequent_indent=30*' ',
130
146
                    break_long_words=False,
131
147
                    )
132
 
                option_str = option_str + wrapped + '\n'       
 
148
                option_str += wrapped + '\n'
133
149
 
134
150
    aliases_str = ""
135
151
    if cmd.aliases:
156
172
    return help
157
173
 
158
174
 
 
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
 
159
185
man_preamble = """\
160
186
.\\\"Man page for Bazaar (%(bzrcmd)s)
161
187
.\\\"
163
189
.\\\"     \"%(bzrcmd)s help commands\"
164
190
.\\\"     \"%(bzrcmd)s help <cmd>\"
165
191
.\\\"
166
 
.\\\" Generation time: %(timestamp)s
167
 
.\\\"
 
192
 
 
193
.ie \\n(.g .ds Aq \\(aq
 
194
.el .ds Aq '
168
195
"""
169
196
 
170
197
 
186
213
.B "help"
187
214
.I "command"
188
215
.SH "DESCRIPTION"
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.
 
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.
193
224
"""
194
225
 
195
226
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
220
227
.SH "FILES"
221
228
.TP
222
229
.I "~/.bazaar/bazaar.conf"