19
19
Help topics are meant to be help for items that aren't commands, but will
20
20
help bzr become fully learnable without referring to a tutorial.
22
Limited formatting of help text is permitted to make the text useful
23
both within the reference manual (reStructuredText) and on the screen.
24
The help text should be reStructuredText with formatting kept to a
25
minimum and, in particular, no headings. The onscreen renderer applies
26
the following simple rules before rendering the text:
28
1. A '::' appearing on the end of a line is replaced with ':'.
29
2. Lines starting with a ':' have it stripped.
31
These rules mean that literal blocks and field lists respectively can
32
be used in the help text, producing sensible input to a manual while
33
rendering on the screen naturally.
36
23
from bzrlib import registry
39
# Section identifiers (map topics to the right place in the manual)
40
SECT_COMMAND = "command"
41
SECT_CONCEPT = "concept"
42
SECT_HIDDEN = "hidden"
44
SECT_PLUGIN = "plugin"
47
26
class HelpTopicRegistry(registry.Registry):
48
27
"""A Registry customized for handling help topics."""
50
def register(self, topic, detail, summary, section=SECT_LIST):
29
def register(self, topic, detail, summary):
51
30
"""Register a new help topic.
53
32
:param topic: Name of documentation entry
54
33
:param detail: Function or string object providing detailed
55
34
documentation for topic. Function interface is detail(topic).
56
35
This should return a text string of the detailed information.
57
See the module documentation for details on help text formatting.
58
36
:param summary: String providing single-line documentation for topic.
59
:param section: Section in reference manual - see SECT_* identifiers.
61
# The detail is stored as the 'object' and the metadata as the info
62
info=(summary,section)
63
super(HelpTopicRegistry, self).register(topic, detail, info=info)
38
# The detail is stored as the 'object' and the
39
super(HelpTopicRegistry, self).register(topic, detail, info=summary)
65
def register_lazy(self, topic, module_name, member_name, summary,
41
def register_lazy(self, topic, module_name, member_name, summary):
67
42
"""Register a new help topic, and import the details on demand.
69
44
:param topic: Name of documentation entry
70
45
:param module_name: The module to find the detailed help.
71
46
:param member_name: The member of the module to use for detailed help.
72
47
:param summary: String providing single-line documentation for topic.
73
:param section: Section in reference manual - see SECT_* identifiers.
75
# The detail is stored as the 'object' and the metadata as the info
76
info=(summary,section)
77
49
super(HelpTopicRegistry, self).register_lazy(topic, module_name,
78
member_name, info=info)
50
member_name, info=summary)
80
52
def get_detail(self, topic):
81
53
"""Get the detailed help on a given topic."""
88
60
def get_summary(self, topic):
89
61
"""Get the single line summary for the topic."""
90
info = self.get_info(topic)
96
def get_section(self, topic):
97
"""Get the section for the topic."""
98
info = self.get_info(topic)
104
def get_topics_for_section(self, section):
105
"""Get the set of topics in a section."""
107
for topic in self.keys():
108
if section == self.get_section(topic):
62
return self.get_info(topic)
113
65
topic_registry = HelpTopicRegistry()
131
83
def _help_on_revisionspec(name):
132
"""Generate the help for revision specs."""
84
"""Write the summary help for all documented topics to outfile."""
134
85
import bzrlib.revisionspec
137
out.append("Revision Identifiers\n")
138
out.append("A revision, or a range bound, can be one of the following.\n")
140
details.append("\nFurther details are given below.\n")
88
out.append("\nRevision prefix specifier:"
89
"\n--------------------------\n")
142
# The help text is indented 4 spaces - this re cleans that up below
143
indent_re = re.compile(r'^ ', re.MULTILINE)
144
91
for i in bzrlib.revisionspec.SPEC_TYPES:
146
93
if doc == bzrlib.revisionspec.RevisionSpec.help_txt:
150
# Extract out the top line summary from the body and
151
# clean-up the unwanted whitespace
152
summary,doc = doc.split("\n", 1)
153
#doc = indent_re.sub('', doc)
154
while (doc[-2:] == '\n\n' or doc[-1:] == ' '):
157
# Note: The leading : here are HACKs to get reStructuredText
158
# 'field' formatting - we know that the prefix ends in a ':'.
159
out.append(":%s\n\t%s" % (i.prefix, summary))
160
details.append(":%s\n%s" % (i.prefix, doc))
162
return '\n'.join(out + details)
95
while (doc[-2:] == '\n\n' or doc[-1:] == ' '):
98
out.append(" %s %s\n\n" % (i.prefix, doc))
165
103
def _help_on_transport(name):
193
132
if not shorthelp:
195
134
if proto.endswith("://"):
196
protl.append(add_string(proto, shorthelp, 79))
135
protl.extend(add_string(proto, shorthelp, 79))
198
decl.append(add_string(proto, shorthelp, 79))
201
out = "URL Identifiers\n\n" + \
202
"Supported URL prefixes::\n\n " + \
137
decl.extend(add_string(proto, shorthelp, 79))
140
out = "\nSupported URL prefix\n--------------------\n" + \
206
out += "\nSupported modifiers::\n\n " + \
144
out += "\nSupported modifiers\n-------------------\n" + \
213
151
"""Bazaar -- a free distributed version-control tool
214
152
http://bazaar-vcs.org/
240
178
"""Global Options
242
180
These options may be used with any command, and may appear in front of any
243
181
command. (e.g. "bzr --quiet help").
245
--quiet Suppress informational output; only print errors and warnings.
246
--version Print the version number.
183
--quiet Suppress informational output; only print errors and warnings
184
--version Print the version number
248
--no-aliases Do not process command aliases when running this command.
186
--no-aliases Do not process command aliases when running this command
249
187
--builtin Use the built-in version of a command, not the plugin version.
250
This does not suppress other plugin effects.
251
--no-plugins Do not process any plugins.
188
This does not suppress other plugin effects
189
--no-plugins Do not process any plugins
253
-Devil Capture call sites that do expensive or badly-scaling
255
191
-Derror Instead of normal error handling, always print a traceback on
257
-Dhooks Trace hook execution.
258
-Dhpss Trace smart protocol requests and responses.
259
-Dindex Trace major index operations.
260
-Dlock Trace when lockdir locks are taken or released.
261
--profile Profile execution using the hotshot profiler.
262
--lsprof Profile execution using the lsprof profiler.
193
--profile Profile execution using the hotshot profiler
194
--lsprof Profile execution using the lsprof profiler
263
195
--lsprof-file Profile execution using the lsprof profiler, and write the
264
196
results to a specified file. If the filename ends with ".txt",
265
text format will be used. If the filename either starts with
266
"callgrind.out" or end with ".callgrind", the output will be
267
formatted for use with KCacheGrind. Otherwise, the output
197
text format will be used. If the filename ends with
198
".callgrind", output will be formatted for use with KCacheGrind.
199
Otherwise, the output will be a pickle.
270
201
See doc/developers/profiling.txt for more information on profiling.
453
381
C File has conflicts
454
382
P Entry for a pending merge (not a file)
456
Column 2 - contents::
460
387
K File kind changed
465
391
* The execute bit was changed
470
"""Environment Variables
472
================ =================================================================
473
BZRPATH Path where bzr is to look for shell plugin external commands.
474
BZR_EMAIL E-Mail address of the user. Overrides EMAIL.
475
EMAIL E-Mail address of the user.
476
BZR_EDITOR Editor for editing commit messages. Overrides EDITOR.
477
EDITOR Editor for editing commit messages.
478
BZR_PLUGIN_PATH Paths where bzr should look for plugins.
479
BZR_HOME Directory holding .bazaar config dir. Overrides HOME.
480
BZR_HOME (Win32) Directory holding bazaar config dir. Overrides APPDATA and HOME.
481
================ =================================================================
488
:On Linux: ~/.bazaar/bazaar.conf
489
:On Windows: C:\\Documents and Settings\\username\\Application Data\\bazaar\\2.0\\bazaar.conf
491
Contains the user's default configuration. The section ``[DEFAULT]`` is
492
used to define general configuration that will be applied everywhere.
493
The section ``[ALIASES]`` can be used to create command aliases for
494
commonly used options.
496
A typical config file might look something like::
499
email=John Doe <jdoe@isp.com>
502
commit = commit --strict
503
log10 = log --short -r -10..-1
507
395
topic_registry.register("revisionspec", _help_on_revisionspec,
508
396
"Explain how to use --revision")
509
topic_registry.register('basic', _basic_help, "Basic commands", SECT_HIDDEN)
510
topic_registry.register('topics', _help_on_topics, "Topics list", SECT_HIDDEN)
397
topic_registry.register('basic', _basic_help, "Basic commands")
398
topic_registry.register('topics', _help_on_topics, "Topics list")
511
399
def get_format_topic(topic):
512
400
from bzrlib import bzrdir
513
return "Storage Formats\n\n" + bzrdir.format_registry.help_topic(topic)
401
return bzrdir.format_registry.help_topic(topic)
514
402
topic_registry.register('formats', get_format_topic, 'Directory formats')
515
403
topic_registry.register('global-options', _global_options,
516
404
'Options that can be used with any command')
517
405
topic_registry.register('checkouts', _checkouts,
518
'Information on what a checkout is', SECT_CONCEPT)
406
'Information on what a checkout is')
519
407
topic_registry.register('urlspec', _help_on_transport,
520
408
"Supported transport protocols")
521
409
topic_registry.register('status-flags', _status_flags,
522
410
"Help on status flags")
523
411
def get_bugs_topic(topic):
524
412
from bzrlib import bugtracker
525
return "Bug Trackers\n\n" + bugtracker.tracker_registry.help_topic(topic)
413
return bugtracker.tracker_registry.help_topic(topic)
526
414
topic_registry.register('bugs', get_bugs_topic, 'Bug tracker support')
527
415
topic_registry.register('repositories', _repositories,
528
'Basic information on shared repositories.',
416
'Basic information on shared repositories.')
530
417
topic_registry.register('working-trees', _working_trees,
531
'Information on working trees', SECT_CONCEPT)
532
topic_registry.register('env-variables', _env_variables,
533
'Environment variable names and values')
534
topic_registry.register('files', _files,
535
'Information on configuration and log files')
418
'Information on working trees')
538
421
class HelpTopicIndex(object):