Skip to content

πŸ‘Œ Add the shared stylesheets only on pages that render something of oursΒ #1923

Description

@chrisjsewell

#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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpkg: sphinx-needsThe sphinx-needs distribution (packages/sphinx-needs): its code, tests and docs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions