mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-16 13:58:47 +00:00
Docs: Improve autoref
Fix `help $cell` type references, as well as actually implement the fallback to yoscrypt.
This commit is contained in:
parent
5d239204f2
commit
e289e32e61
|
@ -41,8 +41,12 @@ html_static_path = ['_static', "_images"]
|
|||
# default to no highlight
|
||||
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'
|
||||
rst_prolog = """
|
||||
.. role:: yoscrypt(code)
|
||||
:language: yoscrypt
|
||||
"""
|
||||
|
||||
extensions = ['sphinx.ext.autosectionlabel', 'sphinxcontrib.bibtex']
|
||||
|
||||
|
|
|
@ -715,10 +715,18 @@ class CellDomain(CommandDomain):
|
|||
|
||||
def autoref(name, rawtext: str, text: str, lineno, inliner: Inliner,
|
||||
options=None, content=None):
|
||||
role = 'cell:ref' if text[0] == '$' else 'cmd:ref'
|
||||
if text.startswith("help ") and text.count(' ') == 1:
|
||||
_, cmd = text.split(' ', 1)
|
||||
text = f'{text} <{cmd}>'
|
||||
words = text.split(' ')
|
||||
if len(words) == 2 and words[0] == "help":
|
||||
IsLinkable = True
|
||||
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)
|
||||
|
||||
def setup(app: Sphinx):
|
||||
|
|
Loading…
Reference in a new issue