diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-05-05 14:41:18 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-05-08 14:34:56 +0200 |
commit | 35a64e258226397348aa6c7060247f0e22b5cd2a (patch) | |
tree | 4f67d0a989e742009f7686cfca1f449c3ab154e3 | |
parent | sphinxcontent: Add add_image() (diff) | |
download | rtems-central-35a64e258226397348aa6c7060247f0e22b5cd2a.tar.bz2 |
sphinxcontent: Add SphinxContent.latex_tiny()
-rw-r--r-- | rtemsspec/sphinxcontent.py | 18 | ||||
-rw-r--r-- | rtemsspec/tests/test_content_sphinx.py | 16 |
2 files changed, 34 insertions, 0 deletions
diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py index f9849fc1..abec5553 100644 --- a/rtemsspec/sphinxcontent.py +++ b/rtemsspec/sphinxcontent.py @@ -72,6 +72,7 @@ def _grid_row(row: Iterable[str], maxi: Iterable[int]) -> str: class SphinxContent(Content): """ This class builds Sphinx content. """ + # pylint: disable=too-many-public-methods def __init__(self, section_level: int = 2): super().__init__("CC-BY-SA-4.0", True) self._tab = " " @@ -195,6 +196,23 @@ class SphinxContent(Content): yield self.open_section(name, label_prefix, label) self.close_section() + def open_latex_tiny(self, size: str = "tiny") -> None: + """ Opens a LaTeX tiny environment. """ + with self.directive("raw", "latex"): + self.add(f"\\begin{{{size}}}") + + def close_latex_tiny(self, size: str = "tiny") -> None: + """ Closes a LaTeX tiny environment. """ + with self.directive("raw", "latex"): + self.add(f"\\end{{{size}}}") + + @contextmanager + def latex_tiny(self, size: str = "tiny") -> Iterator[None]: + """ Opens a LaTeX tiny environment. """ + self.open_latex_tiny(size) + yield + self.close_latex_tiny(size) + def add_licence_and_copyrights(self) -> None: """ Adds a licence and copyright block according to the registered licenses diff --git a/rtemsspec/tests/test_content_sphinx.py b/rtemsspec/tests/test_content_sphinx.py index 82312157..59903283 100644 --- a/rtemsspec/tests/test_content_sphinx.py +++ b/rtemsspec/tests/test_content_sphinx.py @@ -207,6 +207,22 @@ def test_add_image(): """ +def test_latex_tiny(): + content = SphinxContent() + with content.latex_tiny(): + content.add("abc") + assert str(content) == """.. raw:: latex + + \\begin{tiny} + +abc + +.. raw:: latex + + \\end{tiny} +""" + + def test_add_index_entries(): content = SphinxContent() content.add_index_entries(["x", "y"]) |