help: use a full header for topic titles

...for prettier HTML!
This commit is contained in:
Dan Villiom Podlaski Christiansen 2013-02-10 12:58:57 +01:00
parent 9e387ff40b
commit d045d03b91
5 changed files with 29 additions and 26 deletions

View File

@ -5,6 +5,7 @@ sys.path.insert(0, "..")
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 @@ def get_cmd(cmd, cmdtable):
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 @@ def show_doc(ui):
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 @@ def show_doc(ui):
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 @@ def commandprinter(ui, cmdtable, sectionfunc):
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()

View File

@ -394,7 +394,8 @@ def help_(ui, name, unknowncmd=False, full=True, **opts):
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)"))

View File

@ -22,6 +22,18 @@ import re
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.

View File

@ -353,6 +353,7 @@ Test help topic with same name as extension
$ 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

View File

@ -712,6 +712,7 @@ Test a help topic
$ hg help revs
Specifying Single Revisions
"""""""""""""""""""""""""""
Mercurial supports several ways to specify individual revisions.
@ -857,6 +858,7 @@ Test omit indicating for help
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 @@ Test omit indicating for help
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 @@ Dish up an empty repo; serve it cold.
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>