--- a/doc/gendoc.py Sat Feb 09 21:51:21 2013 +0000
+++ b/doc/gendoc.py Sun Feb 10 12:58:57 2013 +0100
@@ -5,6 +5,7 @@
sys.path.append(os.path.join('..', 'mercurial', 'pure'))
from mercurial import demandimport; demandimport.enable()
from mercurial import encoding
+from mercurial import minirst
from mercurial.commands import table, globalopts
from mercurial.i18n import _
from mercurial.help import helptable
@@ -63,28 +64,15 @@
return d
-def section(ui, s):
- ui.write("%s\n%s\n\n" % (s, "\"" * encoding.colwidth(s)))
-
-def subsection(ui, s):
- ui.write("%s\n%s\n\n" % (s, '=' * encoding.colwidth(s)))
-
-def subsubsection(ui, s):
- ui.write("%s\n%s\n\n" % (s, "-" * encoding.colwidth(s)))
-
-def subsubsubsection(ui, s):
- ui.write("%s\n%s\n\n" % (s, "." * encoding.colwidth(s)))
-
-
def show_doc(ui):
# print options
- section(ui, _("Options"))
+ ui.write(minirst.section(_("Options")))
for optstr, desc in get_opts(globalopts):
ui.write("%s\n %s\n\n" % (optstr, desc))
# print cmds
- section(ui, _("Commands"))
- commandprinter(ui, table, subsection)
+ ui.write(minirst.section(_("Commands")))
+ commandprinter(ui, table, minirst.subsection)
# print topics
for names, sec, doc in helptable:
@@ -95,13 +83,13 @@
for name in names:
ui.write(".. _%s:\n" % name)
ui.write("\n")
- section(ui, sec)
+ ui.write(minirst.section(sec))
if util.safehasattr(doc, '__call__'):
doc = doc()
ui.write(doc)
ui.write("\n")
- section(ui, _("Extensions"))
+ ui.write(minirst.section(_("Extensions")))
ui.write(_("This section contains help for extensions that are "
"distributed together with Mercurial. Help for other "
"extensions is available in the help system."))
@@ -113,12 +101,12 @@
for extensionname in sorted(allextensionnames()):
mod = extensions.load(None, extensionname, None)
- subsection(ui, extensionname)
+ ui.write(minirst.subsection(extensionname))
ui.write("%s\n\n" % mod.__doc__)
cmdtable = getattr(mod, 'cmdtable', None)
if cmdtable:
- subsubsection(ui, _('Commands'))
- commandprinter(ui, cmdtable, subsubsubsection)
+ ui.write(minirst.subsubsection(_('Commands')))
+ commandprinter(ui, cmdtable, minirst.subsubsubsection)
def commandprinter(ui, cmdtable, sectionfunc):
h = {}
@@ -133,7 +121,7 @@
if f.startswith("debug"):
continue
d = get_cmd(h[f], cmdtable)
- sectionfunc(ui, d['cmd'])
+ ui.write(sectionfunc(d['cmd']))
# synopsis
ui.write("::\n\n")
synopsislines = d['synopsis'].splitlines()
--- a/mercurial/help.py Sat Feb 09 21:51:21 2013 +0000
+++ b/mercurial/help.py Sun Feb 10 12:58:57 2013 +0100
@@ -394,7 +394,8 @@
else:
raise error.UnknownCommand(name)
- rst = ["%s\n\n" % header]
+ rst = [minirst.section(header)]
+
# description
if not doc:
rst.append(" %s\n" % _("(no help text available)"))
--- a/mercurial/minirst.py Sat Feb 09 21:51:21 2013 +0000
+++ b/mercurial/minirst.py Sun Feb 10 12:58:57 2013 +0100
@@ -22,6 +22,18 @@
import util, encoding
from i18n import _
+def section(s):
+ return "%s\n%s\n\n" % (s, "\"" * encoding.colwidth(s))
+
+def subsection(s):
+ return "%s\n%s\n\n" % (s, '=' * encoding.colwidth(s))
+
+def subsubsection(s):
+ return "%s\n%s\n\n" % (s, "-" * encoding.colwidth(s))
+
+def subsubsubsection(s):
+ return "%s\n%s\n\n" % (s, "." * encoding.colwidth(s))
+
def replace(text, substs):
'''
Apply a list of (find, replace) pairs to a text.
--- a/tests/test-extension.t Sat Feb 09 21:51:21 2013 +0000
+++ b/tests/test-extension.t Sun Feb 10 12:58:57 2013 +0100
@@ -353,6 +353,7 @@
$ hg help multirevs
Specifying Multiple Revisions
+ """""""""""""""""""""""""""""
When Mercurial accepts more than one revision, they may be specified
individually, or provided as a topologically continuous range, separated
--- a/tests/test-help.t Sat Feb 09 21:51:21 2013 +0000
+++ b/tests/test-help.t Sun Feb 10 12:58:57 2013 +0100
@@ -712,6 +712,7 @@
$ hg help revs
Specifying Single Revisions
+ """""""""""""""""""""""""""
Mercurial supports several ways to specify individual revisions.
@@ -857,6 +858,7 @@
no commands defined
$ hg help topic-containing-verbose
This is the topic to test omit indicating.
+ """"""""""""""""""""""""""""""""""""""""""
This paragraph is never omitted (for topic).
@@ -865,6 +867,7 @@
use "hg help -v topic-containing-verbose" to show more complete help
$ hg help -v topic-containing-verbose
This is the topic to test omit indicating.
+ """"""""""""""""""""""""""""""""""""""""""
This paragraph is never omitted (for topic).
@@ -1728,9 +1731,7 @@
files, or words in the commit message</div>
</form>
<div id="doc">
- <p>
- Specifying Single Revisions
- </p>
+ <h1>Specifying Single Revisions</h1>
<p>
Mercurial supports several ways to specify individual revisions.
</p>