Rev 4109: Include the Hooks class in the Hooks docs. in http://people.ubuntu.com/~robertc/baz2.0/pending/Hooks.docs
Robert Collins
robertc at robertcollins.net
Wed Mar 11 04:34:37 GMT 2009
At http://people.ubuntu.com/~robertc/baz2.0/pending/Hooks.docs
------------------------------------------------------------
revno: 4109
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 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