[rtems-central commit] applconfig: Add "Generated from ..." comments

Sebastian Huber sebh at rtems.org
Thu Oct 8 13:25:41 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Oct  7 11:36:35 2020 +0200

applconfig: Add "Generated from ..." comments

---

 rtemsspec/applconfig.py            | 19 ++++++++++-----
 rtemsspec/tests/test_applconfig.py | 48 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/rtemsspec/applconfig.py b/rtemsspec/applconfig.py
index 81ea099..51f5736 100644
--- a/rtemsspec/applconfig.py
+++ b/rtemsspec/applconfig.py
@@ -68,14 +68,17 @@ class _ContentAdaptor:
         """ Substitutes the optional text using the item mapper. """
         return self.mapper.substitute(text)
 
-    def add_group(self, name: str, description: str) -> None:
+    def add_group(self, uid: str, name: str, description: str) -> None:
         """ Adds an option group. """
         self.content.add_automatically_generated_warning()
+        self.content.add(f".. Generated from spec:{uid}")
         self.content.add_header(name, level=2)
         self.content.add(description)
 
-    def add_option(self, name: str, index_entries: List[str]) -> None:
+    def add_option(self, uid: str, name: str,
+                   index_entries: List[str]) -> None:
         """ Adds an option. """
+        self.content.add(f".. Generated from spec:{uid}")
         self.content.add_index_entries([name] + index_entries)
         self.content.add_label(name)
         self.content.add_header(name, level=3)
@@ -140,14 +143,17 @@ class _DoxygenContentAdaptor(_ContentAdaptor):
         self._value_constraints = []  # type: List[str]
         self._description = ""
 
-    def add_group(self, name: str, description: str) -> None:
+    def add_group(self, uid: str, name: str, description: str) -> None:
         identifier = f"RTEMSApplConfig{name.replace(' ', '')}"
+        self.content.add(f"/* Generated from spec:{uid} */")
         with self.content.defgroup_block(identifier, name):
             self.content.add("@ingroup RTEMSApplConfig")
             self.content.doxyfy(description)
             self.content.add("@{")
 
-    def add_option(self, name: str, _index_entries: List[str]) -> None:
+    def add_option(self, uid: str, name: str,
+                   _index_entries: List[str]) -> None:
+        self.content.add(f"/* Generated from spec:{uid} */")
         self.content.open_doxygen_block()
         self._name = name
 
@@ -300,12 +306,13 @@ _OPTION_GENERATORS = {
 
 def _generate(group: Item, options: ItemMap, content: _ContentAdaptor) -> None:
     content.register_license_and_copyrights_of_item(group)
-    content.add_group(group["name"], content.substitute(group["description"]))
+    content.add_group(group.uid, group["name"],
+                      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(name, item["index-entries"])
+        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)
diff --git a/rtemsspec/tests/test_applconfig.py b/rtemsspec/tests/test_applconfig.py
index c7fb9f6..3a3fca5 100644
--- a/rtemsspec/tests/test_applconfig.py
+++ b/rtemsspec/tests/test_applconfig.py
@@ -60,11 +60,15 @@ def test_applconfig(tmpdir):
 ..
 .. https://docs.rtems.org/branches/master/eng/req/howto.html
 
+.. Generated from spec:/g
+
 group name
 ==========
 
 description
 
+.. Generated from spec:/a
+
 .. index:: a
 .. index:: index a
 
@@ -108,6 +112,8 @@ NOTES:
 
     * `unspec_type_2 <https://bar>`_
 
+.. Generated from spec:/b
+
 .. index:: b
 
 .. _b:
@@ -132,6 +138,8 @@ DESCRIPTION:
 NOTES:
     None.
 
+.. Generated from spec:/c
+
 .. index:: c
 
 .. _c:
@@ -168,6 +176,8 @@ DESCRIPTION:
 NOTES:
     notes c
 
+.. Generated from spec:/e
+
 .. index:: e
 
 .. _e:
@@ -194,6 +204,8 @@ DESCRIPTION:
 NOTES:
     None.
 
+.. Generated from spec:/f
+
 .. index:: f
 
 .. _f:
@@ -219,6 +231,8 @@ DESCRIPTION:
 NOTES:
     None.
 
+.. Generated from spec:/h
+
 .. index:: h
 
 .. _h:
@@ -244,6 +258,8 @@ DESCRIPTION:
 NOTES:
     None.
 
+.. Generated from spec:/i
+
 .. index:: i
 
 .. _i:
@@ -270,6 +286,8 @@ DESCRIPTION:
 NOTES:
     None.
 
+.. Generated from spec:/j
+
 .. index:: j
 
 .. _j:
@@ -300,6 +318,8 @@ DESCRIPTION:
 NOTES:
     None.
 
+.. Generated from spec:/k
+
 .. index:: k
 
 .. _k:
@@ -330,6 +350,8 @@ DESCRIPTION:
 NOTES:
     None.
 
+.. Generated from spec:/l
+
 .. index:: l
 
 .. _l:
@@ -356,6 +378,8 @@ DESCRIPTION:
 NOTES:
     None.
 
+.. Generated from spec:/m
+
 .. index:: m
 
 .. _m:
@@ -427,6 +451,8 @@ NOTES:
  * @ingroup RTEMSAPI
  */
 
+/* Generated from spec:/g */
+
 /**
  * @defgroup RTEMSApplConfiggroupname group name
  *
@@ -437,6 +463,8 @@ NOTES:
  * @{
  */
 
+/* Generated from spec:/a */
+
 /**
  * @brief This configuration option is a boolean feature define.
  *
@@ -474,6 +502,8 @@ NOTES:
  */
 #define a
 
+/* Generated from spec:/b */
+
 /**
  * @brief This configuration option is a boolean feature define.
  *
@@ -485,6 +515,8 @@ NOTES:
  */
 #define b
 
+/* Generated from spec:/c */
+
 /**
  * @brief This configuration option is an integer define.
  *
@@ -514,6 +546,8 @@ NOTES:
  */
 #define c
 
+/* Generated from spec:/e */
+
 /**
  * @brief This configuration option is an integer define.
  *
@@ -527,6 +561,8 @@ NOTES:
  */
 #define e
 
+/* Generated from spec:/f */
+
 /**
  * @brief This configuration option is an integer define.
  *
@@ -540,6 +576,8 @@ NOTES:
  */
 #define f
 
+/* Generated from spec:/h */
+
 /**
  * @brief This configuration option is an integer define.
  *
@@ -553,6 +591,8 @@ NOTES:
  */
 #define h
 
+/* Generated from spec:/i */
+
 /**
  * @brief This configuration option is an integer define.
  *
@@ -566,6 +606,8 @@ NOTES:
  */
 #define i
 
+/* Generated from spec:/j */
+
 /**
  * @brief This configuration option is an integer define.
  *
@@ -586,6 +628,8 @@ NOTES:
  */
 #define j
 
+/* Generated from spec:/k */
+
 /**
  * @brief This configuration option is an integer define.
  *
@@ -606,6 +650,8 @@ NOTES:
  */
 #define k
 
+/* Generated from spec:/l */
+
 /**
  * @brief This configuration option is an initializer define.
  *
@@ -620,6 +666,8 @@ NOTES:
  */
 #define l
 
+/* Generated from spec:/m */
+
 /**
  * @brief This configuration option is an initializer define.
  *



More information about the vc mailing list