mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 22:23:23 +00:00
Docs: Add autoref role
Use new `autoref` role when using single backticks. Allows automatic mapping to a cmd ref or a cell ref.
This commit is contained in:
parent
f9b4e04fef
commit
c0f9828b3c
2 changed files with 13 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
# based on https://github.com/ofosos/sphinxrecipes/blob/master/sphinxrecipes/sphinxrecipes.py
|
||||
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils.parsers.rst.states import Inliner
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.domains import Domain, Index
|
||||
from sphinx.domains.std import StandardDomain
|
||||
from sphinx.roles import XRefRole
|
||||
|
@ -228,7 +230,12 @@ class CellDomain(CommandDomain):
|
|||
TagIndex
|
||||
}
|
||||
|
||||
def setup(app):
|
||||
def autoref(name, rawtext, text, lineno, inliner: Inliner,
|
||||
options=None, content=None):
|
||||
role = 'cell:ref' if text[0] == '$' else 'cmd:ref'
|
||||
return inliner.interpreted(rawtext, text, role, lineno)
|
||||
|
||||
def setup(app: Sphinx):
|
||||
app.add_domain(CommandDomain)
|
||||
app.add_domain(CellDomain)
|
||||
|
||||
|
@ -249,5 +256,7 @@ def setup(app):
|
|||
('cell-cell', '')
|
||||
StandardDomain.initial_data['anonlabels']['tagindex'] =\
|
||||
('cell-tag', '')
|
||||
|
||||
app.add_role('autoref', autoref)
|
||||
|
||||
return {'version': '0.2'}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue