summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-12-01 13:23:45 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-12-01 13:48:07 +0100
commit7b864b7c9d9e7b35c79e78d50e836014b2a953c3 (patch)
tree336c1069b0f0eeb70434a31d6fe3e787b577666a
parentFormat specification items (diff)
downloadrtems-central-7b864b7c9d9e7b35c79e78d50e836014b2a953c3.tar.bz2
glossary: Use ItemMapper.add_get_value()
-rw-r--r--rtemsspec/glossary.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/rtemsspec/glossary.py b/rtemsspec/glossary.py
index 21a39e89..64fcbc6b 100644
--- a/rtemsspec/glossary.py
+++ b/rtemsspec/glossary.py
@@ -87,14 +87,14 @@ class _GlossaryMapper(ItemMapper):
def __init__(self, item: Item, document_terms: ItemMap):
super().__init__(item)
self._document_terms = document_terms
-
- def get_value(self, ctx: ItemGetValueContext) -> Any:
- """ Recursively adds glossary terms to the document terms. """
- if ctx.type_path_key == "glossary/term:/term":
- if ctx.item.uid not in self._document_terms:
- self._document_terms[ctx.item.uid] = ctx.item
- _GlossaryMapper(ctx.item, self._document_terms).substitute(
- ctx.item["text"])
+ self.add_get_value("glossary/term:/term", self._add_to_terms)
+ self.add_get_value("glossary/term:/plural", self._add_to_terms)
+
+ def _add_to_terms(self, ctx: ItemGetValueContext) -> Any:
+ if ctx.item.uid not in self._document_terms:
+ self._document_terms[ctx.item.uid] = ctx.item
+ _GlossaryMapper(ctx.item,
+ self._document_terms).substitute(ctx.item["text"])
# The value of this substitute is unused.
return ""