/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: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""man.py - create man page from built-in brz help and static text
 
17
"""man.py - create man page from built-in bzr help and static text
18
18
 
19
19
TODO:
20
 
  * use usage information instead of simple "brz foo" in COMMAND OVERVIEW
 
20
  * use usage information instead of simple "bzr foo" in COMMAND OVERVIEW
21
21
  * add command aliases
22
22
"""
23
23
 
26
26
PLUGINS_TO_DOCUMENT = ["launchpad"]
27
27
 
28
28
import textwrap
29
 
 
30
 
import breezy
31
 
import breezy.help
32
 
import breezy.help_topics
33
 
import breezy.commands
34
 
from breezy.doc_generate import get_autodoc_datetime
35
 
 
36
 
from breezy.plugin import load_plugins
 
29
import time
 
30
 
 
31
import bzrlib
 
32
import bzrlib.help
 
33
import bzrlib.help_topics
 
34
import bzrlib.commands
 
35
 
 
36
from bzrlib.plugin import load_plugins
37
37
load_plugins()
38
38
 
39
39
 
40
40
def get_filename(options):
41
41
    """Provides name of manpage"""
42
 
    return "%s.1" % (options.brz_name)
 
42
    return "%s.1" % (options.bzr_name)
43
43
 
44
44
 
45
45
def infogen(options, outfile):
46
46
    """Assembles a man page"""
47
 
    d = get_autodoc_datetime()
 
47
    t = time.time()
 
48
    tt = time.gmtime(t)
48
49
    params = \
49
 
           { "brzcmd": options.brz_name,
50
 
             "datestamp": d.strftime("%Y-%m-%d"),
51
 
             "timestamp": d.strftime("%Y-%m-%d %H:%M:%S +0000"),
52
 
             "version": breezy.__version__,
 
50
           { "bzrcmd": options.bzr_name,
 
51
             "datestamp": time.strftime("%Y-%m-%d",tt),
 
52
             "timestamp": time.strftime("%Y-%m-%d %H:%M:%S +0000",tt),
 
53
             "version": bzrlib.__version__,
53
54
             }
54
55
    outfile.write(man_preamble % params)
55
56
    outfile.write(man_escape(man_head % params))
61
62
 
62
63
def man_escape(string):
63
64
    """Escapes strings for man page compatibility"""
64
 
    result = string.replace("\\", "\\\\")
65
 
    result = result.replace("`", "\\'")
66
 
    result = result.replace("'", "\\*(Aq")
67
 
    result = result.replace("-", "\\-")
 
65
    result = string.replace("\\","\\\\")
 
66
    result = result.replace("`","\\'")
 
67
    result = result.replace("'","\\*(Aq")
 
68
    result = result.replace("-","\\-")
68
69
    return result
69
70
 
70
71
 
71
72
def command_name_list():
72
 
    """Builds a list of command names from breezy"""
73
 
    command_names = breezy.commands.builtin_command_names()
74
 
    for cmdname in breezy.commands.plugin_command_names():
75
 
        cmd_object = breezy.commands.get_cmd_object(cmdname)
 
73
    """Builds a list of command names from bzrlib"""
 
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)
76
77
        if (PLUGINS_TO_DOCUMENT is None or
77
78
            cmd_object.plugin_name() in PLUGINS_TO_DOCUMENT):
78
79
            command_names.append(cmdname)
82
83
 
83
84
def getcommand_list (params):
84
85
    """Builds summary help for command names in manpage format"""
85
 
    brzcmd = params["brzcmd"]
 
86
    bzrcmd = params["bzrcmd"]
86
87
    output = '.SH "COMMAND OVERVIEW"\n'
87
88
    for cmd_name in command_name_list():
88
 
        cmd_object = breezy.commands.get_cmd_object(cmd_name)
 
89
        cmd_object = bzrlib.commands.get_cmd_object(cmd_name)
89
90
        if cmd_object.hidden:
90
91
            continue
91
92
        cmd_help = cmd_object.help()
95
96
            tmp = '.TP\n.B "%s"\n%s\n' % (usage, firstline)
96
97
            output = output + tmp
97
98
        else:
98
 
            raise RuntimeError("Command '%s' has no help text" % (cmd_name))
 
99
            raise RuntimeError, "Command '%s' has no help text" % (cmd_name)
99
100
    return output
100
101
 
101
102
 
102
103
def getcommand_help(params):
103
 
    """Shows individual options for a brz command"""
 
104
    """Shows individual options for a bzr command"""
104
105
    output='.SH "COMMAND REFERENCE"\n'
105
106
    formatted = {}
