/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/doc_generate/autodoc_man.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from __future__ import absolute_import
25
25
 
26
 
PLUGINS_TO_DOCUMENT = ["launchpad"]
27
 
 
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
 
224
197
"""
225
198
 
226
199
man_foot = """\
 
200
.SH "ENVIRONMENT"
 
201
.TP
 
202
.I "BZRPATH"
 
203
Path where
 
204
.B "%(bzrcmd)s"
 
205
is to look for shell plugin external commands.
 
206
.TP
 
207
.I "BZR_EMAIL"
 
208
E-Mail address of the user. Overrides default user config.
 
209
.TP
 
210
.I "EMAIL"
 
211
E-Mail address of the user. Overrides default user config.
 
212
.TP
 
213
.I "BZR_EDITOR"
 
214
Editor for editing commit messages
 
215
.TP
 
216
.I "EDITOR"
 
217
Editor for editing commit messages
 
218
.TP
 
219
.I "BZR_PLUGIN_PATH"
 
220
Paths where bzr should look for plugins
 
221
.TP
 
222
.I "BZR_HOME"
 
223
Home directory for bzr
227
224
.SH "FILES"
228
225
.TP
229
226
.I "~/.bazaar/bazaar.conf"