Skip to content

Commit e4c16c8

Browse files
authored
🐛 Warn on dynamic function with surrounding text (#1426)
Currently, for an item in a list field, with a dynamic function plus other text, the other text will be silently omitted, e.g. ```restructuredtext .. spec:: TEST_1 🆔 TEST_1 :tags: test_1a;test_1b;[[copy('title')]]omitted ``` A warning is now emitted about this
1 parent f7e2410 commit e4c16c8

File tree

5 files changed

+599
-43
lines changed

5 files changed

+599
-43
lines changed

sphinx_needs/functions/functions.py

+12
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,18 @@ def resolve_dynamic_values(needs: NeedsMutable, app: Sphinx) -> None:
318318
new_values += func_return
319319
else:
320320
new_values += [func_return]
321+
if func_call is not None and not (
322+
str(element).strip().startswith("[[")
323+
and str(element).strip().endswith("]]")
324+
):
325+
log_warning(
326+
logger,
327+
f"Dynamic function in list field {need_option!r} is surrounded by text that will be omitted: {element!r}",
328+
"dynamic_function",
329+
location=(need["docname"], need["lineno"])
330+
if need.get("docname")
331+
else None,
332+
)
321333

322334
need[need_option] = new_values
323335

0 commit comments

Comments
 (0)