diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-01-24 08:32:13 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-01-24 08:32:13 +0300 |
commit | 502c4ee5fbef6bf51fe60cc820b1484471dd1b32 (patch) | |
tree | 0407a81eb4013f90cc62ae9ad8f1e1b8a51c16db /sphinx/domains | |
parent | ee5560b7739932d0a7735be0cc81f28d76a61e92 (diff) | |
parent | becf8f43befe8a1528552106848c0e369b7fba9a (diff) |
Merge branch '3.x'
Diffstat (limited to 'sphinx/domains')
-rw-r--r-- | sphinx/domains/std.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index 864c338f4..c4577ba63 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -43,7 +43,7 @@ logger = logging.getLogger(__name__) # RE for option descriptions option_desc_re = re.compile(r'((?:/|--|-|\+)?[^\s=]+)(=?\s*.*)') # RE for grammar tokens -token_re = re.compile(r'`(\w+)`', re.U) +token_re = re.compile(r'`((~?\w*:)?\w+)`', re.U) class GenericObject(ObjectDescription[str]): @@ -449,9 +449,23 @@ def token_xrefs(text: str, productionGroup: str = '') -> List[Node]: if m.start() > pos: txt = text[pos:m.start()] retnodes.append(nodes.Text(txt, txt)) - refnode = pending_xref(m.group(1), reftype='token', refdomain='std', - reftarget=productionGroup + m.group(1)) - refnode += nodes.literal(m.group(1), m.group(1), classes=['xref']) + token = m.group(1) + if ':' in token: + if token[0] == '~': + _, title = token.split(':') + target = token[1:] + elif token[0] == ':': + title = token[1:] + target = title + else: + title = token + target = token + else: + title = token + target = productionGroup + token + refnode = pending_xref(title, reftype='token', refdomain='std', + reftarget=target) + refnode += nodes.literal(token, title, classes=['xref']) retnodes.append(refnode) pos = m.end() if pos < len(text): |