[rtems-central commit] specdoc: Make section texts configurable

Sebastian Huber sebh at rtems.org
Fri Sep 18 11:31:55 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jul 16 13:07:38 2020 +0200

specdoc: Make section texts configurable

---

 config.yml                      | 10 ++++++++--
 rtemsspec/specdoc.py            | 13 ++++++-------
 rtemsspec/tests/test_specdoc.py | 21 ++++++++++++++++++---
 3 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/config.yml b/config.yml
index cf188b0..d6d93df 100644
--- a/config.yml
+++ b/config.yml
@@ -98,6 +98,12 @@ interface-documentation:
 spec-verification:
   root-type: /spec/root
 spec-documentation:
-  root-type: /spec/root
   doc-target: modules/rtems-docs/eng/req/items.rst
-  label-prefix: SpecType
+  hierarchy-subsection-name: Specification Item Hierarchy
+  hierarchy-text: |
+    The specification item types have the following hierarchy:
+  item-types-subsection-name: Specification Item Types
+  root-type: /spec/root
+  section-label-prefix: ReqEng
+  section-name: Specification Items
+  value-types-subsection-name: Specification Attribute Sets and Value Types
diff --git a/rtemsspec/specdoc.py b/rtemsspec/specdoc.py
index 823a7d5..7ab38fe 100644
--- a/rtemsspec/specdoc.py
+++ b/rtemsspec/specdoc.py
@@ -558,15 +558,14 @@ def document(config: dict, item_cache: ItemCache) -> None:
     for documenter in documenter_map.values():
         documenter.resolve_used_by()
     documenter_names = set(documenter_map)
-    content.section_label_prefix = "ReqEng"
-    with content.section("Specification Items"):
-        with content.section("Specification Item Hierarchy"):
-            content.add(
-                "The specification item types have the following hierarchy:")
+    content.section_label_prefix = config["section-label-prefix"]
+    with content.section(config["section-name"]):
+        with content.section(config["hierarchy-subsection-name"]):
+            content.add(config["hierarchy-text"])
             root_documenter.hierarchy(content)
-        with content.section("Specification Item Types"):
+        with content.section(config["item-types-subsection-name"]):
             root_documenter.document(content, documenter_names)
-        with content.section("Specification Attribute Sets and Value Types"):
+        with content.section(config["value-types-subsection-name"]):
             documenters = [documenter_map[name] for name in documenter_names]
             for documenter in sorted(documenters, key=lambda x: x.section):
                 documenter.document(content)
diff --git a/rtemsspec/tests/test_specdoc.py b/rtemsspec/tests/test_specdoc.py
index 0a3d294..1c0ae58 100644
--- a/rtemsspec/tests/test_specdoc.py
+++ b/rtemsspec/tests/test_specdoc.py
@@ -39,9 +39,24 @@ def test_document(tmpdir):
     assert item_cache["/root"].type == "spec"
     doc_target = os.path.join(tmpdir, "items.rst")
     config = {
-        "root-type": "/root",
-        "doc-target": doc_target,
-        "label-prefix": "SpecType",
+        "doc-target":
+        doc_target,
+        "hierarchy-subsection-name":
+        "Specification Item Hierarchy",
+        "hierarchy-text":
+        "The specification item types have the following hierarchy:",
+        "item-types-subsection-name":
+        "Specification Item Types",
+        "label-prefix":
+        "SpecType",
+        "root-type":
+        "/root",
+        "section-label-prefix":
+        "ReqEng",
+        "section-name":
+        "Specification Items",
+        "value-types-subsection-name":
+        "Specification Attribute Sets and Value Types",
     }
     document(config, item_cache)
     with open(doc_target, "r") as src:



More information about the vc mailing list