##// END OF EJS Templates
help: extract items doc generation function
Patrick Mezard -
r13593:cc4721ed default
parent child Browse files
Show More
@@ -115,3 +115,19 b' helphooks = {'
115
115
116 def addtopichook(topic, rewriter):
116 def addtopichook(topic, rewriter):
117 helphooks.setdefault(topic, []).append(rewriter)
117 helphooks.setdefault(topic, []).append(rewriter)
118
119 def makeitemsdoc(topic, doc, marker, items):
120 """Extract docstring from the items key to function mapping, build a
121 .single documentation block and use it to overwrite the marker in doc
122 """
123 entries = []
124 for name in sorted(items):
125 text = (items[name].__doc__ or '').rstrip()
126 if not text:
127 continue
128 text = gettext(text)
129 lines = text.splitlines()
130 lines[1:] = [(' ' + l.strip()) for l in lines[1:]]
131 entries.append('\n'.join(lines))
132 entries = '\n\n'.join(entries)
133 return doc.replace(marker, entries)
@@ -6,10 +6,10 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import re
8 import re
9 import parser, util, error, discovery
9 import parser, util, error, discovery, help
10 import bookmarks as bookmarksmod
10 import bookmarks as bookmarksmod
11 import match as matchmod
11 import match as matchmod
12 from i18n import _, gettext
12 from i18n import _
13
13
14 elements = {
14 elements = {
15 "(": (20, ("group", 1, ")"), ("func", 1, ")")),
15 "(": (20, ("group", 1, ")"), ("func", 1, ")")),
@@ -815,19 +815,7 b' def match(spec):'
815 return mfunc
815 return mfunc
816
816
817 def makedoc(topic, doc):
817 def makedoc(topic, doc):
818 """Generate and include predicates help in revsets topic."""
818 return help.makeitemsdoc(topic, doc, '.. predicatesmarker', symbols)
819 predicates = []
820 for name in sorted(symbols):
821 text = symbols[name].__doc__
822 if not text:
823 continue
824 text = gettext(text.rstrip())
825 lines = text.splitlines()
826 lines[1:] = [(' ' + l.strip()) for l in lines[1:]]
827 predicates.append('\n'.join(lines))
828 predicates = '\n\n'.join(predicates)
829 doc = doc.replace('.. predicatesmarker', predicates)
830 return doc
831
819
832 # tell hggettext to extract docstrings from these functions:
820 # tell hggettext to extract docstrings from these functions:
833 i18nfunctions = symbols.values()
821 i18nfunctions = symbols.values()
@@ -6,8 +6,7 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import cgi, re, os, time, urllib
8 import cgi, re, os, time, urllib
9 import encoding, node, util
9 import encoding, node, util, help
10 from i18n import gettext
11
10
12 def addbreaks(text):
11 def addbreaks(text):
13 """:addbreaks: Any text. Add an XHTML "<br />" tag before the end of
12 """:addbreaks: Any text. Add an XHTML "<br />" tag before the end of
@@ -353,19 +352,7 b' filters = {'
353 }
352 }
354
353
355 def makedoc(topic, doc):
354 def makedoc(topic, doc):
356 """Generate and include templatefilters help in templating topic."""
355 return help.makeitemsdoc(topic, doc, '.. filtersmarker', filters)
357 entries = []
358 for name in sorted(filters):
359 text = (filters[name].__doc__ or '').rstrip()
360 if not text:
361 continue
362 text = gettext(text)
363 lines = text.splitlines()
364 lines[1:] = [(' ' + l.strip()) for l in lines[1:]]
365 entries.append('\n'.join(lines))
366 entries = '\n\n'.join(entries)
367 doc = doc.replace('.. filtersmarker', entries)
368 return doc
369
356
370 # tell hggettext to extract docstrings from these functions:
357 # tell hggettext to extract docstrings from these functions:
371 i18nfunctions = filters.values()
358 i18nfunctions = filters.values()
@@ -6,8 +6,7 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from node import hex
8 from node import hex
9 import encoding, patch, util, error
9 import encoding, patch, util, error, help
10 from i18n import gettext
11
10
12 def showlist(name, values, plural=None, **args):
11 def showlist(name, values, plural=None, **args):
13 '''expand set of values.
12 '''expand set of values.
@@ -316,19 +315,7 b' keywords = {'
316 }
315 }
317
316
318 def makedoc(topic, doc):
317 def makedoc(topic, doc):
319 """Generate and include keyword help in templating topic."""
318 return help.makeitemsdoc(topic, doc, '.. keywordsmarker', keywords)
320 kw = []
321 for name in sorted(keywords):
322 text = (keywords[name].__doc__ or '').rstrip()
323 if not text:
324 continue
325 text = gettext(text)
326 lines = text.splitlines()
327 lines[1:] = [(' ' + l.strip()) for l in lines[1:]]
328 kw.append('\n'.join(lines))
329 kw = '\n\n'.join(kw)
330 doc = doc.replace('.. keywordsmarker', kw)
331 return doc
332
319
333 # tell hggettext to extract docstrings from these functions:
320 # tell hggettext to extract docstrings from these functions:
334 i18nfunctions = keywords.values()
321 i18nfunctions = keywords.values()
General Comments 0
You need to be logged in to leave comments. Login now