Skip to content

Show preview of the linked need in a pop-up - #16

Merged
tobiaskaestner merged 1 commit into
tkaestner/source-listingsfrom
tkaestner/need-preview
Oct 13, 2026
Merged

tobiaskaestner merged 1 commit into
tkaestner/source-listingsfrom
tkaestner/need-preview

Conversation

@tobiaskaestner

@tobiaskaestner tobiaskaestner commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

When the pointer stays on a link in a need card, and the link goes to another need card, a popup shows a copy of that card: the head, then the fields, then the text. The script fetches the target page in the browser, once per page, so the link can go to another document too. need_cards adds zdocs-need-preview.js to each page; zdocs-needs.css styles the popup.

The popup also opens on keyboard focus, and Escape or a scroll of the page closes it. A device without hover gets no popups. A page opened as file:// cannot fetch other pages, so there only the needs on the same page get a preview.

Only a link that goes to a need gets a popup: need_cards gives it the class zd-need-ref, so a link to a Doxygen page (Source, See also) does not make the script fetch that page.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unsanitized fetched markup creates a security risk, alongside accessibility and unnecessary-fetch concerns.

1 open finding
What changed in this PR

Adds linked-need card previews to generated HTML documentation.

Changes:

  • Adds preview behavior and styling.
  • Registers and copies the JavaScript asset.
  • Documents and tests asset integration.
File Description
sphinx/​_static/​zdocs-needs.css Styles preview popups.
sphinx/​_static/​zdocs-need-preview.js Fetches and displays linked cards.
sphinx/​_extensions/​need_cards.py Registers and copies the script.
sphinx/​_extensions/​_tests/​test_need_cards.py Tests script integration.
doc/​manual/​reference/​directives-and-roles.rst Documents preview behavior.
doc/​api/​python/​extensions.rst Updates extension summary.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sphinx/_static/zdocs-need-preview.js Outdated
When the pointer stays on a link in a need card, and the link goes to
another need card, a popup shows a copy of that card: the head, then the
fields, then the text. The script fetches the target page in the
browser, once per page, so the link can go to another document too.
need_cards adds zdocs-need-preview.js to each page; zdocs-needs.css
styles the popup. Only a link that goes to a need gets a popup:
need_cards gives it the class zd-need-ref, so a link to a Doxygen page
does not fetch that page.

The popup also opens on keyboard focus, and Escape or a scroll of the
page closes it. A device without hover gets no popups. A page opened as
file:// cannot fetch other pages, so there only the needs on the same
page get a preview.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tobias Kaestner <tobias.kaestner@inovex.de>
@tobiaskaestner
tobiaskaestner removed this pull request from stack #15 October 13, 2026 19:09
@tobiaskaestner
tobiaskaestner added this pull request to stack #19 October 13, 2026 19:09
@tobiaskaestner
tobiaskaestner merged commit c06db72 into main Oct 13, 2026
2 checks passed
@tobiaskaestner
tobiaskaestner deleted the tkaestner/need-preview branch October 26, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants