From ea0906c9ee40d475ef0fe0cc841b363287c8933c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 1 Jun 2020 14:00:29 +0200 Subject: sphinxcontent: Support glossary term plurals --- rtemsqual/sphinxcontent.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'rtemsqual/sphinxcontent.py') diff --git a/rtemsqual/sphinxcontent.py b/rtemsqual/sphinxcontent.py index c29586f3..55f5beed 100644 --- a/rtemsqual/sphinxcontent.py +++ b/rtemsqual/sphinxcontent.py @@ -202,12 +202,20 @@ def _get_ref_term(value: Any, key: str) -> str: return f":term:`{value[key]}`" +def _get_ref_term_plural(value: Any, key: str) -> str: + try: + return f":term:`{value[key]} <{value['term']}>`" + except KeyError: + return f":term:`{value['term']}s <{value['term']}>`" + + class SphinxMapper(ItemMapper): """ Sphinx mapper. """ def __init__(self, item: Item): super().__init__(item) self._get_ref = { - "glossary:/term": _get_ref_term + "glossary:/term": _get_ref_term, + "glossary:/plural": _get_ref_term_plural } # type: Dict[str, Callable[[Any, str], str]] def add_get_reference(self, type_name: str, path: str, -- cgit v1.2.3