[rtems-central commit] content: Move list support to Content()
Sebastian Huber
sebh at rtems.org
Wed Feb 3 05:28:01 UTC 2021
Module: rtems-central
Branch: master
Commit: 2a00eeb8d37052555ae5eb0fa10afc8a343f6f24
Changeset: http://git.rtems.org/rtems-central/commit/?id=2a00eeb8d37052555ae5eb0fa10afc8a343f6f24
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Jan 22 14:34:10 2021 +0100
content: Move list support to Content()
---
rtemsspec/content.py | 37 +++++++++++++++++++++++++++++++++++++
rtemsspec/sphinxcontent.py | 37 -------------------------------------
2 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index 616a7a1..e0717b4 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -450,6 +450,43 @@ class Content:
yield
self.close_comment_block()
+ def add_list_item(self, content: GenericContent) -> None:
+ """ Adds a list item. """
+ self.wrap(content, initial_indent="* ", subsequent_indent=" ")
+
+ def add_list(self,
+ items: GenericContentIterable,
+ prologue: Optional[GenericContent] = None,
+ epilogue: Optional[GenericContent] = None,
+ add_blank_line: bool = False) -> None:
+ """ Adds a list with introduction. """
+ if items:
+ self.wrap(prologue)
+ for item in items:
+ self.add_list_item(item)
+ if add_blank_line:
+ self.add_blank_line()
+ self.wrap(epilogue)
+
+ def open_list_item(self, content: GenericContent) -> None:
+ """ Opens a list item. """
+ self.add(["* "])
+ self.push_indent(" ")
+ self.gap = True
+ self.paste(content)
+
+ def close_list_item(self) -> None:
+ """ Closes a list item. """
+ self.pop_indent()
+ self.gap = True
+
+ @contextmanager
+ def list_item(self, content: GenericContent) -> Iterator[None]:
+ """ Opens a list item context. """
+ self.open_list_item(content)
+ yield
+ self.close_list_item()
+
def add_automatically_generated_warning(self) -> None:
""" Adds a warning that the file is automatically generated. """
with self.comment_block():
diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py
index 5f5493f..e7881cf 100644
--- a/rtemsspec/sphinxcontent.py
+++ b/rtemsspec/sphinxcontent.py
@@ -153,43 +153,6 @@ class SphinxContent(Content):
yield self.open_section(name, label_prefix)
self.close_section()
- def add_list_item(self, content: GenericContent) -> None:
- """ Adds a list item. """
- self.wrap(content, initial_indent="* ", subsequent_indent=" ")
-
- def add_list(self,
- items: GenericContentIterable,
- prologue: Optional[GenericContent] = None,
- epilogue: Optional[GenericContent] = None,
- add_blank_line: bool = False) -> None:
- """ Adds a list with introduction. """
- if items:
- self.wrap(prologue)
- for item in items:
- self.add_list_item(item)
- if add_blank_line:
- self.add_blank_line()
- self.wrap(epilogue)
-
- def open_list_item(self, content: GenericContent) -> None:
- """ Opens a list item. """
- self.add(["* "])
- self.push_indent(" ")
- self.gap = True
- self.paste(content)
-
- def close_list_item(self) -> None:
- """ Closes a list item. """
- self.pop_indent()
- self.gap = True
-
- @contextmanager
- def list_item(self, content: GenericContent) -> Iterator[None]:
- """ Opens a list item context. """
- self.open_list_item(content)
- yield
- self.close_list_item()
-
def add_licence_and_copyrights(self) -> None:
"""
Adds a licence and copyright block according to the registered licenses
More information about the vc
mailing list