[rtems-central commit] content: Improve CContent.doxyfy()

Sebastian Huber sebh at rtems.org
Thu Aug 6 13:08:54 UTC 2020


Module:    rtems-central
Branch:    master
Commit:    a89a5c6a09b10bcc5845bda00b20b3d78adb6930
Changeset: http://git.rtems.org/rtems-central/commit/?id=a89a5c6a09b10bcc5845bda00b20b3d78adb6930

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Aug  6 10:23:27 2020 +0200

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 30a1a81..1015424 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 81f1572..f1bbf30 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():



More information about the vc mailing list