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.
23
36
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"
26
47
class HelpTopicRegistry(registry.Registry):
27
48
"""A Registry customized for handling help topics."""
29
def register(self, topic, detail, summary):
50
def register(self, topic, detail, summary, section=SECT_LIST):
30
51
"""Register a new help topic.
32
53
:param topic: Name of documentation entry
33
54
:param detail: Function or string object providing detailed
34
55
documentation for topic. Function interface is detail(topic).
35
56
This should return a text string of the detailed information.
57
See the module documentation for details on help text formatting.
36
58
:param summary: String providing single-line documentation for topic.
59
:param section: Section in reference manual - see SECT_* identifiers.
38
# The detail is stored as the 'object' and the
39
super(HelpTopicRegistry, self).register(topic, detail, info=summary)
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)
41
def register_lazy(self, topic, module_name, member_name, summary):
65
def register_lazy(self, topic, module_name, member_name, summary,
42
67
"""Register a new help topic, and import the details on demand.
44
69
:param topic: Name of documentation entry
45
70
:param module_name: The module to find the detailed help.
46
71
:param member_name: The member of the module to use for detailed help.
47
72
: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)
49
77
super(HelpTopicRegistry, self).register_lazy(topic, module_name,
50
member_name, info=summary)
78
member_name, info=info)
52
80
def get_detail(self, topic):
53
81
"""Get the detailed help on a given topic."""
60
88
def get_summary(self, topic):
61
89
"""Get the single line summary for the topic."""
62
return self.get_info(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):
65
113
topic_registry = HelpTopicRegistry()
83
131
def _help_on_revisionspec(name):
84
"""Write the summary help for all documented topics to outfile."""
132
"""Generate the help for revision specs."""
85
134
import bzrlib.revisionspec
88
out.append("\nRevision prefix specifier:"
89
"\n--------------------------\n")
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")
142
# The help text is indented 4 spaces - this re cleans that up below
143
indent_re = re.compile(r'^ ', re.MULTILINE)
91
144
for i in bzrlib.revisionspec.SPEC_TYPES:
93
146
if doc == bzrlib.revisionspec.RevisionSpec.help_txt:
95
while (doc[-2:] == '\n\n' or doc[-1:] == ' '):
98
out.append(" %s %s\n\n" % (i.prefix, doc))
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)
103
165
def _help_on_transport(name):
132
193
if not shorthelp:
134
195
if proto.endswith("://"):
135
protl.extend(add_string(proto, shorthelp, 79))
196
protl.append(add_string(proto, shorthelp, 79))
137
decl.extend(add_string(proto, shorthelp, 79))
140
out = "\nSupported URL prefix\n--------------------\n" + \
198
decl.append(add_string(proto, shorthelp, 79))
201
out = "URL Identifiers\n\n" + \
202
"Supported URL prefixes::\n\n " + \
144
out += "\nSupported modifiers\n-------------------\n" + \
206
out += "\nSupported modifiers::\n\n " + \
151
213
"""Bazaar -- a free distributed version-control tool
152
214
http://bazaar-vcs.org/
194
256
--lsprof Profile execution using the lsprof profiler
195
257
--lsprof-file Profile execution using the lsprof profiler, and write the
196
258
results to a specified file. If the filename ends with ".txt",
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.
259
text format will be used. If the filename either starts with
260
"callgrind.out" or end with ".callgrind", the output will be
261
formatted for use with KCacheGrind. Otherwise, the output
201
264
See doc/developers/profiling.txt for more information on profiling.
381
447
C File has conflicts
382
448
P Entry for a pending merge (not a file)
450
Column 2 - contents::
387
454
K File kind changed
391
459
* The execute bit was changed
464
"""Environment Variables
466
================ =================================================================
467
BZRPATH Path where bzr is to look for shell plugin external commands.
468
BZR_EMAIL E-Mail address of the user. Overrides EMAIL.
469
EMAIL E-Mail address of the user.
470
BZR_EDITOR Editor for editing commit messages. Overrides EDITOR.
471
EDITOR Editor for editing commit messages.
472
BZR_PLUGIN_PATH Paths where bzr should look for plugins.
473
BZR_HOME Directory holding .bazaar config dir. Overrides HOME.
474
BZR_HOME (Win32) Directory holding bazaar config dir. Overrides APPDATA and HOME.
475
================ =================================================================
482
:On Linux: ~/.bazaar/bazaar.conf
483
:On Windows: C:\\Documents and Settings\\username\\Application Data\\bazaar\\2.0\\bazaar.conf
485
Contains the user's default configuration. The section ``[DEFAULT]`` is
486
used to define general configuration that will be applied everywhere.
487
The section ``[ALIASES]`` can be used to create command aliases for
488
commonly used options.
490
A typical config file might look something like::
493
email=John Doe <jdoe@isp.com>
496
commit = commit --strict
497
log10 = log --short -r -10..-1
395
501
topic_registry.register("revisionspec", _help_on_revisionspec,
396
502
"Explain how to use --revision")
397
topic_registry.register('basic', _basic_help, "Basic commands")
398
topic_registry.register('topics', _help_on_topics, "Topics list")
503
topic_registry.register('basic', _basic_help, "Basic commands", SECT_HIDDEN)
504
topic_registry.register('topics', _help_on_topics, "Topics list", SECT_HIDDEN)
399
505
def get_format_topic(topic):
400
506
from bzrlib import bzrdir
401
return bzrdir.format_registry.help_topic(topic)
507
return "Storage Formats\n\n" + bzrdir.format_registry.help_topic(topic)
402
508
topic_registry.register('formats', get_format_topic, 'Directory formats')
403
509
topic_registry.register('global-options', _global_options,
404
510
'Options that can be used with any command')
405
511
topic_registry.register('checkouts', _checkouts,
406
'Information on what a checkout is')
512
'Information on what a checkout is', SECT_CONCEPT)
407
513
topic_registry.register('urlspec', _help_on_transport,
408
514
"Supported transport protocols")
409
515
topic_registry.register('status-flags', _status_flags,
410
516
"Help on status flags")
411
517
def get_bugs_topic(topic):
412
518
from bzrlib import bugtracker
413
return bugtracker.tracker_registry.help_topic(topic)
519
return "Bug Trackers\n\n" + bugtracker.tracker_registry.help_topic(topic)
414
520
topic_registry.register('bugs', get_bugs_topic, 'Bug tracker support')
415
521
topic_registry.register('repositories', _repositories,
416
'Basic information on shared repositories.')
522
'Basic information on shared repositories.',
417
524
topic_registry.register('working-trees', _working_trees,
418
'Information on working trees')
525
'Information on working trees', SECT_CONCEPT)
526
topic_registry.register('env-variables', _env_variables,
527
'Environment variable names and values')
528
topic_registry.register('files', _files,
529
'Information on configuration and log files')
421
532
class HelpTopicIndex(object):