Show More
@@ -79,7 +79,11 b' def loaddoc(topic):' | |||||
79 | break |
|
79 | break | |
80 |
|
80 | |||
81 | path = os.path.join(docdir, topic + ".txt") |
|
81 | path = os.path.join(docdir, topic + ".txt") | |
82 |
|
|
82 | doc = gettext(open(path).read()) | |
|
83 | for rewriter in helphooks.get(topic, []): | |||
|
84 | doc = rewriter(topic, doc) | |||
|
85 | return doc | |||
|
86 | ||||
83 | return loader |
|
87 | return loader | |
84 |
|
88 | |||
85 | helptable = [ |
|
89 | helptable = [ | |
@@ -102,3 +106,11 b' helptable = [' | |||||
102 | (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')), |
|
106 | (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')), | |
103 | (["glossary"], _("Glossary"), loaddoc('glossary')), |
|
107 | (["glossary"], _("Glossary"), loaddoc('glossary')), | |
104 | ] |
|
108 | ] | |
|
109 | ||||
|
110 | # Map topics to lists of callable taking the current topic help and | |||
|
111 | # returning the updated version | |||
|
112 | helphooks = { | |||
|
113 | } | |||
|
114 | ||||
|
115 | def addtopichook(topic, rewriter): | |||
|
116 | helphooks.setdefault(topic, []).append(rewriter) |
@@ -756,3 +756,30 b' Test a help topic' | |||||
756 | The reserved name "." indicates the working directory parent. If no |
|
756 | The reserved name "." indicates the working directory parent. If no | |
757 | working directory is checked out, it is equivalent to null. If an |
|
757 | working directory is checked out, it is equivalent to null. If an | |
758 | uncommitted merge is in progress, "." is the revision of the first parent. |
|
758 | uncommitted merge is in progress, "." is the revision of the first parent. | |
|
759 | ||||
|
760 | Test help hooks | |||
|
761 | ||||
|
762 | $ cat > helphook1.py <<EOF | |||
|
763 | > from mercurial import help | |||
|
764 | > | |||
|
765 | > def rewrite(topic, doc): | |||
|
766 | > return doc + '\nhelphook1\n' | |||
|
767 | > | |||
|
768 | > def extsetup(ui): | |||
|
769 | > help.addtopichook('revsets', rewrite) | |||
|
770 | > EOF | |||
|
771 | $ cat > helphook2.py <<EOF | |||
|
772 | > from mercurial import help | |||
|
773 | > | |||
|
774 | > def rewrite(topic, doc): | |||
|
775 | > return doc + '\nhelphook2\n' | |||
|
776 | > | |||
|
777 | > def extsetup(ui): | |||
|
778 | > help.addtopichook('revsets', rewrite) | |||
|
779 | > EOF | |||
|
780 | $ echo '[extensions]' >> $HGRCPATH | |||
|
781 | $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH | |||
|
782 | $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH | |||
|
783 | $ hg help revsets | grep helphook | |||
|
784 | helphook1 | |||
|
785 | helphook2 |
General Comments 0
You need to be logged in to leave comments.
Login now