[PATCH 3 of 4] doc: translate from :hg:`help config.SECTION` to a valid link to hgrc.5.html

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Feb 11 09:18:27 EST 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1455200134 -32400
#      Thu Feb 11 23:15:34 2016 +0900
# Node ID c68e5de523aa58c922bb9b148bf7136d4a57445e
# Parent  ca4a0f06eefd9db09635ec7c88da1c41e79c6b3b
doc: translate from :hg:`help config.SECTION` to a valid link to hgrc.5.html

Before this patch, ":hg:`help config.SECTION`" in online help text is
translated to a link to "hg.1.html#config.SECTION" in HTML
unintentionally.

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

This patch ignores element(s) under "SECTION" (e.g. "ITEM" of
":hg:`help config.SECTION.ITEM`"), because there is no way to refer
directly to it in HTML, yet.

diff --git a/doc/runrst b/doc/runrst
--- a/doc/runrst
+++ b/doc/runrst
@@ -35,6 +35,9 @@ def role_hg(name, rawtext, text, lineno,
         if args[0] == 'config':
             # :hg:`help config`
             refuri = "hgrc.5.html"
+        elif args[0].startswith('config.'):
+            # :hg:`help config.SECTION...`
+            refuri = "hgrc.5.html#%s" % args[0].split('.', 2)[1]
         elif len(args) >= 2 and args[0] == '-c':
             # :hg:`help -c COMMAND ...` is equivalent to :hg:`COMMAND`
             # (mainly for :hg:`help -c config`)


More information about the Mercurial-devel mailing list