[rtems-central commit] glossary: Find term plurals

Sebastian Huber sebh at rtems.org
Mon Oct 26 13:09:22 UTC 2020


Module:    rtems-central
Branch:    master
Commit:    7ceb7cac4ea3fae87fc514e9bc7e18aa88bacb49
Changeset: http://git.rtems.org/rtems-central/commit/?id=7ceb7cac4ea3fae87fc514e9bc7e18aa88bacb49

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Oct 26 13:52:43 2020 +0100

glossary: Find term plurals

---

 rtemsspec/glossary.py                 | 9 ++++++++-
 rtemsspec/tests/spec-glossary/doc.rst | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/rtemsspec/glossary.py b/rtemsspec/glossary.py
index bb0bf49..0ac150e 100644
--- a/rtemsspec/glossary.py
+++ b/rtemsspec/glossary.py
@@ -64,13 +64,20 @@ def _generate_glossary_content(terms: ItemMap) -> SphinxContent:
     return content
 
 
+_TERM = re.compile(r":term:`([^`]+)`")
+_TERM_2 = re.compile(r"^[^<]+<([^>]+)>")
+
+
 def _find_glossary_terms(path: str, document_terms: ItemMap,
                          glossary: _Glossary) -> None:
     for src in glob.glob(path + "/**/*.rst", recursive=True):
         if src.endswith("glossary.rst"):
             continue
         with open(src, "r") as out:
-            for term in re.findall(":term:`([^`]+)`", out.read()):
+            for term in _TERM.findall(out.read()):
+                match = _TERM_2.search(term)
+                if match:
+                    term = match.group(1)
                 item = glossary.term_to_item[term]
                 document_terms[item.uid] = item
 
diff --git a/rtemsspec/tests/spec-glossary/doc.rst b/rtemsspec/tests/spec-glossary/doc.rst
index e07b9a3..b86ed6c 100644
--- a/rtemsspec/tests/spec-glossary/doc.rst
+++ b/rtemsspec/tests/spec-glossary/doc.rst
@@ -1 +1,2 @@
 :term:`T`
+:term:`Ts <T>`



More information about the vc mailing list