mirror of https://github.com/YosysHQ/yosys.git
Docs: Improve autoref
Fix `help $cell` type references, as well as actually implement the fallback to yoscrypt.
This commit is contained in:
parent
2b35c4dccf
commit
0df5507791
|
@ -18,8 +18,12 @@ html_static_path = ['_static', "_images"]
|
||||||
# default to no highlight
|
# default to no highlight
|
||||||
highlight_language = 'none'
|
highlight_language = 'none'
|
||||||
|
|
||||||
# default single quotes to attempt auto reference, or fallback to code
|
# default single quotes to attempt auto reference, or fallback to yoscrypt
|
||||||
default_role = 'autoref'
|
default_role = 'autoref'
|
||||||
|
rst_prolog = """
|
||||||
|
.. role:: yoscrypt(code)
|
||||||
|
:language: yoscrypt
|
||||||
|
"""
|
||||||
|
|
||||||
extensions = ['sphinx.ext.autosectionlabel', 'sphinxcontrib.bibtex']
|
extensions = ['sphinx.ext.autosectionlabel', 'sphinxcontrib.bibtex']
|
||||||
|
|
||||||
|
|
|
@ -715,10 +715,18 @@ class CellDomain(CommandDomain):
|
||||||
|
|
||||||
def autoref(name, rawtext: str, text: str, lineno, inliner: Inliner,
|
def autoref(name, rawtext: str, text: str, lineno, inliner: Inliner,
|
||||||
options=None, content=None):
|
options=None, content=None):
|
||||||
role = 'cell:ref' if text[0] == '$' else 'cmd:ref'
|
words = text.split(' ')
|
||||||
if text.startswith("help ") and text.count(' ') == 1:
|
if len(words) == 2 and words[0] == "help":
|
||||||
_, cmd = text.split(' ', 1)
|
IsLinkable = True
|
||||||
text = f'{text} <{cmd}>'
|
thing = words[1]
|
||||||
|
else:
|
||||||
|
IsLinkable = len(words) == 1 and words[0][0] != '-'
|
||||||
|
thing = words[0]
|
||||||
|
if IsLinkable:
|
||||||
|
role = 'cell:ref' if thing[0] == '$' else 'cmd:ref'
|
||||||
|
text = f'{text} <{thing}>'
|
||||||
|
else:
|
||||||
|
role = 'yoscrypt'
|
||||||
return inliner.interpreted(rawtext, text, role, lineno)
|
return inliner.interpreted(rawtext, text, role, lineno)
|
||||||
|
|
||||||
def setup(app: Sphinx):
|
def setup(app: Sphinx):
|
||||||
|
|
Loading…
Reference in New Issue