Skip to content
Snippets Groups Projects
Commit 63eae465 authored by Katsunori FUJIWARA's avatar Katsunori FUJIWARA
Browse files

doc: translate from :hg:`help config` to a valid link to hgrc.5.html

Before this patch, ":hg:`help config`" in online help text is
translated to a link to "hg.1.html#config" in HTML, even though actual
"hg help config" shows not help for "hg config" command but "config"
help topic, and all of current ":hg:`help config`" expects the latter.

This patch translates from ":hg:`help config`" in online help text to
a link to "hgrc.5.html" in HTML as expected.

This patch also allows ":hg:`help -c COMMAND`" style to link
"hg.1.html#COMMAND" for readability.
parent a1924bc6
No related branches found
No related tags found
No related merge requests found
......@@ -30,4 +30,5 @@
linktext = nodes.literal(rawtext, text)
parts = text.split()
cmd, args = parts[1], parts[2:]
refuri = "hg.1.html#%s" % cmd
if cmd == 'help' and args:
......@@ -33,3 +34,11 @@
if cmd == 'help' and args:
cmd = args[0] # link to 'dates' for 'hg help dates'
if args[0] == 'config':
# :hg:`help config`
refuri = "hgrc.5.html"
elif len(args) >= 2 and args[0] == '-c':
# :hg:`help -c COMMAND ...` is equivalent to :hg:`COMMAND`
# (mainly for :hg:`help -c config`)
refuri = "hg.1.html#%s" % args[1]
else:
refuri = "hg.1.html#%s" % args[0]
node = nodes.reference(rawtext, '', linktext,
......@@ -35,5 +44,5 @@
node = nodes.reference(rawtext, '', linktext,
refuri="hg.1.html#%s" % cmd)
refuri=refuri)
return [node], []
roles.register_local_role("hg", role_hg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment