#1920 registers the needtable's script and structural stylesheet only on pages that contain a needtable (the table half of #462). The extension's other stylesheets β everything in src/sphinx_needs/css/common/*.css (including the table's host sheet, common/needstable.css) and the needs_css theme file β are still added to every page from the install_styles_static_files loop at env-updated, whether or not the page renders a need, a needtable or anything of ours.
Proposed: the same doctree-marker mechanism install_needtable_assets uses (environment.py) for the per-page half: mark a resolved doctree that holds any sphinx-needs output, and add the sheets from html-page-context for those pages only. search.html and genindex.html would then carry nothing of ours. The test_html_head_files / test_assets_are_registered_per_page tests in tests/test_basic_doc.py and tests/test_needtable_markup.py show the assertion shape.
One thing to decide first: a user stylesheet that references --sn-* tokens on a page without needs would lose them β probably fine, but it is a behaviour change worth a changelog line.
Follow-up from #1920 (the rest of #462).
#1920 registers the needtable's script and structural stylesheet only on pages that contain a needtable (the table half of #462). The extension's other stylesheets β everything in
src/sphinx_needs/css/common/*.css(including the table's host sheet,common/needstable.css) and theneeds_csstheme file β are still added to every page from theinstall_styles_static_filesloop atenv-updated, whether or not the page renders a need, a needtable or anything of ours.Proposed: the same doctree-marker mechanism
install_needtable_assetsuses (environment.py) for the per-page half: mark a resolved doctree that holds any sphinx-needs output, and add the sheets fromhtml-page-contextfor those pages only.search.htmlandgenindex.htmlwould then carry nothing of ours. Thetest_html_head_files/test_assets_are_registered_per_pagetests intests/test_basic_doc.pyandtests/test_needtable_markup.pyshow the assertion shape.One thing to decide first: a user stylesheet that references
--sn-*tokens on a page without needs would lose them β probably fine, but it is a behaviour change worth a changelog line.Follow-up from #1920 (the rest of #462).