summaryrefslogtreecommitdiffstats
path: root/rtemsspec
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-02-10 10:55:05 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-02-10 15:55:50 +0100
commit718f1b53f7fee6f23870ccc3d598d95f253a7860 (patch)
treefdc6f95574b084a5191797eb07786daf1060fd80 /rtemsspec
parentinterfacedoc: Substitute brief descriptions (diff)
downloadrtems-central-718f1b53f7fee6f23870ccc3d598d95f253a7860.tar.bz2
interface: Support glossary plurals
Diffstat (limited to 'rtemsspec')
-rw-r--r--rtemsspec/interface.py8
-rw-r--r--rtemsspec/tests/spec-interface/func.yml4
-rw-r--r--rtemsspec/tests/spec-interface/term.yml4
-rw-r--r--rtemsspec/tests/test_interface.py4
-rw-r--r--rtemsspec/tests/test_interfacedoc.py10
5 files changed, 21 insertions, 9 deletions
diff --git a/rtemsspec/interface.py b/rtemsspec/interface.py
index e8816468..daf2fb4a 100644
--- a/rtemsspec/interface.py
+++ b/rtemsspec/interface.py
@@ -63,11 +63,19 @@ def _get_value_params(ctx: ItemGetValueContext) -> Any:
return f"``{ctx.value[ctx.key]}``"
+def _get_value_plural(ctx: ItemGetValueContext) -> Any:
+ try:
+ return ctx.value[ctx.key]
+ except KeyError:
+ return f"{ctx.value['term']}s"
+
+
class _InterfaceMapper(ItemMapper):
def __init__(self, node: "Node"):
super().__init__(node.item)
self._node = node
self._code_or_doc = "doc"
+ self.add_get_value("glossary/term/doc:/plural", _get_value_plural)
self.add_get_value("interface/forward-declaration/code:/name",
_get_value_forward_declaration)
self.add_get_value("interface/forward-declaration/doc:/name",
diff --git a/rtemsspec/tests/spec-interface/func.yml b/rtemsspec/tests/spec-interface/func.yml
index f12bbe2d..aeb15df5 100644
--- a/rtemsspec/tests/spec-interface/func.yml
+++ b/rtemsspec/tests/spec-interface/func.yml
@@ -15,8 +15,8 @@ definition:
return: void
variants: []
description: |
- Function description. References to ${func2:/name}, ${td:/name},
- ${enum:/name}, ${define:/name}, ${macro:/name}, ${var:/name},
+ Function description. References to ${term:/plural}, ${func2:/name},
+ ${td:/name}, ${enum:/name}, ${define:/name}, ${macro:/name}, ${var:/name},
${enumerator-0:/name}, ${s:/name}, ${option:/name}, ${option:/type},
${ga:/name}, and ${gf:/name}. Second parameter is ${.:/params[1]/name}.
diff --git a/rtemsspec/tests/spec-interface/term.yml b/rtemsspec/tests/spec-interface/term.yml
new file mode 100644
index 00000000..7bfa4124
--- /dev/null
+++ b/rtemsspec/tests/spec-interface/term.yml
@@ -0,0 +1,4 @@
+term: x
+glossary-type: term
+links: []
+type: glossary
diff --git a/rtemsspec/tests/test_interface.py b/rtemsspec/tests/test_interface.py
index 4d05d3a2..b7b0feea 100644
--- a/rtemsspec/tests/test_interface.py
+++ b/rtemsspec/tests/test_interface.py
@@ -215,8 +215,8 @@ typedef enum EnumB {
*
* @param[in,out] Param3 is parameter 3.
*
- * Function description. References to VeryLongFunction(), ::Integer, #Enum,
- * #DEFINE, VERY_LONG_MACRO(), #Variable, ::ENUMERATOR_0, Struct, #a,
+ * Function description. References to xs, VeryLongFunction(), ::Integer,
+ * #Enum, #DEFINE, VERY_LONG_MACRO(), #Variable, ::ENUMERATOR_0, Struct, #a,
* interface, @ref GroupA, and @ref GroupF. Second parameter is ``Param1``.
*
* @code
diff --git a/rtemsspec/tests/test_interfacedoc.py b/rtemsspec/tests/test_interfacedoc.py
index d079ef16..07e96bc8 100644
--- a/rtemsspec/tests/test_interfacedoc.py
+++ b/rtemsspec/tests/test_interfacedoc.py
@@ -457,11 +457,11 @@ Function brief description.
.. rubric:: DESCRIPTION:
-Function description. References to :ref:`InterfaceVeryLongFunction`,
-:c:type:`Integer`, :c:type:`Enum`, :c:macro:`DEFINE`,
-:ref:`InterfaceVERYLONGMACRO`, Variable, :c:macro:`ENUMERATOR_0`,
-:c:type:`Struct`, :ref:`a`, interface, :ref:`GroupA`, and Group F. Second
-parameter is ``Param1``.
+Function description. References to :term:`xs <x>`,
+:ref:`InterfaceVeryLongFunction`, :c:type:`Integer`, :c:type:`Enum`,
+:c:macro:`DEFINE`, :ref:`InterfaceVERYLONGMACRO`, Variable,
+:c:macro:`ENUMERATOR_0`, :c:type:`Struct`, :ref:`a`, interface, :ref:`GroupA`,
+and Group F. Second parameter is ``Param1``.
.. code-block: