mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-03 04:41:22 +00:00
Docs: Option lists have yoscrypt highlights
This commit is contained in:
parent
d1d419cb51
commit
07b6a35553
2 changed files with 16 additions and 3 deletions
|
@ -18,3 +18,8 @@
|
||||||
.literal-block-wrapper .code-block-caption .caption-number {
|
.literal-block-wrapper .code-block-caption .caption-number {
|
||||||
padding-right: 0.5em
|
padding-right: 0.5em
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Don't double shrink text in a literal in an optionlist */
|
||||||
|
kbd .option>.literal {
|
||||||
|
font-size: revert;
|
||||||
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ from sphinx.application import Sphinx
|
||||||
from sphinx.domains import Domain, Index
|
from sphinx.domains import Domain, Index
|
||||||
from sphinx.domains.std import StandardDomain
|
from sphinx.domains.std import StandardDomain
|
||||||
from sphinx.environment import BuildEnvironment
|
from sphinx.environment import BuildEnvironment
|
||||||
from sphinx.roles import XRefRole
|
from sphinx.roles import XRefRole, SphinxRole
|
||||||
from sphinx.directives import ObjectDescription
|
from sphinx.directives import ObjectDescription
|
||||||
from sphinx.directives.code import container_wrapper
|
from sphinx.directives.code import container_wrapper
|
||||||
from sphinx.util.nodes import make_refnode
|
from sphinx.util.nodes import make_refnode
|
||||||
|
@ -155,7 +155,7 @@ class CommandOptionGroupNode(CommandUsageNode):
|
||||||
]
|
]
|
||||||
|
|
||||||
def transform_content(self, contentnode: addnodes.desc_content) -> None:
|
def transform_content(self, contentnode: addnodes.desc_content) -> None:
|
||||||
"""hack `:option -thing: desc` into a proper option list"""
|
"""hack `:option -thing: desc` into a proper option list with yoscrypt highlighting"""
|
||||||
newchildren = []
|
newchildren = []
|
||||||
for node in contentnode:
|
for node in contentnode:
|
||||||
newnode = node
|
newnode = node
|
||||||
|
@ -172,7 +172,10 @@ class CommandOptionGroupNode(CommandUsageNode):
|
||||||
option_group += option
|
option_group += option
|
||||||
name, text = child.rawsource.split(' ', 1)
|
name, text = child.rawsource.split(' ', 1)
|
||||||
is_option = name == 'option'
|
is_option = name == 'option'
|
||||||
option += nodes.option_string(text=text)
|
literal = nodes.literal(text=text)
|
||||||
|
literal['classes'] += ['code', 'highlight', 'yoscrypt']
|
||||||
|
literal['language'] = 'yoscrypt'
|
||||||
|
option += literal
|
||||||
if not is_option: warnings.warn(f'unexpected option \'{name}\' in {field.source}')
|
if not is_option: warnings.warn(f'unexpected option \'{name}\' in {field.source}')
|
||||||
elif isinstance(child, nodes.field_body):
|
elif isinstance(child, nodes.field_body):
|
||||||
description = nodes.description()
|
description = nodes.description()
|
||||||
|
@ -601,6 +604,10 @@ class TitleRefRole(XRefRole):
|
||||||
"""XRefRole used which has the cmd title as the displayed text."""
|
"""XRefRole used which has the cmd title as the displayed text."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class OptionRole(SphinxRole):
|
||||||
|
def run(self) -> tuple[list[Node], list]:
|
||||||
|
return self.inliner.interpreted(self.rawtext, self.text, 'yoscrypt', self.lineno)
|
||||||
|
|
||||||
class CommandDomain(Domain):
|
class CommandDomain(Domain):
|
||||||
name = 'cmd'
|
name = 'cmd'
|
||||||
label = 'Yosys commands'
|
label = 'Yosys commands'
|
||||||
|
@ -608,6 +615,7 @@ class CommandDomain(Domain):
|
||||||
roles = {
|
roles = {
|
||||||
'ref': XRefRole(),
|
'ref': XRefRole(),
|
||||||
'title': TitleRefRole(),
|
'title': TitleRefRole(),
|
||||||
|
'option': OptionRole(),
|
||||||
}
|
}
|
||||||
|
|
||||||
directives = {
|
directives = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue