mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-25 10:05:33 +00:00
cmdref: codeblock language now works
Add `options` map for setting `ContentListing` options with key:val pairs; currently only used with `ContentListing::codeblock()` language arg. Fix generated codeblock rst to print each line of code with indentation, and change it to use explicit an `code-block` so we can set a language on it.
This commit is contained in:
parent
fb944ca0fb
commit
b1c9097a12
4 changed files with 17 additions and 5 deletions
|
@ -28,6 +28,7 @@ class YosysCmdContentListing:
|
|||
body: str
|
||||
source_file: str
|
||||
source_line: int
|
||||
options: dict[str, str]
|
||||
content: list[YosysCmdContentListing]
|
||||
|
||||
def __init__(
|
||||
|
@ -36,12 +37,14 @@ class YosysCmdContentListing:
|
|||
body: str = "",
|
||||
source_file: str = "unknown",
|
||||
source_line: int = 0,
|
||||
options: dict[str, str] = {},
|
||||
content: list[dict[str]] = [],
|
||||
):
|
||||
self.type = type
|
||||
self.body = body
|
||||
self.source_file = source_file
|
||||
self.source_line = source_line
|
||||
self.options = options
|
||||
self.content = [YosysCmdContentListing(**c) for c in content]
|
||||
|
||||
class YosysCmd:
|
||||
|
@ -375,9 +378,11 @@ class YosysCmdDocumenter(YosysCmdGroupDocumenter):
|
|||
self.add_line(f'{indent_str}{content_list.body}', content_source)
|
||||
self.add_line('', source_name)
|
||||
elif content_list.type == 'code':
|
||||
self.add_line(f'{indent_str}::', source_name)
|
||||
language_str = content_list.options.get('language', '')
|
||||
self.add_line(f'{indent_str}.. code-block:: {language_str}', source_name)
|
||||
self.add_line('', source_name)
|
||||
self.add_line(f'{indent_str} {content_list.body}', content_source)
|
||||
for body_line in content_list.body.splitlines():
|
||||
self.add_line(f'{indent_str} {body_line}', content_source)
|
||||
self.add_line('', source_name)
|
||||
else:
|
||||
logger.warning(f"unknown content type '{content_list.type}'")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue