diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-06 10:23:27 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-06 14:10:06 +0200 |
commit | a89a5c6a09b10bcc5845bda00b20b3d78adb6930 (patch) | |
tree | 900a55b98ad4c56ab05eef76b5aca96477352228 /rtemsspec | |
parent | spec: Add more unspecified interfaces (diff) | |
download | rtems-central-a89a5c6a09b10bcc5845bda00b20b3d78adb6930.tar.bz2 |
content: Improve CContent.doxyfy()
Add replacement for :file:`xyz`.
Diffstat (limited to 'rtemsspec')
-rw-r--r-- | rtemsspec/content.py | 3 | ||||
-rw-r--r-- | rtemsspec/tests/test_content_c.py | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/rtemsspec/content.py b/rtemsspec/content.py index 30a1a81d..1015424c 100644 --- a/rtemsspec/content.py +++ b/rtemsspec/content.py @@ -480,6 +480,7 @@ def _align_params(params: List[str]) -> List[str]: _NOT_ALPHANUM = re.compile(r"[^a-zA-Z0-9_]") +_SPHINX_FILE_TO_DOXYGEN = re.compile(r":file:`([^`]+)`") class CContent(Content): @@ -508,6 +509,8 @@ class CContent(Content): blocks = collections.deque(text.split("\n\n")) while blocks: block = blocks.popleft() + block = _SPHINX_FILE_TO_DOXYGEN.sub( + lambda match: f"``{match.group(1)}``", block) if block.startswith(".. code-block"): self.add("@code") self.gap = False diff --git a/rtemsspec/tests/test_content_c.py b/rtemsspec/tests/test_content_c.py index 81f15727..f1bbf303 100644 --- a/rtemsspec/tests/test_content_c.py +++ b/rtemsspec/tests/test_content_c.py @@ -60,6 +60,10 @@ ghi @code @endcode """ + content = CContent() + content.doxyfy(":file:`abc`") + assert str(content) == """``abc`` +""" def test_add_have_config(): |