[rtems-central commit] content: Add add_automatically_generated_warning()

Sebastian Huber sebh at rtems.org
Thu Aug 20 14:13:13 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Aug 19 11:00:29 2020 +0200

content: Add add_automatically_generated_warning()

---

 rtemsspec/applconfig.py | 15 ++-------------
 rtemsspec/content.py    | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/rtemsspec/applconfig.py b/rtemsspec/applconfig.py
index cc40fc6..830b322 100644
--- a/rtemsspec/applconfig.py
+++ b/rtemsspec/applconfig.py
@@ -53,15 +53,6 @@ _OPTION_DEFAULT_CONFIG = {
 enabled."""
 }
 
-_AUTOMATICALLY_GENERATED_WARNING = [
-    "This file was automatically generated.  Do not edit it manually.",
-    "Please have a look at",
-    "",
-    "https://docs.rtems.org/branches/master/eng/req/howto.html",
-    "",
-    "for information how to maintain and re-generate this file.",
-]
-
 
 class _ContentAdaptor:
     """
@@ -79,8 +70,7 @@ class _ContentAdaptor:
 
     def add_group(self, name: str, description: str) -> None:
         """ Adds an option group. """
-        with self.content.comment_block():
-            self.content.append(_AUTOMATICALLY_GENERATED_WARNING)
+        self.content.add_automatically_generated_warning()
         self.content.add_header(name, level=2)
         self.content.add(description)
 
@@ -529,8 +519,7 @@ def generate(config: dict, item_cache: ItemCache) -> None:
     doxygen_mapper = ItemMapper(EmptyItem())
     _add_doxygen_get_values(doxygen_mapper)
     doxygen_content = _DoxygenContentAdaptor(doxygen_mapper)
-    with doxygen_content.content.comment_block():
-        doxygen_content.content.append(_AUTOMATICALLY_GENERATED_WARNING)
+    doxygen_content.content.add_automatically_generated_warning()
     with doxygen_content.content.defgroup_block(
             "RTEMSApplConfig", "Application Configuration Options"):
         doxygen_content.content.add("@ingroup RTEMSAPI")
diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index 3c28ab6..131f8fe 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -158,6 +158,15 @@ def _add_context(_content: "Content") -> Iterator[None]:
 
 _SPECIAL_BLOCK = re.compile(r"^( *\* | *[0-9]+\. | +)")
 
+_AUTOMATICALLY_GENERATED_WARNING = [
+    "This file was automatically generated.  Do not edit it manually.",
+    "Please have a look at",
+    "",
+    "https://docs.rtems.org/branches/master/eng/req/howto.html",
+    "",
+    "for information how to maintain and re-generate this file.",
+]
+
 
 class Content:
     """ This class builds content. """
@@ -409,6 +418,11 @@ class Content:
         yield
         self.close_comment_block()
 
+    def add_automatically_generated_warning(self) -> None:
+        """ Adds a warning that the file is automatically generated. """
+        with self.comment_block():
+            self.append(_AUTOMATICALLY_GENERATED_WARNING)
+
     def write(self, path: str) -> None:
         """ Writes the content to the file specified by the path. """
         directory = os.path.dirname(path)



More information about the vc mailing list