summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-05-05 14:41:19 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-05-08 21:58:56 +0200
commit6c1b70c760ede04552146df221afd895eae30f55 (patch)
tree6d8e5a4f163a8efd5e2bd980e575f3de7570497e
parentspec: Reorganize glossary (diff)
downloadrtems-central-6c1b70c760ede04552146df221afd895eae30f55.tar.bz2
applconfig: Add document_option()
-rw-r--r--rtemsspec/applconfig.py31
-rw-r--r--rtemsspec/tests/test_applconfig.py19
2 files changed, 40 insertions, 10 deletions
diff --git a/rtemsspec/applconfig.py b/rtemsspec/applconfig.py
index 1474a7f5..47bcb9d0 100644
--- a/rtemsspec/applconfig.py
+++ b/rtemsspec/applconfig.py
@@ -253,6 +253,27 @@ _OPTION_GENERATORS = {
}
+def _document_option(item: Item, enabled: List[str],
+ content: _ContentAdaptor) -> None:
+ option_type = item["appl-config-option-type"]
+ content.add_option_type(_OPTION_TYPES[option_type])
+ _OPTION_GENERATORS[option_type](content, item, option_type)
+ content.add_option_description(content.substitute(item["description"]))
+ content.add_option_notes(content.substitute(item["notes"]))
+ _generate_constraints(content, item, enabled)
+
+
+def document_option(item: Item, enabled: List[str],
+ mapper: ItemMapper) -> SphinxContent:
+ """
+ Documents the option specified by the item using the item mapper and
+ enabled set.
+ """
+ adaptor = _SphinxContentAdaptor(mapper)
+ _document_option(item, enabled, adaptor)
+ return adaptor.content
+
+
def _generate(group: Item, options: ItemMap, enabled: List[str],
content: _ContentAdaptor) -> None:
content.register_license_and_copyrights_of_item(group)
@@ -260,15 +281,9 @@ def _generate(group: Item, options: ItemMap, enabled: List[str],
content.substitute(group["description"]))
for item in sorted(options.values(), key=lambda x: x["name"]):
content.mapper.item = item
- name = item["name"]
content.register_license_and_copyrights_of_item(item)
- content.add_option(item.uid, name, item["index-entries"])
- option_type = item["appl-config-option-type"]
- content.add_option_type(_OPTION_TYPES[option_type])
- _OPTION_GENERATORS[option_type](content, item, option_type)
- content.add_option_description(content.substitute(item["description"]))
- content.add_option_notes(content.substitute(item["notes"]))
- _generate_constraints(content, item, enabled)
+ content.add_option(item.uid, item["name"], item["index-entries"])
+ _document_option(item, enabled, content)
content.add_licence_and_copyrights()
diff --git a/rtemsspec/tests/test_applconfig.py b/rtemsspec/tests/test_applconfig.py
index 5135cd5f..fc9172d2 100644
--- a/rtemsspec/tests/test_applconfig.py
+++ b/rtemsspec/tests/test_applconfig.py
@@ -26,8 +26,8 @@
import os
-from rtemsspec.applconfig import generate
-from rtemsspec.items import ItemCache
+from rtemsspec.applconfig import document_option, generate
+from rtemsspec.items import ItemCache, ItemMapper
from rtemsspec.tests.util import create_item_cache_config_and_copy_spec
@@ -723,3 +723,18 @@ description m
/** @} */
"""
assert content == src.read()
+ option_item = item_cache["/k"]
+ option_content = document_option(option_item, [],
+ ItemMapper(option_item))
+ assert str(option_content) == """.. rubric:: OPTION TYPE:
+
+This configuration option is an integer define.
+
+.. rubric:: DEFAULT VALUE:
+
+The default value is 1.
+
+.. rubric:: DESCRIPTION:
+
+description k
+"""