Dynamic functions for `layout` directive broken
After upgrading sphinx-needs from v 4.2.0 to v 5.1.0 in my documentation project, I'm facing the following issue with the use of a dynamic function for the layout directive:
Regardless of whether layout is set via needs_global_options
needs_global_options = {
"layout" : {
"default": "[[get_layout()]]",
},
}
or within a needs block
.. req:: test
:id: df_1
:status: open
:layout: [[get_layout()]]
running either of these with Sphinx v8.2.3 with sphinx-needs v5.1.0 results in the following exception
sphinx_needs.layout.SphinxNeedLayoutException: Given layout "[[get_layout()]]" is unknown for need test.
Note, as a sanity check, I confirmed that the function works as expected for the tags directive:
.. req:: test
:id: df_1
:status: open
:tags: [[get_layout()]]
which results in tags displaying the layout that is returned when get_layout is run for a req-need block.
Since this used to work with version 4.2.0 and according to the docs, dynamic functions are supported for layout, I suspect this may be a regression. Or this an error on my end? I'd be grateful for any pointers on how to fix this.
You can probably do this with predicates:
needs_global_options = {
"layout": {
"predicates": [
("type== 'type123'", "layout123"),
]
"default": "clean",
}
}
You can probably do this with predicates:
Yes, indeed, for my current case, converting the get_layout-function to a set of predicates is feasible and I just checked that this works as advertised :smile:
Thank you for the suggestion!