106
107
    for cmd_name in command_name_list():
107
 
        cmd_object = breezy.commands.get_cmd_object(cmd_name)
 
108
        cmd_object = bzrlib.commands.get_cmd_object(cmd_name)
108
109
        if cmd_object.hidden:
109
110
            continue
110
111
        formatted[cmd_name] = format_command(params, cmd_object)
119
120
    """Provides long help for each public command"""
120
121
    subsection_header = '.SS "%s"\n' % (cmd._usage())
121
122
    doc = "%s\n" % (cmd.__doc__)
122
 
    doc = breezy.help_topics.help_as_plain_text(cmd.help())
 
123
    doc = bzrlib.help_topics.help_as_plain_text(cmd.help())
123
124
 
124
125
    # A dot at the beginning of a line is interpreted as a macro.
125
126
    # Simply join lines that begin with a dot with the previous
166
167
 
167
168
 
168
169
def format_alias(params, alias, cmd_name):
169
 
    help = '.SS "brz %s"\n' % alias
170
 
    help += 'Alias for "%s", see "brz %s".\n' % (cmd_name, cmd_name)
 
170
    help = '.SS "bzr %s"\n' % alias
 
171
    help += 'Alias for "%s", see "bzr %s".\n' % (cmd_name, cmd_name)
171
172
    return help
172
173
 
173
174
 
174
175
def environment_variables():
175
176
    yield ".SH \"ENVIRONMENT\"\n"
176
177
 
177
 
    from breezy.help_topics import known_env_variables
 
178
    from bzrlib.help_topics import known_env_variables
178
179
    for k, desc in known_env_variables:
179
180
        yield ".TP\n"
180
181
        yield ".I \"%s\"\n" % k
182
183
 
183
184
 
184
185
man_preamble = """\
185
 
.\\\"Man page for Breezy (%(brzcmd)s)
 
186
.\\\"Man page for Bazaar (%(bzrcmd)s)
186
187
.\\\"
187
188
.\\\" Large parts of this file are autogenerated from the output of
188
 
.\\\"     \"%(brzcmd)s help commands\"
189
 
.\\\"     \"%(brzcmd)s help <cmd>\"
 
189
.\\\"     \"%(bzrcmd)s help commands\"
 
190
.\\\"     \"%(bzrcmd)s help <cmd>\"
190
191
.\\\"
191
192
 
192
193
.ie \\n(.g .ds Aq \\(aq
195
196
 
196
197
 
197
198
man_head = """\
198
 
.TH brz 1 "%(datestamp)s" "%(version)s" "Breezy"
 
199
.TH bzr 1 "%(datestamp)s" "%(version)s" "Bazaar"
199
200
.SH "NAME"
200
 
%(brzcmd)s - Breezy next-generation distributed version control
 
201
%(bzrcmd)s - Bazaar next-generation distributed version control
201
202
.SH "SYNOPSIS"
202
 
.B "%(brzcmd)s"
 
203
.B "%(bzrcmd)s"
203
204
.I "command"
204
205
[
205
206
.I "command_options"
206
207
]
207
208
.br
208
 
.B "%(brzcmd)s"
 
209
.B "%(bzrcmd)s"
209
210
.B "help"
210
211
.br
211
 
.B "%(brzcmd)s"
 
212
.B "%(bzrcmd)s"
212
213
.B "help"
213
214
.I "command"
214
215
.SH "DESCRIPTION"
215
216
 
216
 
Breezy (or %(brzcmd)s) is a distributed version control system that is powerful,
217
 
friendly, and scalable.  Breezy is a fork of the Bazaar version control system.
 
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.
218
220
 
219
 
Breezy keeps track of changes to software source code (or similar information);
 
221
Bazaar keeps track of changes to software source code (or similar information);
220
222
lets you explore who changed it, when, and why; merges concurrent changes; and
221
223
helps people work together in a team.
222
224
"""
224
226
man_foot = """\
225
227
.SH "FILES"
226
228
.TP
227
 
.I "~/.config/breezy/breezy.conf"
 
229
.I "~/.bazaar/bazaar.conf"
228
230
Contains the user's default configuration. The section
229
231
.B [DEFAULT]
230
232
is used to define general configuration that will be applied everywhere.
246
248
.br
247
249
log10 = log --short -r -10..-1
248
250
.SH "SEE ALSO"
249
 
.UR https://www.breezy-vcs.org/
250
 
.BR https://www.breezy-vcs.org/
 
251
.UR http://bazaar.canonical.com/
 
252
.BR http://bazaar.canonical.com/
251
253
"""
252
254