100
100
return ''.join(out)
103
def _help_on_transport(name):
104
from bzrlib.transport import (
105
transport_list_registry,
109
def add_string(proto, help, maxl, prefix_width=20):
110
help_lines = textwrap.wrap(help, maxl - prefix_width)
111
line_with_indent = '\n' + ' ' * prefix_width
112
help_text = line_with_indent.join(help_lines)
113
return "%-20s%s\n" % (proto, help_text)
116
a1 = a[:a.rfind("://")]
117
b1 = b[:b.rfind("://")]
128
protos = transport_list_registry.keys( )
129
protos.sort(sort_func)
131
shorthelp = transport_list_registry.get_help(proto)
134
if proto.endswith("://"):
135
protl.extend(add_string(proto, shorthelp, 79))
137
decl.extend(add_string(proto, shorthelp, 79))
140
out = "\nSupported URL prefix\n--------------------\n" + \
144
out += "\nSupported modifiers\n-------------------\n" + \
104
151
"""Bazaar -- a free distributed version-control tool
105
152
http://bazaar-vcs.org/
242
289
'Options that can be used with any command')
243
290
topic_registry.register('checkouts', _checkouts,
244
291
'Information on what a checkout is')
292
topic_registry.register('urlspec', _help_on_transport,
293
"Supported transport protocols")
294
def get_bugs_topic(topic):
295
from bzrlib import bugtracker
296
return bugtracker.tracker_registry.help_topic(topic)
297
topic_registry.register('bugs', get_bugs_topic, 'Bug tracker support')
300
class HelpTopicIndex(object):
301
"""A index for bzr help that returns topics."""
306
def get_topics(self, topic):
307
"""Search for topic in the HelpTopicRegistry.
309
:param topic: A topic to search for. None is treated as 'basic'.
310
:return: A list which is either empty or contains a single
311
RegisteredTopic entry.
315
if topic in topic_registry:
316
return [RegisteredTopic(topic)]
321
class RegisteredTopic(object):
322
"""A help topic which has been registered in the HelpTopicRegistry.
324
These topics consist of nothing more than the name of the topic - all
325
data is retrieved on demand from the registry.
328
def __init__(self, topic):
331
:param topic: The name of the topic that this represents.
335
def get_help_text(self, additional_see_also=None):
336
"""Return a string with the help for this topic.
338
:param additional_see_also: Additional help topics to be
341
result = topic_registry.get_detail(self.topic)
342
# there is code duplicated here and in bzrlib/plugin.py's
343
# matching Topic code. This should probably be factored in
344
# to a helper function and a common base class.
345
if additional_see_also is not None:
346
see_also = sorted(set(additional_see_also))
350
result += '\nSee also: '
351
result += ', '.join(see_also)
355
def get_help_topic(self):
356
"""Return the help topic this can be found under."""