🐛 Fix need role in section headings by registering NeedRef node#1700
Open
🐛 Fix need role in section headings by registering NeedRef node#1700
Conversation
…ration The NeedRef node was not registered with app.add_node(), causing SphinxContentsFilter to fail when encountering it in section headings (used for TOC generation). Fixed by registering NeedRef with dummy visitor methods. Agent-Logs-Url: https://github.com/useblocks/sphinx-needs/sessions/383d8ee1-76c6-41b3-b820-931501775be8 Co-authored-by: chrisjsewell <2997570+chrisjsewell@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
chrisjsewell
May 7, 2026 09:57
View session
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1700 +/- ##
==========================================
+ Coverage 86.87% 89.30% +2.42%
==========================================
Files 56 72 +16
Lines 6532 10325 +3793
==========================================
+ Hits 5675 9221 +3546
- Misses 857 1104 +247
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using
:need:in an RST section heading crashes the build becauseSphinxContentsFilter(used byTocTreeCollectorfor TOC generation) doesn't know how to visitNeedRefnodes.Fails with:
SphinxContentsFilter visiting unknown node type: NeedRefFix: Register
NeedRefwithapp.add_node()using dummy visitors, same pattern asNeedPart:sphinx_needs/needs.py— add node registration forNeedReftests/test_role_need_in_heading.py— new test asserting the heading renders with a resolved need referencetests/doc_test/doc_role_need_in_heading/— minimal test project