From a89a5c6a09b10bcc5845bda00b20b3d78adb6930 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 6 Aug 2020 10:23:27 +0200 Subject: content: Improve CContent.doxyfy() Add replacement for :file:`xyz`. --- rtemsspec/content.py | 3 +++ rtemsspec/tests/test_content_c.py | 4 ++++ 2 files changed, 7 insertions(+) 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(): -- cgit v1.2.3