diff --git a/AUTHORS b/AUTHORS index 821726ea2..b37fbbb7c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -37,3 +37,5 @@ Duodu Randy Christian Wappler Chris Sewell + +Simon Leiner diff --git a/sphinx_needs/layout.py b/sphinx_needs/layout.py index 887d2fea8..38b123e50 100644 --- a/sphinx_needs/layout.py +++ b/sphinx_needs/layout.py @@ -397,7 +397,7 @@ def _func_replace(self, section_nodes: List[nodes.Node]) -> List[nodes.Node]: node.replace(child, new_child) # type: ignore[attr-defined] return_nodes.append(node) else: - node_str = str(node) + node_str = node.astext() # func_elements = re.findall(r'<<([a-z_()]*)>>', node_str) node_line = nodes.inline() @@ -486,7 +486,11 @@ def meta(self, name: str, prefix: Optional[str] = None, show_empty: bool = False Returns the specific metadata of a need inside docutils nodes. Usage:: - <> + <> + + .. note:: + + You must escape all rst_content in your function strings! E.g. to get `**` one must use `\\\\*\\\\*`. :param name: name of the need item :param prefix: string as rst-code, will be added infront of the value output diff --git a/tests/doc_test/doc_layout/conf.py b/tests/doc_test/doc_layout/conf.py index 5bc569c33..adcc07d7f 100644 --- a/tests/doc_test/doc_layout/conf.py +++ b/tests/doc_test/doc_layout/conf.py @@ -30,6 +30,13 @@ "side": ['<>'], }, }, + "optional_author": { + "grid": "simple", + "layout": { + "head": ['**<>**'], + "meta": ['**status**: <>', r'<>'], + }, + }, "footer_grid": { "grid": "simple_footer", "layout": { diff --git a/tests/doc_test/doc_layout/index.rst b/tests/doc_test/doc_layout/index.rst index a34a4dac5..ce1cf38ea 100644 --- a/tests/doc_test/doc_layout/index.rst +++ b/tests/doc_test/doc_layout/index.rst @@ -13,5 +13,9 @@ TEST DOCUMENT .. spec:: title_example_layout :layout: example +.. spec:: title_layout_optional_author + :layout: optional_author + :author: some author + .. spec:: title_layout_footer_grid :layout: footer_grid diff --git a/tests/test_layouts.py b/tests/test_layouts.py index e20aca3f7..e886c2fbd 100644 --- a/tests/test_layouts.py +++ b/tests/test_layouts.py @@ -23,8 +23,11 @@ def test_doc_build_html(test_app): assert "title_example_layout" in html needs = extract_needs_from_html(html) - assert len(needs) == 5 + assert len(needs) == 6 + assert ( + 'author: some author' in html + ) assert '' in html # check simple_footer grid layout