summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-09-25 09:02:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-09-25 09:16:54 +0200
commit5ed182ee7c8e10c652f177b6763b3bc83593a3ad (patch)
tree022b9eac524753ff4a0ab827d2de582ad84c6c17
parentconfig.yml: Fix documentation source paths (diff)
downloadrtems-central-5ed182ee7c8e10c652f177b6763b3bc83593a3ad.tar.bz2
rtemsspec: Fix interface formatting
-rw-r--r--rtemsspec/applconfig.py41
-rw-r--r--rtemsspec/interface.py2
-rw-r--r--rtemsspec/sphinxcontent.py42
-rw-r--r--rtemsspec/tests/test_interfacedoc.py3
4 files changed, 46 insertions, 42 deletions
diff --git a/rtemsspec/applconfig.py b/rtemsspec/applconfig.py
index 830b3222..81ea0996 100644
--- a/rtemsspec/applconfig.py
+++ b/rtemsspec/applconfig.py
@@ -351,34 +351,6 @@ def _get_value_sphinx_reference(ctx: ItemGetValueContext) -> Any:
return _SPHINX_DOC_REFS[ctx.key]
-def _get_value_sphinx_define(ctx: ItemGetValueContext) -> Any:
- return f":c:macro:`{ctx.value[ctx.key]}`"
-
-
-def _get_value_sphinx_function(ctx: ItemGetValueContext) -> Any:
- return f":c:func:`{ctx.value[ctx.key]}`"
-
-
-def _get_value_sphinx_type(ctx: ItemGetValueContext) -> Any:
- return f":c:type:`{ctx.value[ctx.key]}`"
-
-
-def _get_value_sphinx_url(ctx: ItemGetValueContext) -> Any:
- return f"`{ctx.value[ctx.key]} <{ctx.item['reference']}>`_"
-
-
-def _get_value_sphinx_unspecified_define(ctx: ItemGetValueContext) -> Any:
- if ctx.item["reference"]:
- return _get_value_sphinx_url(ctx)
- return _get_value_sphinx_define(ctx)
-
-
-def _get_value_sphinx_unspecified_type(ctx: ItemGetValueContext) -> Any:
- if ctx.item["reference"]:
- return _get_value_sphinx_url(ctx)
- return _get_value_sphinx_type(ctx)
-
-
def _add_sphinx_get_values(mapper: ItemMapper) -> None:
for key in _SPHINX_DOC_REFS:
for opt in ["feature-enable", "feature", "initializer", "integer"]:
@@ -386,19 +358,6 @@ def _add_sphinx_get_values(mapper: ItemMapper) -> None:
mapper.add_get_value(doc_ref, _get_value_none)
mapper.add_get_value(f"{doc_ref}/{key}",
_get_value_sphinx_reference)
- mapper.add_get_value("interface/define:/name", _get_value_sphinx_define)
- mapper.add_get_value("interface/function:/name",
- _get_value_sphinx_function)
- mapper.add_get_value("interface/macro:/name", _get_value_sphinx_function)
- mapper.add_get_value("interface/struct:/name", _get_value_sphinx_type)
- mapper.add_get_value("interface/typedef:/name", _get_value_sphinx_type)
- mapper.add_get_value("interface/union:/name", _get_value_sphinx_type)
- mapper.add_get_value("interface/unspecified-define:/name",
- _get_value_sphinx_unspecified_define)
- mapper.add_get_value("interface/unspecified-function:/name",
- _get_value_sphinx_function)
- mapper.add_get_value("interface/unspecified-type:/name",
- _get_value_sphinx_unspecified_type)
def _c_user_ref(ref: str, name: str) -> str:
diff --git a/rtemsspec/interface.py b/rtemsspec/interface.py
index 9bca0709..30d16d62 100644
--- a/rtemsspec/interface.py
+++ b/rtemsspec/interface.py
@@ -82,6 +82,8 @@ class _InterfaceMapper(ItemMapper):
for opt in ["feature-enable", "feature", "initializer", "integer"]:
name = f"interface/appl-config-option/{opt}:doc:/name"
self.add_get_value(name, get_value_hash)
+ self.add_get_value("interface/unspecified-function:doc:/name",
+ get_value_doxygen_function)
@contextmanager
def code(self) -> Iterator[None]:
diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py
index 914e2436..f9bafa7f 100644
--- a/rtemsspec/sphinxcontent.py
+++ b/rtemsspec/sphinxcontent.py
@@ -221,6 +221,34 @@ def _get_appl_config_option(ctx: ItemGetValueContext) -> Any:
return f":ref:`{ctx.value[ctx.key]}`"
+def _get_value_sphinx_macro(ctx: ItemGetValueContext) -> Any:
+ return f":c:macro:`{ctx.value[ctx.key]}`"
+
+
+def _get_value_sphinx_function(ctx: ItemGetValueContext) -> Any:
+ return f":c:func:`{ctx.value[ctx.key]}`"
+
+
+def _get_value_sphinx_type(ctx: ItemGetValueContext) -> Any:
+ return f":c:type:`{ctx.value[ctx.key]}`"
+
+
+def _get_value_sphinx_url(ctx: ItemGetValueContext) -> Any:
+ return f"`{ctx.value[ctx.key]} <{ctx.item['reference']}>`_"
+
+
+def _get_value_sphinx_unspecified_define(ctx: ItemGetValueContext) -> Any:
+ if ctx.item["reference"]:
+ return _get_value_sphinx_url(ctx)
+ return _get_value_sphinx_macro(ctx)
+
+
+def _get_value_sphinx_unspecified_type(ctx: ItemGetValueContext) -> Any:
+ if ctx.item["reference"]:
+ return _get_value_sphinx_url(ctx)
+ return _get_value_sphinx_type(ctx)
+
+
class SphinxMapper(ItemMapper):
""" Sphinx item mapper. """
def __init__(self, item: Item):
@@ -235,3 +263,17 @@ class SphinxMapper(ItemMapper):
_get_appl_config_option)
self.add_get_value("interface/appl-config-option/integer:/name",
_get_appl_config_option)
+ self.add_get_value("interface/define:/name", _get_value_sphinx_macro)
+ self.add_get_value("interface/enum:/name", _get_value_sphinx_type)
+ self.add_get_value("interface/function:/name",
+ _get_value_sphinx_function)
+ self.add_get_value("interface/macro:/name", _get_value_sphinx_function)
+ self.add_get_value("interface/struct:/name", _get_value_sphinx_type)
+ self.add_get_value("interface/typedef:/name", _get_value_sphinx_type)
+ self.add_get_value("interface/union:/name", _get_value_sphinx_type)
+ self.add_get_value("interface/unspecified-define:/name",
+ _get_value_sphinx_unspecified_define)
+ self.add_get_value("interface/unspecified-function:/name",
+ _get_value_sphinx_function)
+ self.add_get_value("interface/unspecified-type:/name",
+ _get_value_sphinx_unspecified_type)
diff --git a/rtemsspec/tests/test_interfacedoc.py b/rtemsspec/tests/test_interfacedoc.py
index 911fc42f..07dc8b14 100644
--- a/rtemsspec/tests/test_interfacedoc.py
+++ b/rtemsspec/tests/test_interfacedoc.py
@@ -217,7 +217,8 @@ DIRECTIVE PARAMETERS:
DESCRIPTION:
Function description. References to :ref:`InterfaceVeryLongFunction`,
- Integer, Enum, DEFINE, VERY_LONG_MACRO, Variable, ENUMERATOR_0, Struct,
+ :c:type:`Integer`, :c:type:`Enum`, :c:macro:`DEFINE`,
+ :c:func:`VERY_LONG_MACRO`, Variable, ENUMERATOR_0, :c:type:`Struct`,
:ref:`a`, and interface.
"""
assert content == src.read()