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 | 4708352e70c557c14fd8bdac5be7f7ba92a37f08 (patch) | |
tree | a1271900d515dbaac0709541b3932ea4ad67a8af | |
parent | sphinxcontent: Make get value functions public (diff) | |
download | rtems-central-4708352e70c557c14fd8bdac5be7f7ba92a37f08.tar.bz2 |
sphinxcontent: Add add_rubric()
-rw-r--r-- | rtemsspec/applconfig.py | 2 | ||||
-rw-r--r-- | rtemsspec/interfacedoc.py | 12 | ||||
-rw-r--r-- | rtemsspec/sphinxcontent.py | 6 |
3 files changed, 12 insertions, 8 deletions
diff --git a/rtemsspec/applconfig.py b/rtemsspec/applconfig.py index 132ee905..1474a7f5 100644 --- a/rtemsspec/applconfig.py +++ b/rtemsspec/applconfig.py @@ -85,7 +85,7 @@ class _ContentAdaptor: wrap: bool = False) -> None: if not text: return - self.content.add(f".. rubric:: {name}:") + self.content.add_rubric(f"{name}:") if wrap: self.content.wrap(text) else: diff --git a/rtemsspec/interfacedoc.py b/rtemsspec/interfacedoc.py index c7b03fff..335c4e85 100644 --- a/rtemsspec/interfacedoc.py +++ b/rtemsspec/interfacedoc.py @@ -130,14 +130,14 @@ def _generate_directive(content: SphinxContent, mapper: SphinxInterfaceMapper, code_mapper: _CodeMapper, item: Item, enabled: List[str]) -> None: content.wrap(mapper.substitute(item["brief"])) - content.add(".. rubric:: CALLING SEQUENCE:") + content.add_rubric("CALLING SEQUENCE:") with content.directive("code-block", "c"): code = CContent() _add_definition(code, code_mapper, item, "definition", item["definition"]) content.add(code) if item["params"]: - content.add(".. rubric:: PARAMETERS:") + content.add_rubric("PARAMETERS:") for param in item["params"]: description = param["description"] if description: @@ -146,11 +146,11 @@ def _generate_directive(content: SphinxContent, mapper: SphinxInterfaceMapper, mapper.substitute(f"This parameter {description}"), wrap=True) if item["description"]: - content.add(".. rubric:: DESCRIPTION:") + content.add_rubric("DESCRIPTION:") content.wrap(mapper.substitute(item["description"])) ret = item["return"] if ret: - content.add(".. rubric:: RETURN VALUES:") + content.add_rubric("RETURN VALUES:") for retval in ret["return-values"]: if isinstance(retval["value"], str): value = mapper.substitute(str(retval["value"])) @@ -162,14 +162,14 @@ def _generate_directive(content: SphinxContent, mapper: SphinxInterfaceMapper, wrap=True) content.wrap(mapper.substitute(ret["return"])) if item["notes"]: - content.add(".. rubric:: NOTES:") + content.add_rubric("NOTES:") content.wrap(mapper.substitute(item["notes"])) constraints = [ mapper.substitute(parent["text"], parent) for parent in item.parents("constraint") if parent.is_enabled(enabled) ] if constraints: - content.add(".. rubric:: CONSTRAINTS:") + content.add_rubric("CONSTRAINTS:") content.add_list(constraints, "The following constraints apply to this directive:") diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py index f48dfc67..dd2fb308 100644 --- a/rtemsspec/sphinxcontent.py +++ b/rtemsspec/sphinxcontent.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-2-Clause """ This module provides classes for Sphinx content generation. """ -# Copyright (C) 2019, 2020 embedded brains GmbH (http://www.embedded-brains.de) +# Copyright (C) 2019, 2022 embedded brains GmbH (http://www.embedded-brains.de) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -101,6 +101,10 @@ class SphinxContent(Content): self.add_header(name, level) return label + def add_rubric(self, name: str) -> None: + """ Adds a rubric. """ + self.add(f".. rubric:: {name}") + def add_index_entries(self, entries) -> None: """ Adds a list of index entries the content. """ self.add([".. index:: " + entry for entry in make_lines(entries)]) |