[rtems-central commit] sphinxcontent: Add user-defined section labels
Sebastian Huber
sebh at rtems.org
Wed Mar 10 09:02:05 UTC 2021
Module: rtems-central
Branch: master
Commit: 1691a0d950e5496accec2e86ca152921300215ba
Changeset: http://git.rtems.org/rtems-central/commit/?id=1691a0d950e5496accec2e86ca152921300215ba
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Mar 10 08:53:36 2021 +0100
sphinxcontent: Add user-defined section labels
---
rtemsspec/sphinxcontent.py | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py
index 1a00b79..af555fb 100644
--- a/rtemsspec/sphinxcontent.py
+++ b/rtemsspec/sphinxcontent.py
@@ -79,11 +79,13 @@ class SphinxContent(Content):
def add_header_with_label(self,
name: str,
level: int = 2,
- label_prefix: Optional[str] = None) -> str:
+ label_prefix: Optional[str] = None,
+ label: Optional[str] = None) -> str:
""" Adds a header with label. """
- if label_prefix is None:
- label_prefix = self.section_label_prefix
- label = label_prefix + get_label(name)
+ if label is None:
+ if label_prefix is None:
+ label_prefix = self.section_label_prefix
+ label = label_prefix + get_label(name)
self.add_label(label)
self.add_header(name, level)
return label
@@ -144,10 +146,11 @@ class SphinxContent(Content):
def open_section(self,
name: str,
- label_prefix: Optional[str] = None) -> str:
+ label_prefix: Optional[str] = None,
+ label: Optional[str] = None) -> str:
""" Opens a section. """
label = self.add_header_with_label(name, self._section_level,
- label_prefix)
+ label_prefix, label)
self._section_level += 1
return label
@@ -158,9 +161,10 @@ class SphinxContent(Content):
@contextmanager
def section(self,
name: str,
- label_prefix: Optional[str] = None) -> Iterator[str]:
+ label_prefix: Optional[str] = None,
+ label: Optional[str] = None) -> Iterator[str]:
""" Opens a section context. """
- yield self.open_section(name, label_prefix)
+ yield self.open_section(name, label_prefix, label)
self.close_section()
def add_licence_and_copyrights(self) -> None:
More information about the vc
mailing list