From 718f1b53f7fee6f23870ccc3d598d95f253a7860 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 10 Feb 2021 10:55:05 +0100 Subject: interface: Support glossary plurals --- rtemsspec/interface.py | 8 ++++++++ rtemsspec/tests/spec-interface/func.yml | 4 ++-- rtemsspec/tests/spec-interface/term.yml | 4 ++++ rtemsspec/tests/test_interface.py | 4 ++-- rtemsspec/tests/test_interfacedoc.py | 10 +++++----- 5 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 rtemsspec/tests/spec-interface/term.yml (limited to 'rtemsspec') 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 `, +: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: -- cgit v1.2.3