diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-01-22 14:36:00 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-01 06:59:01 +0100 |
commit | bda3bd7195247162f0f6d806a2a205815293186c (patch) | |
tree | 4a24ff5bd40004148f28856b6c6a0d6ff59b8e34 /rtemsspec/interface.py | |
parent | content: Move list support to Content() (diff) | |
download | rtems-central-bda3bd7195247162f0f6d806a2a205815293186c.tar.bz2 |
interface: Add directive constraints
Diffstat (limited to '')
-rw-r--r-- | rtemsspec/interface.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/rtemsspec/interface.py b/rtemsspec/interface.py index 84623dc2..e8816468 100644 --- a/rtemsspec/interface.py +++ b/rtemsspec/interface.py @@ -26,7 +26,7 @@ from contextlib import contextmanager import os -from typing import Any, Callable, Dict, Iterator, List, Union, Set +from typing import Any, Callable, Dict, Iterator, List, Optional, Union, Set from rtemsspec.content import CContent, CInclude, enabled_by_to_exp, \ ExpressionMapper, get_value_double_colon, get_value_doxygen_function, \ @@ -316,14 +316,16 @@ class Node: return self.mapper.substitute(text.strip("\n")) return text - def substitute_text(self, text: str) -> str: + def substitute_text(self, + text: Optional[str], + item: Optional[Item] = None) -> str: """ Performs a variable substitution on a description using the item mapper of the node. """ if text: - return self.mapper.substitute(text.strip("\n")) - return text + return self.mapper.substitute(text.strip("\n"), item) + return "" def _get_compound_definition(self, item: Item, definition: Any) -> Lines: content = CContent() @@ -423,6 +425,16 @@ class Node: content.wrap(self.substitute_text(ret["return"]), initial_indent="@return ") content.add_paragraph("Notes", self.substitute_text(item["notes"])) + constraints = [ + self.substitute_text(parent["text"], parent) + for parent in item.parents("constraint") + ] + if constraints: + constraint_content = CContent() + constraint_content.add_list( + constraints, + "The following constraints apply to this directive:") + content.add_paragraph("Constraints", constraint_content) return content def _add_generic_definition(self, get_lines: GetLines) -> None: |