summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-10-26 13:54:43 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-10-26 14:05:39 +0100
commit4fe26dc8759fd8cd71c86c20ee594768f01bd222 (patch)
tree226102506bff17c4c9b08c94187c9e954747dcdb
parentglossary: Find term plurals (diff)
downloadrtems-central-4fe26dc8759fd8cd71c86c20ee594768f01bd222.tar.bz2
glossary: Support custom glossary headers
-rw-r--r--config.yml4
-rw-r--r--rtemsspec/glossary.py20
-rw-r--r--rtemsspec/tests/test_glossary.py6
3 files changed, 18 insertions, 12 deletions
diff --git a/config.yml b/config.yml
index 07684cd2..b9257dd6 100644
--- a/config.yml
+++ b/config.yml
@@ -52,9 +52,11 @@ spec:
glossary:
project-groups:
- /glossary-general
+ project-header: Glossary
project-target: modules/rtems-docs/c-user/glossary.rst
documents:
- - rest-source-paths:
+ - header: Glossary
+ rest-source-paths:
- modules/rtems-docs/eng
target: modules/rtems-docs/eng/glossary.rst
appl-config:
diff --git a/rtemsspec/glossary.py b/rtemsspec/glossary.py
index 0ac150e2..1a7a18cf 100644
--- a/rtemsspec/glossary.py
+++ b/rtemsspec/glossary.py
@@ -50,9 +50,10 @@ def _gather_glossary_terms(item: Item, glossary: _Glossary) -> None:
glossary.term_to_item[term] = item
-def _generate_glossary_content(terms: ItemMap) -> SphinxContent:
+def _generate_glossary_content(terms: ItemMap, header: str,
+ target: str) -> None:
content = SphinxContent()
- content.add_header("Glossary", level=1)
+ content.add_header(header, level=1)
content.add(".. glossary::")
with content.indent():
content.add(":sorted:")
@@ -61,7 +62,7 @@ def _generate_glossary_content(terms: ItemMap) -> SphinxContent:
text = SphinxMapper(item).substitute(item["text"])
content.add_definition_item(item["term"], text)
content.add_licence_and_copyrights()
- return content
+ content.write(target)
_TERM = re.compile(r":term:`([^`]+)`")
@@ -103,9 +104,9 @@ def _resolve_glossary_terms(document_terms: ItemMap) -> None:
_GlossaryMapper(term, document_terms).substitute(term["text"])
-def _generate_project_glossary(target: str, glossary: _Glossary) -> None:
- content = _generate_glossary_content(glossary.uid_to_item)
- content.write(target)
+def _generate_project_glossary(glossary: _Glossary, header: str,
+ target: str) -> None:
+ _generate_glossary_content(glossary.uid_to_item, header, target)
def _generate_document_glossary(config: dict, glossary: _Glossary) -> None:
@@ -113,8 +114,8 @@ def _generate_document_glossary(config: dict, glossary: _Glossary) -> None:
for path in config["rest-source-paths"]:
_find_glossary_terms(path, document_terms, glossary)
_resolve_glossary_terms(document_terms)
- content = _generate_glossary_content(document_terms)
- content.write(config["target"])
+ _generate_glossary_content(document_terms, config["header"],
+ config["target"])
def generate(config: dict, item_cache: ItemCache) -> None:
@@ -134,7 +135,8 @@ def generate(config: dict, item_cache: ItemCache) -> None:
for group in config["project-groups"]:
_gather_glossary_terms(groups[group], project_glossary)
- _generate_project_glossary(config["project-target"], project_glossary)
+ _generate_project_glossary(project_glossary, config["project-header"],
+ config["project-target"])
for document_config in config["documents"]:
_generate_document_glossary(document_config, project_glossary)
diff --git a/rtemsspec/tests/test_glossary.py b/rtemsspec/tests/test_glossary.py
index 2682b5da..030e215b 100644
--- a/rtemsspec/tests/test_glossary.py
+++ b/rtemsspec/tests/test_glossary.py
@@ -38,9 +38,11 @@ def test_glossary(tmpdir):
glossary_config = {}
glossary_config["project-groups"] = ["/g"]
+ glossary_config["project-header"] = "Project Glossary"
project_glossary = os.path.join(tmpdir, "project", "glossary.rst")
glossary_config["project-target"] = project_glossary
doc = {}
+ doc["header"] = "Glossary"
doc["rest-source-paths"] = [str(tmpdir)]
document_glossary = os.path.join(tmpdir, "document", "glossary.rst")
doc["target"] = document_glossary
@@ -52,8 +54,8 @@ def test_glossary(tmpdir):
.. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
-Glossary
-********
+Project Glossary
+****************
.. glossary::
:sorted: