Rev 2454: Teach RegisteredTopic to support the additional_see_also list of related help terms. in file:///home/robertc/source/baz/help-contexts/

Robert Collins robertc at robertcollins.net
Fri Apr 20 05:08:34 BST 2007


At file:///home/robertc/source/baz/help-contexts/

------------------------------------------------------------
revno: 2454
revision-id: robertc at robertcollins.net-20070420040831-xff3b3kdjnei9rmg
parent: robertc at robertcollins.net-20070420035406-e68xf089otkpo7xx
committer: Robert Collins <robertc at robertcollins.net>
branch nick: help-contexts
timestamp: Fri 2007-04-20 14:08:31 +1000
message:
  Teach RegisteredTopic to support the additional_see_also list of related help terms.
modified:
  bzrlib/help_topics.py          help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
  bzrlib/tests/test_help.py      test_help.py-20070419045354-6q6rq15j9e2n5fna-1
=== modified file 'bzrlib/help_topics.py'
--- a/bzrlib/help_topics.py	2007-04-20 03:07:01 +0000
+++ b/bzrlib/help_topics.py	2007-04-20 04:08:31 +0000
@@ -279,6 +279,19 @@
         """
         self.topic = topic
 
-    def get_help_text(self):
-        """Return a string with the help for this topic."""
-        return topic_registry.get_detail(self.topic)
+    def get_help_text(self, additional_see_also=None):
+        """Return a string with the help for this topic.
+
+        :param additional_see_also: Additional help topics to be
+            cross-referenced.
+        """
+        result = topic_registry.get_detail(self.topic)
+        if additional_see_also is not None:
+            see_also = sorted(set(additional_see_also))
+        else:
+            see_also = None
+        if see_also:
+            result += '\nSee also: '
+            result += ', '.join(see_also)
+            result += '\n'
+        return result

=== modified file 'bzrlib/tests/test_help.py'
--- a/bzrlib/tests/test_help.py	2007-04-20 03:54:06 +0000
+++ b/bzrlib/tests/test_help.py	2007-04-20 04:08:31 +0000
@@ -92,6 +92,13 @@
         self.assertEqual(help_topics.topic_registry.get_detail('commands'),
             topic.get_help_text())
 
+    def test_get_help_text_with_additional_see_also(self):
+        topic = help_topics.RegisteredTopic('commands')
+        self.assertEndsWith(
+            topic.get_help_text(['foo', 'bar']),
+            '\n'
+            'See also: bar, foo\n')
+
 
 class TestTopicIndex(tests.TestCase):
     """Tests for the HelpTopicIndex class."""



More information about the bazaar-commits mailing list