Rev 4118: (robertc) Trivially add the class name as a header before the in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Mar 11 23:33:11 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4118
revision-id: pqm at pqm.ubuntu.com-20090311233307-n6zmhg1y074svja6
parent: pqm at pqm.ubuntu.com-20090311225320-7y2picz4muszgkma
parent: robertc at robertcollins.net-20090311043421-jua2wrjq86ltarx0
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-03-11 23:33:07 +0000
message:
  (robertc) Trivially add the class name as a header before the
  	HookPoint docs in Hooks.docs(). (Tobert Collins)
modified:
  bzrlib/hooks.py                hooks.py-20070325015548-ix4np2q0kd8452au-1
  bzrlib/tests/test_hooks.py     test_hooks.py-20070628030849-89rtsbe5dmer5npz-1
    ------------------------------------------------------------
    revno: 4108.3.1
    revision-id: robertc at robertcollins.net-20090311043421-jua2wrjq86ltarx0
    parent: pqm at pqm.ubuntu.com-20090310131846-8f45p0k6f0nftk31
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: Hooks.docs
    timestamp: Wed 2009-03-11 15:34:21 +1100
    message:
      Include the Hooks class in the Hooks docs.
    modified:
      bzrlib/hooks.py                hooks.py-20070325015548-ix4np2q0kd8452au-1
      bzrlib/tests/test_hooks.py     test_hooks.py-20070628030849-89rtsbe5dmer5npz-1
=== modified file 'bzrlib/hooks.py'
--- a/bzrlib/hooks.py	2009-03-10 05:14:31 +0000
+++ b/bzrlib/hooks.py	2009-03-11 04:34:21 +0000
@@ -57,6 +57,10 @@
         """
         hook_names = sorted(self.keys())
         hook_docs = []
+        name = self.__class__.__name__
+        hook_docs.append(name)
+        hook_docs.append("="*len(name))
+        hook_docs.append("")
         for hook_name in hook_names:
             hook = self[hook_name]
             try:
@@ -68,7 +72,7 @@
                 strings.append("-" * len(hook_name))
                 strings.append("")
                 strings.append("An old-style hook. For documentation see the __init__ "
-                    "method of '%s'\n" % (self.__class__.__name__,))
+                    "method of '%s'\n" % (name,))
                 hook_docs.extend(strings)
         return "\n".join(hook_docs)
 

=== modified file 'bzrlib/tests/test_hooks.py'
--- a/bzrlib/tests/test_hooks.py	2009-03-10 03:05:21 +0000
+++ b/bzrlib/tests/test_hooks.py	2009-03-11 04:34:21 +0000
@@ -51,7 +51,9 @@
 
     def test_docs(self):
         """docs() should return something reasonable about the Hooks."""
-        hooks = Hooks()
+        class MyHooks(Hooks):
+            pass
+        hooks = MyHooks()
         hooks['legacy'] = []
         hook1 = HookPoint('post_tip_change',
             "Invoked after the tip of a branch changes. Called with "
@@ -63,11 +65,14 @@
             (1, 6), None)
         hooks.create_hook(hook1)
         hooks.create_hook(hook2)
-        self.assertEqual(
+        self.assertEqualDiff(
+            "MyHooks\n"
+            "=======\n"
+            "\n"
             "legacy\n"
             "------\n"
             "\n"
-            "An old-style hook. For documentation see the __init__ method of 'Hooks'\n"
+            "An old-style hook. For documentation see the __init__ method of 'MyHooks'\n"
             "\n"
             "post_tip_change\n"
             "---------------\n"




More information about the bazaar-commits mailing list