Changelog¶
Unreleased¶
Improvements¶
✨ needs_from_toml follows extend: a needs_from_toml file whose top-level
extendnames a base file is read with the base, and with every file the base extends in turn, merged as ubCode merges them: each[needs]key is taken whole from the nearest file that sets it, the variant data is merged across the chain, and a relative path is resolved at the directory of the file that sets it (a file that extends another). So need types, link types and fields kept in a shared base file are known to the Sphinx build too, where every directive of such a type used to be an “Unknown directive type” error. A chain that cannot be followed (a cycle, a missing or invalid base) is oneneeds.configwarning, as an unreadable file is; under needs_from_toml_tableextendis not followed, and is reported as aneeds.configwarning. Needs the next release of ub-project. (issue #2469)‼️ A wrong-typed variant key in the ignored location fails the build: a
[needs] variant_datathat is not a table, or a[needs] variant_data_filethat is not a string, beside a[variants]table that is read is now a configuration error naming the file and the key, as ubCode refuses it, where it was aneeds.variant_data_locationwarning (Variant data: the [variants] table). (issue #2469)✨ A style class can carry a diagram look: needs_styles (
[needs.styles.<class>]inubproject.toml) gives a class anodelook,{ fill, text, border, shape }, and a need whose style names the class is drawn with it by needflow, on PlantUML and Graphviz, and byflow()in needuml and needarch. So one need type can draw its databases as cylinders ([needs.styles.database] node = { shape = "cylinder" }and:style: database), and a predicate of thestylefield can give the open requirements an outline in a needflow and inflow()(a needflow’s own:border_color:and:highlight:are drawn above it). A colour is#and three or six hex digits; a shape is one of ten names (rectangle,rounded,circle,ellipse,diamond,hexagon,cylinder,document,folder,box3d), drawn on PlantUML and Graphviz as the table of needs_styles says. Property by property the last class of the need’s list wins; a class’s fill is above the need type’scolor, its shape above the type’sstyle, its border below a needflow’s:border_color:and:highlight:(Style classes). A problem of an entry is oneneeds.configwarning, the entry’s usable properties kept. The built-in styles carry no node look, so a project that writes no entry draws what it drew. Not in this release: a class’s look on a need’s page, a table row or an edge, in a legend, in needsequence or needgantt, the colour of:highlight:, and a border’s width or line style. (PR #2599)✨ A link type says how its edges are drawn: a link type (needs_links,
[needs.links.<name>]) gainsline(solid,dashed,dotted,thick) andarrow(normal,none,both,circle,diamond), and itscoloris drawn at last: needflow draws the three on PlantUML and on Graphviz alike,arrowon the edges to need parts too, whose line and colour stay as they were drawn (line / arrow / color). So[needs.links.verifies] line = "dashed",arrow = "diamond",color = "#00AA00"draws every verification as a dashed green line with a hollow diamond, on either engine.style,style_startandstyle_endare written as they were, and read as these values where a link type does not set them, as the engines draw them (the last of two line words or colours, a.of the ends asdashed); a key that is set changes its own value alone (linethe line words ofstyle,colorits colours), but forarrow, which takes the place ofstyle_startandstyle_endwhole but for the line they drew, so a direction, a length or a colour written in them goes with them (on PlantUML alineorcoloris written in the arrow’s brackets, and PlantUML loses the whole diagram where they come before the arrow’s first line character, among other places: style_start / style_end). A colour is#and three or six hex digits; a value of the three keys that is not usable is oneneeds.configwarning and unset, and an empty one unset. A link type’scolorwas accepted whatever it held, so one that is no hex colour now fails a-Wbuild: correct it, or addneeds.configtosuppress_warnings, which silences every warning about the configuration. The built-inlinksandparent_needslose their colours (#000000,#333333), which no engine drew, so a project naming no colour draws what it drew, andLinkDisplayConfig.coloris empty by default. Fixed with it:solidin astyleorstyle_part("solid","solid,#777777") lost the whole PlantUML diagram; it is no longer written for PlantUML, nor, where it is the last line word, any line word, so the line is drawn solid, as Graphviz draws a lower-casesolid; astylebeside an emptystyle_startlost the diagram too, its brackets written right after the source name: the first-or.ofstyle_endis now written before them; and the documentation no longer teachesredand#redas colours (PlantUML refuses the first, Graphviz draws the second black). The first build after upgrading reads every document again. (PR #2605)✨ A hidden need, read in full: needs_hidden_needs (
[needs] hidden_needs) set to"collapsed"reads a need with hide set as a visible need is read, howeverhidewas set (the option, a field default or predicate, needimport’s:hide:, a record’shide, a list2need item, a need another extension creates): it has the parts its content marks and its anchor, the needs written inside it exist with it as their parent, acontent_linksrule and links_from_content read its references (nono stored nodewarning), needlist links it, needextract draws it, and the children of a hiddenlist2needitem are that item’s children. It is drawn, from itshideonce every needextend is applied, as its card in a closed disclosure in a builder writing HTML, its anchor outside the disclosure and its header as the summary, and in every other builder, which has no disclosure, as a visible need’s card is drawn, so that builder writes what it writes with thehidetaken off, but for a hidden need’s templates, which stay unrendered, and for what readshideitself (and agettextcatalog holds the hidden text). A project that sets it can newly see needs that did not exist, a nested need refused for an id another need has, a markup error or a:need:reference to a missing need in hidden content reported for the first time,needs.views_include_partsandneeds.needextractnotices about what a hidden need now has, and atextormanbuild that ends where a hidden need holds a need nested in it, as it ends for a visible need (hide has the list). Unset, nothing changes: a hidden need is read and drawn as before. The new configuration value makes every project’s first build after upgrading re-read every document, once. (PR #2597)✨ A join can link need parts: links_from_match takes
include_parts, and so does a derivedlinksrule with join, where it was refused (needs.derive_invalid). With it, the parts of every need are candidates too, each read as a part answers a filter: its ownidandid_complete, its text ascontentandtitle, noparent_need, its need’s value of every other field. So[[links_from_match("id_complete", "case", include_parts=True)]]links the parts whose address the need’scasenames. A part that matches is linked as<need>.<part>, after its need, in part-id order, and the need’s own parts are left out with it unlessinclude_self. Without it, nothing changes. (PR #2567)✨ An import under a namespace:
:namespace: SUPon needimport (namespace), ornamespace = "SUP"on a needs_external_needs source, puts the file’s needs into the namespaceSUP, so that a supplier’s ids cannot clash with the project’s: the file’sREQ_1becomesSUP::REQ_1, itsnc::REQ_2becomesSUP::nc::REQ_2, and every reference inside the file to one of its own needs follows. It isid_prefixwith the textSUP::, with the namespace checked; several levels are allowed (sup::m2). A value that is not a namespace, or one given beside anid_prefix, is refused: at aneedimportwith oneneeds.needimportwarning, and the directive imports nothing; for a source, as a missingbase_urlis, stopping the build. With needs_namespaced_ids off (the default in 9.x) the ids get the prefix all the same and are read as plain ids, and each such import gives oneneeds.namespaced_ids_offwarning. With it on, a need whose id cannot be joined to a namespace (a::::b, or an id starting with:) is imported asSUP::a::::b, a plain id outside the namespace, and each import holding such ids gives one warning of a new type,needs.import_namespace, naming how many and the first five. A sphinx-needs older than this one ignores thenamespacekey of a source without a word (the needs arrive with the file’s own ids), and reports theneedimportoption as unknown. (PR #2568)✨ What a view’s filter selects: needs_views_include_parts (
[needs] views_include_parts) says whether the filter of a needtable, needlist, needflow or needgantt, of a needpie line or a needbar cell (and of either chart’s scope) and of need_count is tested on the need parts beside the needs.Truetests every need and every part, as every release so far has;Falsetests the needs alone, so a view shows a need’s parts only where it asks (a needtable’s or a needflow’s:show_parts:), a filter that tests each need on its own selects the needs it selects underTruein the same order,is_partselects nothing, a needflow draws a link to a part of a need it shows as an edge to that need, in the link type’sstyle_part(dotted by default), and filter code and a filter function are handed needs alone (a part they build themselves is dropped, unless needs_allow_unsafe_filters). Unset, it isTruein 9.x andFalsefrom 10.0. While it is unset, each view, chart line or cell and:need_count:whose result holds a need part reportsneeds.views_include_parts, once, where it is written, saying how many need parts its filter selects (a count: how many it counts), before any:max_items:cap; so does a needflow that from 10.0 draws links to parts of its needs as edges to the parts’ needs, saying how many: those of the needs itsmax_itemswindow keeps once it holds needs alone. Set the value either way (Truekeeps the views as they are,Falseselects needs alone now) or suppress the warning type to silence it, until which a-Wbuild of such a project fails on this release. A needtable with:show_parts:reports the parts whose need it does not list, and is not reported where its matched parts are each listed under their need; needextract is not reported. The report is decided from each place’s result: it cannot see a view whose filter string, filter code or filter function readsneedsitself (a needflow among them can be reported with a number of links it does not then draw), nor a chart’s:filter-func:, and it can name a place whose output stays the same (filter code that builds parts itself, with unsafe filters allowed; a:need_count:ratio whose two halves both hold parts; a needflow drawn by graphviz whose filter selects parts of a need it does not show, which graphviz does not draw). Functions and rules that takeinclude_parts, needextend, warning checks, constraints, the builder’s filter andneeds.jsondo not read the value; changing it re-reads no document. From 10.0 a view lists needs, not need parts, unless it asks: setneeds_views_include_partseither way to keep a project’s views through that release.✨ A needflow’s edge to a need names the parts it links: with needs_views_include_parts
False(the default from 10.0) a needflow draws the links of one need, of one link type, to parts of one need it draws as ONE edge to that need, in the link type’sstyle_part, labelled with the part ids in the need’s order of its parts, each once:SPEC_2, linkingREQ_1.zetaandREQ_1.alpha, is one dotted edge toREQ_1labelledzeta, alpha, where it was two unlabelled edges. A link to the need itself stays an edge of its own, unlabelled; each link type draws its own edge; with show_link_names the label is the link type’s name and the part ids, on two lines (Need parts). An external need’s part now links the part’s anchor, as:need:links it, where it linked the need’s URL: its needtable row, a needtable cell naming it, its node in a needflow and needuml’sref()of it. UnderTrueand unset a needflow draws what it drew but for two kinds of line: an external part’s node, which links the part’s anchor, and graphviz’s edge from a need to its own part, which no longer names the need’s cluster as its tail (dotwarned on it, and the build did not show the warning). Separately, a link type whosestyle_partis empty draws a plain line in a PlantUML needflow, where it wrote-[]->, a syntax error. Theneeds.views_include_partsreport still counts a needflow’s links, not its edges. (PR #2588)✨ A needflow draws each need’s parts inside it: with show_parts a needflow draws each need it draws with every need part it has, inside it, in the need’s order of its parts, whether a link names the part or not, and a link to a part as an edge to the part’s node, in the link type’s
style_part. Its result then holds needs alone: a part its filter selects is drawn only inside its need,:max_items:counts needs, and a filter that selects parts alone draws nothing. What it draws is the same whatever needs_views_include_parts says, but for a filter that readsneedsitself (a filter string, filter code or a filter function), which is handed needs and parts underTrueand needs alone underFalse, as in every view; it makes noneeds.views_include_partsreport, and the report of a needflow without the option now names it. An upgraded project re-reads every document once, as the needflow’s stored options gain a key. (PR #2589)✨ An imported need keeps the parts its record states: a needimport record’s
partsthat its content does not mark with a need_part / np role were dropped, and every link and:need:reference to one was dead (needs.link_outgoing,needs.link_ref). The need now has them, after the parts its content marks, in the record’s order, each with its key as its id and its text on one line: each run of white space that holds a line break (LF, VT, FF, CR, NEL U+0085, LS U+2028 or PS U+2029) is one space, in the stored part and so inneeds.json, filters and every place the text is written, and every other character is kept; where both give an id, the content’s part is the part, with its text, and nothing is reported. A part id is one word: a record part whose id holds white space or a control character is not taken, and is dropped as before. On the page the stated parts are shown in a block after the need’s content (the classneeds-stated-parts), one line per part with its text, its id and its anchorNEED.part, styled as a part in the content with the classneed-part-statedbesideneed-part. html, singlehtml, epub, LaTeX and texinfo anchor each line; text and man print each line’s text and id after the need’s content, text in the need’s cell with every paragraph of it on one line, man with no blank line before the first. Links and references to a stated part are live and land on its line, their warnings go, and the importing project’sneeds.json, tables, flows and filters have it (see stated parts). A need’s parts are stored in that order, its content’s as written then the stated ones, and a needtable’s:show_parts:rows, needlist, needflow, needextract and the block list them in it; a needtable whose filter selects parts sorts them as it sorts its rows, and links_from_match and a derived join take them in part-id order, as before.A view now lists the stated parts: a stated part is a part like any other, so a view’s filter tests it while needs_views_include_parts is unset or
True. With the value unset (the 9.x default), every view whose filter an imported need passes now also lists that need’s stated parts and reportsneeds.views_include_partsonce where it is written, so a-Wbuild that passed fails. Set the value toFalseto select needs alone, or toTrueto keep the parts without the report. One more warning can appear: a PlantUML needflow that draws a stated part whose one-word id holds a double quote, a backslash,@or a square bracket fails to draw it and reports[plantuml](graphviz draws it).Importing a
needs.jsonthat Sphinx-Needs wrote changes nothing on the page for a need that had no stated part there, where this project reads each need’s content as the writing project did: its record states only the parts its content marks. A need that had stated parts there (imported, or given bycreate_need) is written with them in the file’s order, which is by id, and this project takes them in that order, with the same texts, so its block can list them in another order than the writing project’s. In two cases a record’s parts are now stated parts, where they were dropped: a content holding an.. include::this project cannot resolve, or may not read (needs_import_restrict_content), whose parts the record carries without their text; and a content in another markup than this project reads it in, such as a MyST need read as reStructuredText, whose{np}role is no role there, so that its part’s text is on the page twice, in the content and in the block (needs_import_parse_by_doctype reads each content in the markup its record names, where this project has a parser for it, and removes that case). A hidden imported need and an external need keep their record’s parts alone, as the record gives them, as before.Through the API,
create_need()takesparts, a mapping of part id to text, merged by the same rule; it refuses a part id that is not one word. The deprecatedadd_needkeeps thepartsit is given for a need on a page, where it dropped them with oneneeds.partwarning per need.NeedPartDatarecords whether a part comes from its need’s content or is stated (origin), which needs.json and filters do not read. Every project re-reads its sources once after upgrading. (PR #2581)👌 The warning for the keys of a need’s given parts that the format does not define (any but
id,contentand the<link>_backof a link type the project has) now has its own code,needs.unknown_part_keys, and comes once per need, naming each such part in the order given with its keys, where it came once per part underneeds.part, the code of a part outside a need. Only a project that imports or loads records whose parts carry such keys is affected: a needimport or a needs_external_needs source, orpartsgiven toadd_need,add_external_need,generate_needoringest_need_record. A project that listsneeds.partinsuppress_warningsto silence it sees it again, and a-Wbuild then fails: listneeds.unknown_part_keys. Which parts a need keeps is unchanged. (PR #2586)✨ needs.json draft “2a2” (experimental), replacing “2a1”: with needs_json_format_version
= "2a2", a need’s parts are a section of its record,"parts": [{"id": "zeta", "text": "last id first"}, {"id": "alpha", "text": "first id second"}], beside itscontentand in the order the need holds them – the parts its content marks in the order written, then the parts it states (its record’s, or those it was given) in the order given – where “2a1” wrote them ascontent.parts, which a file written without its content lost. Leaving out thecontent(needs_json_exclude_fields) keeps the parts, with their texts; namingpartsleaves out the section alone; a need without parts has noparts. A link to the empty part,REQ_1., stays the dead link it is through a draft file: written{"id": "REQ_1", "part": ""}, read back asREQ_1.and reported again, where a 2a1 file turned it into a live link toREQ_1. needimport and needs_external_needs read “2a2” and refuse a “2a1” file, with the warning they give every format they do not read; a part entry of a wrong shape, or a second entry of one id, is one warning, and the need is read without it. The value"2a1"is an unknown value now: a project that sets it gets oneneeds.configwarning, which names"2a2", and aneeds.jsonof format 1, until it sets"2a2".ENV_DATA_VERSIONis 35, was 34, so that a page whoseneedimportread a “2a1” file reads it again: the first build after upgrading reads every document again. See needs.json format 2a2 (draft). (PR #2594)✨ A link type may say where the linked need stands:
points_to = "upstream"(the linked need comes first, the default),"downstream"(it comes after) or"peer"(neither) (needs_links), and a need type’s entry may give its own value for the links written on its needs, read throughinherits(Fields per need type);FieldsSchema.points_to(need_type, link_type)answers it. It is checked and kept, and sphinx-needs does not act on it, so a configuration shared with a tool that reads it builds under-W: before, the key was reported as unknown. A value that is none of the three names is aneeds.configwarning, and ignored. It is not in theneeds.json.ENV_DATA_VERSIONis 37: the first build after upgrading reads every document again. (PR #2554)⬆️
jsonschema-rsis allowed up to 0.63 (>=0.37.1,<0.64; it was capped below 0.59) (changed output) (PR #2596)A link schema’s
minContainsormaxContainsviolation now says how many links matched: where it saidNone of ["SPEC_1"] are valid under the given schema, which was untrue whenever some links matched, it says["SPEC_1"] has less than 2 items valid under the given schema(orhas more than 1 item).⚡️ A need that does not set a link type takes the link type’s default (or a predicate’s) as a new list of the same links, rather than a deep copy of each link: a project of 1452 needs and 484 link types builds about 15 % faster (24.0 s to 20.4 s on Python 3.13, 27.5 s to 23.3 s on Python 3.12, measured locally). A default holding a dynamic function is still copied deeply. No output changes. (PR #2616)
Bug fixes¶
🐛 An appended style keeps every class’s look: a needextend’s
:+style:adds its classes after a comma and a blank, so:style: redand:+style: green_bargivered, green_bar, and the need’s card and its node in a needflow orflow()draw both classes. The append joined with a blank, which merged the need’s last class and the first appended one into one token,red green_bar: the card drewredand a baregreen_barclass that no style rule names, and a diagram neither class’s needs_styles look, with no warning. Only the parts that are not empty are joined, a computed part ([[copy("status")]]) by the text it resolves to, blanks alone being empty, so an empty:+style:leaves no trailing blank, and an append onto an unset style sets it as written. An appended text is taken as written::+style: , green_baronredgivesred, , green_bar, whose empty token is no class. Every other string option still joins an append with a blank.ENV_DATA_VERSIONis 38: the first build after upgrading reads every document again. (changed output) (PR #2623)🐛 A blank between a variant’s name and its
:is ignored:<<v1 :a, b>>kept the blank in its condition,"v1 ", which names no needs_variants key, so the condition was evaluated as an expression and the field failed withname 'v1' is not defined– or, where the need has a field named like the variant, read that field instead of the variant. The blanks between a condition written without brackets and its:are now dropped, as those before the condition and after the:already were, so<<v1 :a, b>>names the variantv1as<<v1:a, b>>does, in a field and in a needflow’s:border_color:alike. A condition in brackets is taken as written:<<[ v1 ]:a, b>>reads as it did (Variant functions). Changed output: where a need has a field named like the variant,<<safety :a, b>>resolved silently from that field; the variant now decides, as it does without the blank. (PR #2621)🐛 A
schemakey of[needs]in needs_from_toml is ignored, as ubCode ignores it: a[needs.schema]sub-table holding aschema_-prefixed key (schema_debug_path) stopped the build with aKeyError, and aschemathat is not a table was anError loading 'needs_from_toml' filewarning and nothing of the file was read. The sub-table never set anything (its keys without the prefix were skipped), and ubCode does not read it. Theschema_*options are keys of[needs]itself (schema_definitions_from_json = "schemas.json"), as they always were; aschemakey is now ignored, as any other unknown key of[needs]is.🐛 A word ending in
_in a need card’s label no longer ends the HTML build (issue #2613): the need card parses its labels as inline reStructuredText – a link type’soutgoingandincominglabels (by default its name and<name> incoming), the field namesmeta_allshows, the lines of a layout and theprefixof itsmeta,imageandlink– and a reference no card can resolve ended the build withAssertionError: References must have "refuri" or "refid" attribute(or aKeyErrororNotImplementedError): a word ending in_such assee_, a field or link type nameda_(set through:a\_:, MyST or needimport), and a footnote, citation or substitution reference ([1]_,[CIT]_,|sub|). Each is now shown as written,see_, and the build goes on;**strong**, roles and a reference with an embedded URI are drawn as before. (PR #2614)🐛 A field or link type whose name ends in
_is one warning (issue #2610): docutils reads a reStructuredText option’s name as inline markup and may read a name ending in_as a hyperlink reference, so:a_:reaches the directive as the optiona, and a field or link type nameda_is not set by it (Unknown option 'a', or, whereais declared too,aset instead). Each such name, fromneeds_fields,needs_extra_options,needs_links,needs_extra_links, a need type’sfieldsorlinks, or theirubproject.tomltables, is now oneneeds.option_name_underscorewarning naming its declaration; the name is declared and works as before. A-Wbuild of a project declaring such a name now fails on it: rename the field or link type, or add"needs.option_name_underscore"tosuppress_warnings(option names and case). (PR #2612)🐛 A link type’s older keys no longer end the build, and lose a PlantUML needflow in fewer places (issue #2607): PlantUML loses the whole diagram where an arrow’s brackets come before its first line character (
-,.,=,~), and astyle,style_part,lineorcolorwas written there: beside an emptystyle_startand astyle_endstarting with<, a head (o->), a blank,=or~, and beside astyle_startof blanks alone or ending in a head (<,o,*). Wherestyle_startholds no line character, the brackets are now written right after the first line character of the arrow (<-[dotted]>,o-[dotted]>,=[dotted]>), drawn with the heads, the direction and the length the arrow has without them, but for astyle_endwith a second line character before a direction word, or before a0with more of the arrow after it (<and--up->are<-[dotted]-up->), which is still lost; astyle_startthat holds one, and ends holding brackets of their own (-[norank]->), which PlantUML would draw otherwise, are written as before (style_start / style_end). Astyleorstyle_partwith a blank around a token or an empty piece (dotted, #AA0000,dotted,) lost the PlantUML diagram too; it is given to PlantUML trimmed of blanks, its empty pieces left out (style / style_part). And astyle,style_part,style_startorstyle_endthat is no string (a number,None, a list) inneeds_linksorneeds_extra_linksended the build with a Python exception on Graphviz, and astyle_startorstyle_endon PlantUML too: it is drawn as the link type’s look reads it, astylewith no line and no colour and astyle_startorstyle_endas empty, but for astyleorstyle_partthat is truthy on PlantUML, written in the brackets as before; on Graphviz, astyle_startand astyle_endthat are both empty or no string get the existingUnknown link start/end style ''warning, where the build ended. Such a value is now also said, once per link type and key, as a newneeds.configwarning, inneeds_links,needs_extra_linksand theirubproject.tomltables (a need type’slinksalready reported it, and ignores the key): a-Wbuild of such a project now fails on it; write the value as a string, or addneeds.configtosuppress_warnings. Every arrow whose text changed lost its diagram, or the build, before. (PR #2609)🐛 A need naming a layout that is not defined no longer ends the build (issue #2324): written on the need (layout), carried by a record needimport reads, given by a needextract’s
:layout:, or naming a card of needs_card_layouts that was skipped when it was compiled (anextendsnaming no specification, regions no grid can draw), the name is reported as a warning of a new type,needs.layout_unknown, naming the need, the layout and the layout used instead: needs_default_layout, orcleanwhen that one is not defined either. The name a need carries is checked on the need, as a dead link is, and on the same builds (every build that reads or writes a page, and from Sphinx 8 one that does neither too): every need of the project that is not hidden and not external, once, at the need where it has a location, however often it is drawn, also one no builder writes (none underneeds_include_needs = False). A hidden or an external need is reported only where it is drawn (by a view, or a hidden need drawn collapsed under needs_hidden_needs), while that page is written; a needextract’s:layout:is reported while its page is written, at the need it draws. A report made while a page is written is made again only by a build that writes that page. Where the need was drawn, the name ended the build withSphinxNeedLayoutException: such a project did not build before, and a-Wbuild of it now fails on the warning, as on any other. Newly warned is a project in which such a need was never drawn: one built only with theneedsbuilder, which draws no need, or one that defines a layout inconf.pyonly under a tag and uses it in needs under.. only::of that tag. It built without a word, and now gets one warning per such need, which fails a-Wbuild. Define the layout, or add"needs.layout_unknown"tosuppress_warnings, which silences every such name, also of a need that is drawn. An error inside a layout’s own lines (an unknown layout function or grid, an argument a function refuses) still ends the build. (PR #2598)🐛 An unresolvable needs_default_layout – empty, or naming no layout (a skipped card of needs_card_layouts among them) – is one
needs.configwarning, on the builds that check the needs’ layout names, andcleanis used in its place; it ended the build at the first need drawn with it. It is checked with those names, when the needs are post-processed, so a layout an extension adds before the documents are read resolves; one thatadd_need_layoutadds after that step (from adoctree-resolvedhandler, say) is drawn, but reported as not defined. A project whose every need names a layout of its own built with such a value without a word, and now gets the warning. (PR #2598)🐛 A card of needs_card_layouts with
collapse = "open"draws the meta region’s toggle, starting open whatever the need’s:collapse:says, as"closed"draws it starting closed; it drew no toggle, so a reader could not close the meta region. The compiled layout says so with a new optional keyword of thecollapse_buttonlayout function,fixed=True(the button starts asinitialsays, whatever the need’s:collapse:says), which a needs_layouts entry can use too."honour"and"closed"compile and draw as they did. (PR #2598)🐛 A card of needs_card_layouts with
header = falseand a meta region (and neither a footer nor a side region) is drawn, the meta region above the content, on a new grid, simple_headless; it was skipped as not expressible, and a need naming it ended the build. With a footer or a side region it is still skipped, and a need naming it is now aneeds.layout_unknownwarning. No other grid changes. (PR #2598)🐛 Changed default: a card of needs_card_layouts whose
sideregion names nopositiondraws it on the right; it drew it on the left. A project with such a card sees its side column move: writeposition = "left"to keep it where it was. A card extending one that names a position (clean_l, say) keeps that position, and the built-in layouts (clean_l,clean_r,focus_l,focus_r, …) do not move. (PR #2598)🐛 In the places below that take a need id, a need part’s address
ID.partreads as its need, as a link to a part already did.The places: the targets of need_outgoing and need_incoming, the uml(id) and flow(id) functions and the links
import()follows, the:start:of needsequence, theneed_idofcopyand oflinks_from_content, and thefromof a derived field’scopyandcontent_linksrules;links_from_contentandcontent_linksread the need’s whole content.:need_incoming:given a part address lists the links that point at the part, its own back links. The roles, the needuml functions and needsequence ended the build on a part address, andcopy,links_from_contentand a rule’sfromreported an error and gave no value. An address naming a part its need does not have is treated as an id naming no need, except that the two roles report it as:need:reports a missing part. Changed output: a:need_outgoing:or:need_incoming:naming no need, which ended the build too, is now reported as:need:reports one (aneeds.link_refwarning) and rendered as an unresolved reference. The need card’s outgoing row and the list:need_outgoing:renders show a link to a part of an external need as they show one to a local part, linked to the part’s anchor as:need:links it, where they showed the need’s id and linked the need. (PR #2551, PR #2553, PR #2567)🐛 Seven more places read a need part’s address
ID.part, or a link to a part, as a link to a part is read: the address is split once at its first., and names the need when the need has the part.needextract given
REQ_1.p1extractsREQ_1, where it read the address as it read any argument naming no need (as a filter, reported as invalid, or, under an id pattern accepting it whole, as an id naming no need). An argument that is the address of a part an existing need has always names that need, also when it could be read as a filter: given a needvarwith a partflag,var.flagextractsvar. Any other argument is read as before, an address of a part the need does not have included.needextend given a part address still refuses it, with the same warning and strictness, now saying that the address names a part of the need and to extend the need.
needflow’s
:root_id:naming a part starts the walk at the part’s need, where it drew nothing, and the walk follows a link to a part to the part’s need. The walk’s first incoming step follows only the links that point at the part, its first outgoing step follows the need’s links, and every later step follows the links of the need it reaches.A schema’s network rule validates the need a link to a part names, where it reported a broken link (issue #2337).
A link to the empty part,
REQ_1., which no need has, keeps its.where the link is stored, written to needs.json and reported, where the.was dropped.
Given to needextend or
:root_id:, an address naming a part its need does not have is treated as an id naming no need, and a link to one stays a dead link.Changed output:
A
:root_id:diagram whose needs link to parts now holds the needs those links lead to.A needtable link cell splits a link at its first
., where it took the second dot-separated segment as the part, and writes a link to a part its need does not have as text, as it writes a link to a need that does not exist, where it linked#ID.part(issue #2488). A link naming a need whole, whose id holds a., is written as before.A needflow edge is drawn as a part edge when its link names a part, so a link from a need whose id holds a
.is drawn as a link between needs, where it was drawn as a part edge (issue #2488).A link written
REQ_1.isREQ_1.in needs.json, in its dead-link warning and in a filter ("REQ_1." in links), where it wasREQ_1. So a needtable link cell writes it as text, a needflow draws no edge for it and its walk does not follow it from the need that holds it (it still counts inREQ_1’s back links, so a walk intoREQ_1reaches the need holding it), and a schema’s network rule reports it as a broken link, where each read it as a link toREQ_1.
The first build after upgrading reads every document again. (PR #2552, PR #2553)
🐛 The text of a need part written
(id) textno longer keeps the white space after its(id)(issue #1437):(p1) firsthas the textfirst, where it had" first", and a text written on the line after its(id)no longer starts with a line break. White space at the end, which a MyST role can hold, is removed too; white space and line breaks inside the text are kept. White space is Unicode’sWhite_Space. No part id changes, and a part with no(id)keeps its whole text as written. A part a record states keeps its text as given wherever that part is kept, as thepartsof an external need are, but for its line breaks where a need whose content is read takes it (see the entry on the parts a record states, above).Changed output: a part’s text wherever it is shown or read: in needs.json
parts(andcontent.partsof the draft format 2a1); ascontentin a filter; in the text of:need:and of a need card’s link to a part, whose 30-character cut (needs_role_need_max_title_length for:need:) now counts from the first word; in needtable:show_parts:rows and needflow labels, so a needflow image is written again under a new name; and on the page where a part directly follows a character other than white space, such as punctuation:(\ :np:`(p1) first`)renders(first p1)where it rendered( first p1). A filter comparingcontent == " first"must drop the space. The first build after upgrading reads every document again. (PR #2555)🐛 A need part in a need’s content no longer stops a builder from writing its page.
text,manandepubended the build on a page with a part (departing unknown node type: NeedPart), andtexinfowarnedunknown node type: onlyhtmlandlatexknew the node. A writer, another extension’s included, now gets such a part as the inline text it is, with its id and its link. Changed output:xmlandpseudoxmlno longer write aNeedPartelement around a part; the part’sinline(classneed-part, the part’s id) inside it is written as before.htmlandlatexoutput does not change. (issue #2556, PR #2558)🐛 A needflow drawn with the graphviz engine renders when it draws a need part with no text, or a need with no title:
dotrefused the empty<b></b>that took the text’s place, and the whole diagram was not rendered. Such a node is now labelled by its type and id. The PlantUML engine was not affected. (issue #2557, PR #2558)🐛 A needflow drawn with the graphviz engine renders when it draws a need whose type has an empty title in needs_types:
dotrefused the empty<font point-size="12"></font>that took the type’s place, and the whole diagram was not rendered. A node whose type title is empty, or white space only, now has no type line and is labelled by the rest (its title, where it has one, and its id); a need part keeps its(part)line. Every other node’s label does not change. (PR #2561)🐛 A page with a needflow drawn with the graphviz engine builds with the
epubbuilder, which ended the build on it (departing unknown node type: NeedflowGraphiz):epubwrites with the html writer but looks the visitors of a node up under its own name, and another extension sphinx-needs loads registers one there, so a node registered forhtmlalone was unknown to it. Every node sphinx-needs registers forhtmlis now registered forepubwith the same visitors. So a:need:role in the title of a page that a toctree lists, and a need part in a section title, no longer end anepubbuild either. Changed output: a needtable in an epub carries the attributes it carries in html (data-needstable-*on the table,data-*andscopeon its rows and header cells).html,latexand every other builder’s output does not change. (PR #2561)🐛 A needlist, needtable or needextract that lists a need on a page the
latexortexinfobuilder leaves out, such as an:orphan:page or one only another of thelatex_documentsreaches, no longer ends the build (sphinx.errors.NoUri). The need is listed, its text with no link, as Sphinx writes a cross-reference whose target the builder leaves out. Where the need’s page is written, nothing changes, and the output of every other Sphinx builder does not change. (issue #166, issue #347, issue #902, issue #1288, PR #2564)🐛 An incremental build no longer keeps needs of needs_external_needs that an earlier build loaded and the sources no longer give. Such needs stayed in the environment beside the current ones, and kept warning, when a source’s
id_prefix,json_path,json_urlorversionchanged, when a source was removed, or when a need was removed from a source’s file, until a build started from a fresh environment (-E). The needs the previous build loaded are now removed before the sources are loaded again. That step removes nothing else: a need of the project that has taken one of their ids, and an external need an extension added throughadd_external_need, are left as they are. A fresh build does not change. The first build after upgrading reads every document again. (issue #2523, PR #2565)🐛 An incremental build re-writes the page of a need showing a value copied from another need, a derived
copyrule’sfromor theneed_idofcopynaming it, in two cases where the page kept the old value until a full build: the need named has a.in its id and changed, and a need whose id is a part’s addressID.partwas added or removed in another document, so the copy reads that need, or the part’s need again. The page of the need a needextend names by an id holding a.is re-written when the extend changes, likewise. (PR #2567)🐛 A need part’s
titleis its text, wherever a part is read, as a needtable row and:need:already showed it; Filter string said a part keeps its own, and the code read the title of the part’s need (issue #2356). A need’s owntitledoes not change, and a needflow with its default labels shows a part’s text as before.Changed output: a filter that meets a part reads its
titleas its text, whether or not it asks for parts. The filter of a needtable, needlist, needflow, needgantt, needpie or needbar, or of need_count, that teststitle, a needflow’s highlight or border_color, a needgantt’s milestone_filter and a sort_bytitlenow match or order a need part by its text, where the view’s filter tests need parts (needs_views_include_parts), so such a view lists, counts or marks a need’s parts only where their text matches, where it matched them by their need’s title::filter: title == 'Alpha'listed the need titled Alpha and each of its parts, and now lists the need alone. A needlist line of a part shows the part’s text (p1: brake fast), where it showed its need’s title (p1: Alpha); a needgantt element of a part is labelled by its text; a needtable sorted bytitlesorts the rows of parts by their text. A filter or join that asks for parts (include_parts) and teststitle– links_from_filter, a derivedlinksrule’swhere, and the joins of links_from_match and of alinksrule withjoin– matches a part by its text, and no longer matches the parts of a need by the need’s title, so the links it derives can change. In Python,NeedPartItem["title"](NeedPartItem, what an extension, filter code, a filter-func or a dynamic function reads of a part) is the part’s text, and a custom needs_diagram_template that reads{{title}}gets the part’s text. The need’s title is the title of the need a part’sid_parentnames: a filter meant for the parts of a need names that need, such asis_part and id_parent == "REQ_1". needs.json does not change, except through such a derived link and the back links it gives.🐛 A needtable with show_parts lists a need part once, under its need, where a filter matching the need and the part listed the part twice: as a row of its own, and again under its need (issue #336). A part the filter matches whose need is not a row keeps its row of its own. This is decided before the sort and the
:max_items:cap.Changed output: such a table has fewer rows, and its
:max_items:cap counts a need with its parts as one entry, so it can keep more needs than before, and its notice andneeds.max_itemswarning give the smaller total. A part the filter matched is listed once, under its need, without the row style its own row had::style_row:is not applied to a:show_parts:row. This fix changes no table without:show_parts:; such a table whose filter or sort readstitlechanges through the fix above.🐛 A needgantt draws an element whose title holds a line break or brackets, or is empty, where PlantUML refused the whole chart. A need part’s title is its text, where each of these is ordinary, and a need’s title could hold them too. The element’s label is now its title on one line, each run of white space one space, the element’s id when the title is empty, and each bracket written so that the chart draws it as a bracket.
Changed output: a double space, a tab or a no-break space inside a title is drawn as one space. A title with single spaces and no bracket is drawn as before.
🐛 The text of a need part role is on the page where the role makes no part. A second role with a part id its need already has, such as
(p1) the secondafter(p1) the first, and a role outside every need rendered nothing, in every builder:Marks the first p1 and the second here.readMarks the first p1 and here.. Such a role is now its text, as plain text: no id, no anchor, no link and noneed-partclass. The first role of an id is still the part, and theneeds.duplicate_part_idwarning, still one per repetition, now says so (Need 'REQ_1' already has a part 'p1': the first role of an id marks the part, this one is shown as plain text.), where it said the part “may get overridden”, which has not been so since 6.0.0. A role in a section title is not changed and still shows no text.A part’s address
ID.partis now an anchor inlatexandtexinfooutput. LaTeX wrote no label for it, so every link and need reference to a part was an undefined reference in the PDF, and texinfo wrote the anchor at the end of the output file, so a link to a part landed there. Both now anchor it at the start of the part’s text, once per page: where a page shows the part twice, as aneedextractof a need on the need’s own page does, at the first, as a browser does with an id a page holds twice. A part is not anchored at its text in a caption (of a figure, a code block or aliteralinclude), where a LaTeX anchor stopspdflatex, so there it is left as it was in both, nor, in texinfo, in text that writer writes as plain text (an admonition’s title, a hyperlink’s text, acenteredline), so its anchor stays where it was.Changed output: the repeated and the outer roles’ text, in every builder; in
latex, a label at the start of each part, once per page:\phantomsection\labelin running text, a bare\labelin a title, none in a caption; intexinfo, its@anchorthere instead of at the end of the file. A part inhtml,dirhtml,singlehtmlandepubis written byte for byte as before, its id on theneed-partspan, and so is a part inxmlandpseudoxml. Stored parts,needs.json, filters and links do not change. (PR #2577)
Documentation¶
📚 Three corrections: the example under needs_default_style set
needs_default_layoutto'border_yellow', which is neither the option nor a style; it setsneeds_default_style = 'yellow_border'. The class list under Layouts & Styles printed the style class asneeds_style_needs_blue; it isneeds_style_blue, and the list now shows the line a build writes,needs_type_<type>included. needs_flow_link_types and link_types taught the setting as choosing the link types a needflow draws; it changes no diagram on either engine (a needflow without:link_types:draws every link type but the summary ones), and the two pages now say so. The setting is not deprecated. (PR #2598)
Internal changes¶
🧪 A contract for need parts and a conformance corpus that pins it,
tests/fixtures/parts_conformance.toml: a part is an id, a text and the links that point at it, of one need, with no fields, no type and no outgoing links. Its cases, one project each, pin the role’s grammar, which need a part belongs to, a repeated id, the addressID.part[condition], links to a part and their back links, and what a part answers in a filter that asks for parts;design/parts-contract.mdstates the rules and names what is not on the page yet. This repository is the corpus’s repository of record, and ubCode is to vendor it. One case is marked as an expected failure of sphinx-needs: a hidden need has no parts (issue #1321). No behaviour changes. (PR #2550)
9.3.0¶
- Released:
19.11.2026
- Full Changelog:
Qualified need directives lead this release: every need type is also written .. need:<type>:: (a
{need:<type>} fence in MyST), and needs_directive_name says whether the bare .. <type>:: is the need
where another directive has that name too, so a project keeps both sphinx-design’s step and a need type
step. A need id may name a namespace: with needs_namespaced_ids on, nc::m2::REQ_1 is the need
REQ_1 in the namespace nc::m2, and c.in_namespace(), c.id.ns and c.id.local select by it. The
switch is off by default in 9.x and on by default from 10.0: set it either way to keep a project’s reading through
that release. Two further additions are opt-in: the draft needs.json format 2a1 (experimental), whose records
carry each need’s source from project to project, and needs_import_restrict_content, which parses imported
content with file insertion and raw markup switched off. Templates render with minijinja 3.1, where 9.2.0 used 2.x,
and a value a template builds itself may print differently. Several fixes change output; two to read before
upgrading: a boolean is no longer accepted as an integer or number value (PR #2540), and a filter that
fails where it is tested need by need, or a needsequence or needgantt over a part link, a dead link or an unknown
link type, no longer ends the build (PR #2541). ENV_DATA_VERSION is 28, was 25: the first build after
upgrading reads every document again. This release requires ub-needs-exchange 1.2.0 and ub-project 1.3.0.
Improvements¶
✨ Namespaced ids, opt-in: with needs_namespaced_ids on, a need id holding
::names a namespace,nc::m2::REQ_1being the needREQ_1in the namespacenc::m2, and a filter selects a namespace and everything below it withc.in_namespace("nc")(Namespaced ids, PR #2517)Turn it on with
needs_namespaced_ids = True([needs] namespaced_ids = true). It is off by default in the 9.x series and on by default from 10.0: set it either way to keep a project’s reading through that release. With it on, an id is split at its last::, each segment before it made of ASCII letters, digits,_and-; the id itself is unchanged, the need’s key, anchor andneeds.jsonid, and a link names it whole. In a filter,c.id.nsis the namespace as text (""for none),c.id.localthe local id, andc.in_namespace()compares by segments, soncdoes not selectncx::REQ_1(Filtering by namespace (c.id, c.in_namespace)); in Python a need hasid_ns,id_ns_segmentsandid_local. The three filter names are defined in every project; off, every need is in no namespace. The filter names and the attributes are experimental; the switch is not.A project that does not set the switch sees no change but one full re-read of its sources after upgrading (every need now stores its namespace). A project that turns it on sees, besides the new names:
needs_id_regex and a need type’s
id_regexaccept an id whose local id matches, or which matches as a whole: with the default patternnc::REQ_00001is accepted, and every id accepted before still is. As the local id is tried first, a pattern cannot refuse a namespace (^(?!.*::)…acceptsnc::REQ_1);an id the project writes or generates that holds
::but does not split cleanly (A::::B,std::vector<int>::size) is kept as a plain id and reported asneeds.id_namespace, which fails a-Wbuild until the id is corrected, the switch is turned off again, or the warning type is suppressed (suppress_warnings = ["needs.id_namespace"]); imported and external needs are not reported;a dead link or a
:need:role naming a bare id that no need has, and exactly one need has as its local id in a namespace, ends(did you mean 'nc::REQ_2'?);an
id_prefixending in::on needimport or needs_external_needs puts the imported needs into that namespace.
✨ A filter that reads
c.id.ns,c.id.localorc.in_namespace()while needs_namespaced_ids is off is reported asneeds.namespaced_ids_off, naming the filter, once per place it is written (once per build where the place gives no location, such as a constraint): every id is plain then, soc.in_namespace("nc")selects no need andnot c.in_namespace("nc")every need. The answer is unchanged; turn the switch on, or suppress the warning type (suppress_warnings = ["needs.namespaced_ids_off"]). With it, ac.is_anaming no need type (needs.filter_type) is no longer lost in acalc_sumfilter over a computed field, nor at a place with no location (a constraint, say) that shares its filter string with acopyfilter (PR #2518)✨ needs_import_restrict_content, opt-in: the content of a need needimport creates, and the text its templates render, is parsed with docutils’ file insertion and raw markup switched off: an
include,literalinclude,csv-table :file:orrawin it does not run, aneedimportin it reads no file, and MyST’s raw HTML in it is removed (needs.import_restrict). Turn it on withneeds_import_restrict_content = True([needs] import_restrict_content = true); it is off by default in 9.x and planned to be on by default in a later release. It narrows what imported content can do and is no substitute for trusting the file: its entry lists what it does not cover, filter strings, which are evaluated as Python, among them (issue #2259, PR #2542)✨ Qualified need directives and needs_directive_name: every need type is also written
.. need:<type>::(a{need:<type>}fence in MyST), and a project chooses whether the bare.. <type>::is the need where another directive has the name too (PR #2507)needis a Sphinx domain of sphinx-needs’ own that serves each need type’s directive under its qualified name, whatever else the project loads (The qualified spelling: need:<type>). needs_directive_name, and adirective_namein a needs_types entry for one type, say what the bare name is:"claim", the need, over the other directive (what a need type has always done);"yield", the other directive, so a project keeps both sphinx-design’sstepand a need typestep, written.. need:step::; or"qualified", never the need. Both keys are read fromubproject.tomltoo ([needs] directive_name), where ubCode reads them.While neither is given, a need type taking another directive’s name is one
needs.directive_name_clashwarning that names the fix, in place of Sphinx’sdirective 'step' is already registered and will not be overridden [app.add_directive], which said the opposite of what happened. It is silent whereapp.add_directiveis suppressed, as Sphinx’s was. A need type named as astdor primary-domain directive (glossary,data), which a bare directive never reached, is now reported the same way, where nothing was said. A need type’sdirectivewith a:is aneeds.configwarning and its entry is ignored, andadd_need_typerefuses it.✨ needs.json format 2a1 (experimental draft): write it with needs_json_format_version
= "2a1", off by default (PR #2484)Each need in a 2a1 file carries its source: the lines of its directive in the file it is written in, each file it was included through, the needs.json it was imported from, and the docstring or the service it came from, innermost first, then the page it is placed on, with its sections. A record is
{id, type, fields, links, content, source}: every value of the fields its need type declares (a default and a typed empty too: the file carries no schema), but for anull, which is left out and read as unset, links as a bare id or{id, part, condition}, and nothing computed – no back links, nois_*ortype_*keys, none of format 1’s location keys. Theneedsbuilder, needs_build_json and the per-id builder obey the option; needs_json_exclude_fields, needs_builder_filter, needs_reproducible_json and needs_json_include_link_conditions apply, while needs_json_remove_defaults and needs_file are ignored, each with a warning. The format is needs.json format 2a2 (draft).needimport and needs_external_needs read a 2a1 file, and an imported or external need keeps the source its record carries before the hops of this build, so re-exporting it writes them all: the source travels with a need from project to project. Each such hop names the project it belongs to (
origin). What the need answers about where it is from (docname,lineno,sections,section_name,signature,is_external,external_url,c.source) is what it answers read from a format-1 file. Aneedimport:filter:or atarget_urltemplate over the record itself sees less: its fields, links and content, anddocname,sections,section_nameandsignature, but nolineno,is_*,type_name,external_urlor other computed key.A 2a1 file is readable only by the release that wrote it, and each build that writes one says so in a
needs.betawarning (a build that writes noneeds.jsonis not warned). Sphinx-Needs 9.1.0 and 9.2.0 refuse it with one warning per reader that names its format version, 9.0.0 with one that its'versions' is missing, and 8.5.0 aborts the build on it. At the default,1, theneeds.jsonis written exactly as before, but for one case that crashed: a needs_file with noversions(a 2a1 file, say) is oneneeds.json_loadwarning and a new file, where the build stopped with aKeyError.⬆️ Templates render with minijinja 3:
minijinja>=3.0.5,<4, which was~=2.15(changed output) (PR #2475)The data sphinx-needs hands a template prints as before: need fields,
needs_render_contextand the needreport variables are Python values, printed as Python prints them. What moves is a value a template builds itself, mostly towards Jinja2’s behaviour:a list or map a template writes, and every filter result, prints with Python’s quoting (
{{ ['a'] }}is['a'], was["a"]), anditems,dictsortandgroupbygive tuples ([('a', 1)]);tojsonspaces its output asjson.dumpsdoes ({"a": [1, 2]}, was{"a":[1,2]});roundrounds half to even (2.5|roundis2.0), and a negative precision rounds (15|round(-1)is20);//and%follow Python (7 // -2is-4);1 / 0is an error, where it printedinf;2 ** -1is0.5, where it was an error;-foo.barnegates the attribute, where it was an error;titlekeeps an apostrophe’s letter (Don't),min,maxandsorton several attributes ignore case,'%s'|formatand'{}'.formatprint a float in full,findcounts characters, andislowerand its siblings answer as Python’s do;inttakesdefault=andbase=, andmin,max,sumandjointakeattribute=;a macro whose name starts with
_cannot be imported from another template.
It also fixes three faults of 2.x:
{{ 'abc'.count('') }}hung the build forever (it is4), one panic in a template broke every later render on its environment, and a filter that rendered a template on its own environment deadlocked. The full list is minijinja’s own changelog.⬆️ Templates render with minijinja 3.1:
minijinja>=3.1.0,<4, which was>=3.0.5,<4(changed output) (PR #2500)The data sphinx-needs hands a template prints as before. What moves is again a value a template builds or tests itself, mostly towards Jinja2’s behaviour:
trueandfalsecompare and sort as1and0:[true, 2, false, 1, 0]|sortis[False, 0, True, 1, 2], which was[False, True, 0, 1, 2],[true, 1]|unique|listis[True],{true: 'a', 1: 'b'}is the one-key map{True: 'b'}, and[true, 0, false]|minis0;maxandgroupbykeep the first of equal items:max(attribute='a')of two items with the sameais the first,['B', 'b']|maxisB, andgroupby('k', case_sensitive=false)names a group by its first spelling;an undefined value is empty, as in Jinja2:
|lengthand|countof it are0,|firstand|lastare empty, and|itemsis[], where each was an error;none|reverseis an error, where it was empty;titleandcapitalizefollow Unicode’s case mappings ('ΟΔΟΣ'|titleisΟδος, and'džemal'|capitalizeisDžemal);a map reverses:
{'a': 1, 'b': 2}|reverse|listis['b', 'a'], and|lastof it isb, where it was an error;a negative repeat is empty (
'ab' * -1is'', and[1] * -2is[]), where it was an error;replacetakes a count ('aaa'|replace('a', 'b', 2)isbba).
It also turns two panics into ordinary results:
4 is divisibleby(0)is an error that says it cannot calculate4 % 0, and a slice with a negative step works ([1, 2, 3][5:0:-1]is[3, 2]). The full list is minijinja’s own changelog.👌 needs_from_toml is read as TOML 1.1, through ub-project 1.3.0, which this release requires: an inline table may span lines or end with a trailing comma, a string may use the
\eand\xHHescapes, and a time or a datetime may leave out its seconds; valid TOML 1.0 reads as before (PR #2476)
Bug fixes¶
🐛 needs_json_format_version can be set on the command line:
-D needs_json_format_version=2a1writes a 2a1 fileSphinx converted a
-Dvalue by the type of the option’s default, the integer1, so2a1was dropped as an invalid number and the file was written in format 1. The value is now passed through as the text it is, and the text"1"is format 1 wherever it is set (-D needs_json_format_version=1,conf.py,ubproject.toml); fromconf.pyandubproject.tomlit was reported as an unknown value. Unset, the option still reads the integer1. A build whose value differs from the previous build’s reads the project again, so that it writes the file in the format asked for on every supported Sphinx (on Sphinx 7.4 a build that read nothing wrote no file);-D needs_json_format_version=1after a build that left the option unset, or the reverse, is such a build: the text and the integer are both format 1 and differ as values (issue #2530, PR #2539)🐛 A needsequence over need ids holding
::(or another character PlantUML refuses in a name, such as-) renders, and shows each participant by its title or its id (PR #2515)It wrote each need id as it is as a PlantUML participant name. For a participant that sends a message, which is declared with its title, an id such as
SUPPLIER::USER_A(which the default needs_id_regex accepts) orUSER-Amade the diagram a PlantUML syntax error, and so did a receiver that sends none, but for one whose id holds:, which was drawn wrongly instead (SUPPLIER::Bas a participantSUPPLIERwith the message:B: …). A participant is now named as needflow names a need in a PlantUML diagram, over the participants of the one diagram: each character PlantUML refuses in a name becomes_, and two ids that become the same name are told apart by a numeric suffix. What the reader sees keeps its text: a participant that sends a message shows its title, and a receiver that sends none shows its id, as before; in a diagram where such a receiver’s name is not its id, every such receiver is declared, in the order the arrows reach them. The message labels are unchanged, and a diagram whose ids hold none of those characters is written as before. The first build after upgrading reads every document again.🐛 The default item of a variant may hold
::, as a need id such asSUPPLIER::REQ_2does (PR #2515)<<[False]:X, SUPPLIER::REQ_2>>read its last item as the variant nameSUPPLIERwith the value:REQ_2, so the field or link was left empty with aneeds.dynamic_functionwarning thatname 'SUPPLIER' is not defined. What remains of a variant is now its default value when it holds no single:(one with no:beside it), so the value isSUPPLIER::REQ_2. While a single:remains, an item’s name ends at its first:, as before: a variant reads differently only where the colons left in it all stand in runs of two or more (<<x:nc::A, nc::B>>,<<a:::b>>), and<<debug::need:`X`>>still namesdebug. The first build after upgrading reads every document again.🐛 needs_build_json_per_id and the needs_id builder encode the characters of a need id that a file name cannot hold on every system, such as
:, in the name of the need’s file (changed output) (PR #2515)Each file was named
<id>.jsonwith the id as it is, soSUPPLIER::REQ_1, which the default needs_id_regex accepts, gaveSUPPLIER::REQ_1.json, a name Windows refuses, and an id holding/could not be written (an error).<>:"/\|?*, the control characters U+0000 to U+001F and%are now each written as%and two upper-case hex digits (SUPPLIER%3A%3AREQ_1.json), in both needs.json formats. The file of an id holding none of them keeps its name, and every file’s content is unchanged; files an earlier release wrote under the old name are not removed. Not handled: an id too long for a file name, Windows’ reserved device names (NUL,CON, …), and names differing only by case.🐛 An
id_prefixof needimport or needs_external_needs leaves a longer::-joined id in a need’s content as it is (changed output) (PR #2515)The prefix rewrites each id of the file written in a need’s content, and it took
:as a word boundary, so with the file idPLAIN_1and the prefixSUP::the textother::PLAIN_1becameother::SUP::PLAIN_1andPLAIN_1::xbecameSUP::PLAIN_1::x, although neither names the file’sPLAIN_1. A file id directly after a::that follows a letter, digit,_or-, or directly before a::that one of those follows, is now left as it is, whatever the prefix; any other character beside the::(white space, punctuation, a third:, the end of the text) joins nothing. So an id of the file that itself holds::(nc::REQ_1) is still rewritten as a whole, and so are an id beside a single:(:need:`PLAIN_1`,PLAIN_1: text) and one before a::that ends the text or is followed by white space (see PLAIN_1::before a literal block). Each id of the file is tested on its own, so where a longer file id is now left as it is, a shorter file id inside it may be rewritten: with the file idsREQ_1.SUB_2andSUB_2,x::REQ_1.SUB_2becomesx::REQ_1.SUP::SUB_2, where it wasx::SUP::REQ_1.SUB_2. The first build after upgrading reads every document again.🐛 A one-word needextend argument holding
(,=,'or"is a filter (changed output) (PR #2515)needextendread every one-word argument as a need id, soc.this_doc(),c.is_a('req')andstatus=="open", written without a space, were reported as ids that do not exist (and ended the build under needs_needextend_strict). A one-word argument holding any of(,=,'or"is now a filter; every other one-word argument is an id, as before, so a comparison without=such aspriority>3is still read as an id (write it"priority>3"). A one-word argument naming an existing need whose id holds(,=,'or"is now a filter too; write it<id>(<REQ_001(A)>), as<…>still forces an id. The first build after upgrading reads every document again.🐛 A filter that is not a Python expression no longer aborts the build where a view’s
:filter:, theneedextractargument, aneedpieorneedbar:filter:or line,need_count, needuml’sfilter(), needs_warnings or needs_builder_filter takes it (PR #2515)needextract:: nc::missing(an id the needs_id_regex refuses is read as a filter), or the same string as the:filter:of aneedtable,needlist,needflow,needgantt,needextract,needpieorneedbar, a line of aneedpieorneedbar, aneed_count, needuml’sfilter(), a needs_warnings entry or the needs_builder_filter, ended the build withinvalid syntax. It is now oneneeds.filterwarning naming the string and the error, at the directive, where there is one, and it matches no need.needextend’s filter form andcopy(filter=...), which reported such a string already, keep their messages. needflow’s:highlight:, needgantt’s:milestone_filter:, needs_constraints and needsequence’s:filter:report it too, as any filter that fails there (issue #2252). Not changed: a filter too deep for Python’s parser still ends the build, as before.🐛 Every link condition reads back as it was written, one that ends in
]or starts with[included, so aneeds.jsonwritten with link conditions keeps them through needimport and needs_external_needs (changed output) (issue #2489, PR #2494)A condition runs to the closing brackets that end the link, as many
]as it was opened with:REQ_001[status in ["open"]]andREQ_001[[x == a[0]]]are the conditionsstatus in ["open"]andx == a[0]. A need directive with such a link was refused (needs.create_need), andneedimportand external needs dropped its condition without a warning, also from a needs.json sphinx-needs wrote itself. A condition that starts with[read back as another condition, or not at all: one that also ends with]is now written with one space after the opening brackets (REQ_001[[ [x] == a[0]]]), which the reader drops, and one that does not is read where the link closes with fewer brackets than it opened with (REQ_001[[1] == y]). Every link that was read without a warning is read as before; a link that was malformed may now read as a link with a condition.🐛 A
:need:reference to a part of an external need names the part and links its anchor (changed output) (issue #2487, PR #2493)It rendered the external need’s bare id and linked the need, so the part was lost, and so was a text given in the role. It is now written as a reference to a part of a need of the project: the part’s text and the full
ID.part(first part text (UP_001.p1)), or the role’s text, keeping the external need’s css class. The link goes to the part’s anchor,#UP_001.p1, when the fragment of the external need’s URL is the need’s id, alone or after theid_prefixof one of the project’s external sources, as on the default…/<docname>.html#<id>. Atarget_urlof another shape is linked as it is. A reference to a whole external need still renders its id, also with a text given in the role.🐛 A part id repeated in one need is reported once, as
needs.duplicate_part_id, and no longer also as a part “not associated with a need” (needs.part); the first part of the id is still the one kept (issue #2485, PR #2492)🐛
add_needwarns, once per need, of thepartsit was given that a need on a page drops (issue #2486, PR #2492)A need on a page takes its parts from its content (its need_part / np roles), which replaced the given ones silently. The result is unchanged: a given part whose id the content marks takes the content’s text, and an external or a hidden need keeps the parts as given. Now each other given part id is named in one
needs.partwarning.🐛 A
full_titlethat is not a string no longer aborts the build:create_needrefuses it with a warning, and aneedserviceneed takes no full title from a link type or a value that is not a string (issue #2479, PR #2491)create_need,add_need,generate_needandgenerate_need_idraiseInvalidNeedException(invalid_value, “full_title must be a string, not list”) for afull_titlethat is neitherNonenor a string, which a producer reports as it reports any refused need. That holds whether or not anidis given: without one they raisedAttributeError: 'list' object has no attribute 'encode', which ended the build, and with one the value was ignored. Aneedservicedatum’sfull_titleis the full title a need without an id has its id hashed from only when it is a string and the project has no link type of that name, as for a sphinx-codelinks one-line marker; it is still the need’s link or field. So a service need whosefull_titleis a list (a link type, or a field declared as an array) is created, with the id of its title, and one whosefull_titleis a link given as a string now has the id of its title, where it had the id of the link’s value (changed output).🐛 A link type named
full_titleis kept onneedimport, external needs and codelinks multi-line needs (issue #2466, PR #2477)A needs.json written by sphinx-needs 5.0 or earlier carries a legacy
full_titlestring on every need: in a project with such a link type it is now read as that need’s link targets, one warning per unknown target (link_outgoing, orexternal_link_outgoingfor an external need), where it was dropped silently; filter those needs out with theneedimport’s:filter:, or rename the link type (the only way out for external needs).🐛
needimport’s own warnings name the file and line the directive is written on, not the parser’s running line, under anrst_prologor an include (changed output) (issue #2463, PR #2478)Inside an included file they named the including page; they now name the included file and the line the needs the directive imports record, also in an include sliced by
:start-line:. Every warning of one directive names that one place, those about its records (an empty id, a need that cannot be created, unknown keys) included. Aneedimportthat another extension generates is written in no file, and is still reported at its page.🐛 A field or link type named
descriptionis kept onneedimport, external needs and codelinks multi-line needs, also on a need without content, so a project’s own needs.json reads back as written, unless it is written withcontentexcluded (changed output) (issue #2465, PR #2481)sphinx-needs before 4.0 wrote a need’s content as
description; that legacydescriptionis now read as the content only when the record has nocontentkey, after its schema defaults are merged – the rule of ub-needs-exchange 1.2.0, which this release requires. A need without content, which sphinx-needs writes as"content": ""(or, withneeds_json_remove_defaults, as the schema’scontentdefault), lost itsdescriptionfield into the content, and a need with neither content nor adescription(a nullable field written asnull) was refused. A link type of that name was refused onneedimportand external needs and lost on a codelinks block. A body-less codelinks block without an id and with an empty title is given the id codelinks predicts for its duplicate check and[docs]link, and a body-less imported need no longer warnsneeds.import_doctypeunder:parse_by_doctype:. A file written withcontentexcluded (needs_json_exclude_fields) has nocontentkey and reads as a pre-4.0 file, as before: itsdescriptionis taken as the content.A hand-written record with an empty
contentbeside adescriptionmeant as its content now keeps the content empty, and, in a project that declares nodescription, an imported need reports that key as unknown (needs.unknown_import_keys, orneeds.unknown_external_keysfor external needs); move the text into thecontent. One whosecontentis not a string (null,0,false,[],{}) beside adescriptionis refused, as such acontentalready is without one.🐛 A filter string with leading spaces or tabs selects what it selects without them in needs_warnings, needs_builder_filter, a
needpieline, needuml’sfilter(), the filter of the dynamic functionscopy,links_from_filterandlinks_from_match, and a quoted needextend argument (changed output) (issue #2521, PR #2537)" status == 'open'"was refused there asnot valid(unexpected indent) and matched no need: aneeds_builder_filterwritten so exported none, aneedextendextended none and the dynamic function failed, while a constraint or a link condition read the same string past its padding, as Python’sevaldoes. These places now read past exactly whatevalreads past, spaces and tabs (a newline or a form feed followed by a space is still refused, asevalrefuses it); ac.is_ain such a string naming no need type is reported (needs.filter_type) as in the unpadded one; and a warning quoting the filter quotes it as written. A derived field’swhereandtestare the exception: a declared rule, which must parse as written, so a padded one is still refused (needs.derive_invalid). A directive option such as:filter:was never affected: docutils strips it.🐛 A
c.is_anaming no need type is reported once at each place it is written, with the place’s file and line (an external need’s link condition names the need), where a filter is tested need by need – a needflow:highlight:, a needgantt:milestone_filter:, a needsequence:filter:, a link condition – and at each of two needextends of one document with the same quoted filter (changed output) (issue #2528, PR #2537)There,
needs.filter_typewas reported once per build for the string with no location, however many places wrote it, and a place with no location sharing the string (a constraint) took their report; a highlight, milestone filter or sequence filter that no need was tested on, and the second of two suchneedextends, were not reported. It is now reported together withneeds.namespaced_ids_off, at the same places and as often; a constraint, which has no location, is still reported once per build for its string.🐛 A boolean is no longer accepted as an
integeror anumber:trueorfalsein such a field, or as an item of an array of either, is refused as any other value of the wrong type is (changed output) (issue #2533, PR #2540)Python counts a
boolas anint, so the type check let a boolean through: the need was created holding it, the schema validation then reported it (sn_schema_violation.field_fail), and a filter such aseffort > 0was true for it. A needimport, external orneedservicerecord holding such a value is now refused with that route’s own warning (needs.import_need,needs.load_external_need,needs.load_service_need), and so is a record that takes a boolean default from the file’s ownneeds_schema. A project’s own code calling the creation API (create_need,add_need,add_external_need,ingest_need_record,generate_need) with such a value gets theInvalidNeedExceptionit gets for any other value of the wrong type, where the need was created before (silently, withneeds_schema_validation_enabled = False). A booleandefaultorpredicatesvalue of such a field is reported asneeds.configand not used, and on a need type asneeds.type_conflict(it was refused asneeds.type_wideningbefore). A dynamic function or variant data returning a boolean for such a field is reported asneeds.dynamic_function, and the value is dropped. An integer is still anumber.🐛 A filter that fails where it is tested need by need – a needflow
:highlight:, a needgantt:milestone_filter:, a needsequence:filter:, a needs_constraints check – no longer aborts the build (issue #2252, PR #2541)A filter there that is not Python (
nc::MISSING), names what a need does not have (ab == 1), raises while it is evaluated (int('x') == 1) or is a constant ended the build with a traceback (NeedsInvalidFilter). It is now reported as a view’s:filter:reports it: oneneeds.filterwarning naming the string and the error, at the directive, however many needs it fails on. It matches no need it fails on and answers every other need, so a filter that fails on every need highlights no need, makes no task a milestone and draws no message. A constraint check, which has no directive, is reported once, ending(from constraint 'c1', check 'check_0', first on need 'REQ_1'), and is not evaluated on a need it fails on: it neither passes nor fails there, runs noon_failaction, and the need’sconstraints_resultsandconstraints_passedare what they would be had the check not been declared. A filter that works selects what it selected.🐛 A needsequence or needgantt over a link to a need part, or to a need that does not exist, or with a link type that does not exist, no longer aborts the build (issue #2336, PR #2541)
Both looked a link up as a whole need id, so a link such as
USER_B.p1, and a dead link, ended the build with aKeyError. A link to a part the need has is now a link to the need owning the part (a needsequence message toUSER_B, a needgantt constraint at[USER_B]). A link to a part the need does not have (USER_B.nopart), like a link to a need that does not exist, is a dead link: it is left out of the diagram, as needflow draws no edge for it, and the dead-link check reports it, as it did (needs.link_outgoing). In a needsequence’s:link_types:, a link type written in another case (LINKS), which the directive accepts, ended the build; it is now walked as the link type it names (links). A back-link name (links_back) gets the directive’s “Unknown link type” warning (needs.needsequence) and is walked, as before. A name that is neither a link type nor a back-link name ended the build right after that warning; it is now left out after it. A name in a needgantt’s:starts_with_links:,:starts_after_links:or:ends_with_links:that is no link type (a back-link type such aslinks_backincluded) ended the build (SphinxNeedsLinkTypeException); it is now oneneeds.needganttwarning with the same text, at the directive, and is left out.
9.2.0¶
- Released:
04.11.2026
- Full Changelog:
Where a need comes from is the first story of this release. Each need records the places its text came through –
the file its directive is written in, an included fragment, the needs.json it was imported from, the test report it
was read from, the code entity a sphinx-codelinks marker is attached to – and a filter reads them as
c.source: c.source.kind, path, line, paths and symbol select the needs
traced from code under ../src/, the needs of one test report or those written in one fragment, answered without
eval. Extensions create needs through the new create_need(), with the fields and
links as two mappings and one NeedItemSource, and ask which option a need type’s directive takes with
resolve_need_option; add_need is deprecated in its favour, and a new section of the API page says
what is public. The second story carries on the per-type model of 9.1.0: a link type derives a
chain’s far ends as links, a summary link type marks a shortcut across the trace, c.is_a('req') follows
inherits, a need type declares a severity, the back links it must receive and the shape of its ids, an
extension declares a field on its own need types alone (add_field(..., types=[...])) and a project’s
needs_types entry narrows an extension’s type, copy takes where and any / all take empty.
Several fixes change output: a need from a needimport, a needservice or a sliced include records the line it
is written on, a need inside a C, C++ or JavaScript domain object takes that object’s name as its signature, a
hidden need is located as a visible one in its place is, and an incremental build re-writes every page showing a
need that changed. A directive option now matches a field or link type ignoring case, and two names equal ignoring
case are a configuration error that stops the build. The first build after upgrading reads every document again.
This release requires ub-project 1.2.0.
Improvements¶
✨
c.sourcein a filter reads where a need comes from: the needs traced from code under../src/, the needs from one test report, the needs written in an included fragment (Filtering by where a need comes from (c.source))Beside
c.this_doc()andc.is_a():c.source.kindis the producer (import,external,report,code,generated,page),c.source.pathandc.source.linethe file the need is written in and its line there,c.source.pathsevery file it came through that the build records, innermost first (test membership: it may gain entries), andc.source.symbolthe qualified name of the code entity a traced need is attached to;c.source.documentandc.source.sectionsare aliases of the need’sdocnameandsections. A path is relative to the source directory, with..for a file outside it. A facet the build does not know yet isNone– the path of an imported or an external need, or of a test case – and later releases only fill it. The facets are in the portable filter language, answered withouteval, and computed only where a filter reads them. They are not available in a field predicate, a needimport:filter:or a variant condition, where the error says so.docname,sections,lineno,is_import,is_externalandsignatureare unchanged.✨ A link type derives a chain’s far ends as links:
copyofidandcollectof a link type, over a link type, declared on a link type (A chain as links: copy and collect on a link type, issue #2370){ kind = "copy", field = "id", over = "satisfies" }on a specification and{ kind = "collect", field = "chain", over = "implements" }on the rungs below give every need of the chain the requirements it traces to as links, and each requirement the needs that reach it as back links. Each link is kept once by its target and part, its condition dropped; a dead link is carried, and reported where it is written. Such a link type is a summary (summary = falsebeside the rule is refused), counts towardneeds.derive_dense, and is computed with the link types: anovernaming back links, and afieldnaming a value field or back links, are refused at load (needs.derive_invalid), and needs reading one another’s chain around a ring areneeds.derive_cycle.overmay name a union, read through its members, so a chain climbs several link types at once (over = "trace_up"); acollectof its own link type over a link type another kind of rule computes is refused. A dead link carried is flagged (has_dead_links) and drawn forbidden only as the link type it is written in says. Acollect, or acopyover a link type another rule computes, links needs its need does not name, so in a project with one every change of a need re-writes every need-relevant page on an incremental build (Incremental builds). On a field,copyandcollectare unchanged.✨ Summary link types:
summary = trueon a needs_links entry, or on a need type’s entry of a link type declared on need types alone, marks a link type whose links are shortcuts across the trace rather than steps in it, such as a test result linked straight to the requirements it covers (Summary link types, issue #2370)It works as any link type wherever it is named (a filter, a needtable column, a rule’s
over, a needflow’s:link_types:, a schema rule), and a need holds its links and back links as usual; but a needflow without:link_types:neither draws it nor walks it from:root_id:, so a diagram does not show every path twice. The schema of theneeds.jsonmarks it, and its back links,"summary": true, and aunioncannot name it as a member (needs.derive_invalid). It is set on the link type for every need type: on a link type declared on need types alone, by the first need type’s entry declaring it, which the others may repeat or leave out (another value isneeds.type_conflict, that entry ignored); on one declared inneeds_links, a need type’s entry giving it is aneeds.configwarning. In a rule it is no key (needs.derive_invalid);copy = truebeside it is aneeds.configwarning, and nothing is copied intolinks. Without it nothing changes.✨
c.is_a('req')is true for a need whose type isreqor inherits from it (issue #2322, issue #2402)type == 'req'compares the type’s name alone;c.is_a('req')follows inherits, directly or through other types, as the project’s need types declare it: withsys_reqinheritingreqandhw_reqinheritingsys_req, it selects the needs of all three, astype in ['req', 'sys_req', 'hw_req']does. It reads the need’s type and the need type declarations, and no field: a need carries no list of its types. A name that is no need type selects nothing; a string literal naming one is reported asneeds.filter_type, with the type it is the title of or is close to: once per filter and place it is written, once per filter string where it has no place (such as a derived field’swhere), and once per needs_warnings entry, naming it. Silence a deliberate one withsuppress_warnings = ["needs.filter_type"]. It is a check besidec.this_doc(), in the portable filter language with a string literal as its argument, answered withouteval, and in theevaltier for any other argument. It reads the need alone, so it is available in a filter configured inconf.pyand in a derived field’swhere, wherec.this_doc()is not; likec.this_doc(), it is not available in a needimport:filter:nor in thepredicatesof a needs_fields entry.c.is_atests the need’s type: to follow a link type namedis_a, use the link. See Filtering for a type and the types inheriting from it.✨ A needs_types entry naming a need type an extension adds narrows that type, where it was ignored (issue #2371)
An entry for sphinx-test-reports’
testcase, or any type an extension adds withadd_need_type, is a narrowing of it, as an entry naming a default type is: the keys it gives win, thetitle,prefix,colorandstyleit leaves out are the extension’s, and itsinherits,fieldsandlinks(withderive,target_types,minItems/maxItems, a narrowerschema) apply to the type’s needs, as on a type the project declares, whenever the extension adds the type. So[needs.types.testcase.links.evidence_for] derive = {...}gives test cases a derived link type of their own (joining on thecase_nameoftestneeds takes[needs.types.test.fields.case_name]too, once sphinx-test-reports declares its fields on its own types, below). The entry takes every key of a need type’s,back_links,id_regexand a field’sseverity(below) included, and only narrows: its declaration of a field the extension declares starts from the extension’s, so one widening it is aneeds.type_wideningwarning (one re-typing it aneeds.type_conflict), and is ignored. A bare entry still declares no type (the default types are kept beside it). A bare entry naming no default type and no type an extension adds is ignored as before, but reported once the schema is built, namingderive_by_typeas the spelling that attaches a rule to a type the project does not declare – the documentation now says that is whatderive_by_typeis for, rather than only that it is older. The GitHub services’ types are not narrowed: an entry with atitleand aprefixreplaces one, and a bare entry for one is ignored, with a warning naming the service’s type. See narrowing an extension’s type.✨ An extension declares a field on its own need types alone:
add_field(name, description, types=[...])(issue #2372)The field is the extension’s declaration – its schema,
nullableand default – on the need types named (and the types inheriting from them), and absent on every other type, exactly as a field a project’s need type entries declare alone:Nonethere, and a value set there is oneneeds.undeclared_for_typewarning. A project need type that carries the field names it in its entry ([needs.types.test.fields.case_name], an empty entry included), which declares it there too; aneeds_fieldsentry of the same name is the field, on every type, as before. A type named that nothing declares when the schema is built is oneneeds.configwarning, the field declared on the others.FieldsSchema.declaring_types(name)names the types declaring a field declared on need types alone, either way, and the needs.json schema writes such a field nullable where the extension’s declaration is not, with anulldefault where it gives no literal one (soneeds_json_remove_defaultsleaves the key out). sphinx-test-reports declares its eighteen fields this way from 4.0.0. See fields an extension declares on need types alone.✨ Each need now records where its text came from, as a list of hops on
need.source(provisional; see Python API, PR #2399)need.source.hopsstarts at the innermost place sphinx-needs knows the need came through – the file a directive is written in (an included file’s own, in an include), theneeds.jsonan imported need was read from, the service that made a need, an external need’s page, with its sections there – and ends at the page the need is placed on, with its sections and the domain objects it is written in (an external need has no such page). In a nested reStructuredText include, each file the need’s file was included through is a hop between the two, innermost first and with no line (a MyST{include}is never recorded, so a chain through one records its reStructuredText links alone). A need an extension creates on its page (NeedItemSource.on_page,add_need) records the page’s file, with no line. A need in a docstring autodoc reads starts at acodehop of its Python file, with the languagepythonand, where the definition autodoc names holds the need in its docstring, that definition’s file (for a member inherited from another module, that module’s) and its name in the file in sphinx-codelinks’ Python kinds (class Shape > method area), with its qualified name rendered as sphinx-codelinks renders it (Shape.area,make.<locals>.Made), so it compares with the code hop of a sphinx-codelinks marker in the same docstring. A sphinx-codelinks marker’s code hop carries the qualified name its analysis renders (ns::Widget::draw,<Widget as Shape>::area). A hop records a line range only where the file, read from disk, holds the need’s text there: under reStructuredText every line of the directive equals the file’s line (whole lines), under MyST the line opens the directive’s fence with its name and title; elsewhere it records no line (it can still be wrong only where the file holds an identical copy of the need’s text at the line the parser claims). It is provisional until it reachesneeds.json: through 9.x a minor release only adds to the shape, and a rename or a removal waits for 10.0 (What is public). Nothing a filter, a table orneeds.jsonshows changes; the first build after upgrading reads every document again. The five concreteNeedItemSource*classes this release started with are one class now,NeedItemSource(below);NeedItemSourceProtocolis unchanged.✨ A derive rule of kind
copytakeswherebesideoverorjoin(copy, issue #2246)wherenarrows the targets beforeselectreads them, as it does for the other kinds and forlinkswithjoin:select = "first"takes the lowest-id target that passeswhereand sets the field,"unique"counts only those, and"list"keeps their values. A target the filter cannot be evaluated on is dropped, without a warning. Acopyof the need’s own field, or of the needfromnames, still takes nowhere(needs.derive_invalid).✨ A derive rule of kind
anyoralltakesempty, the value it gives over no candidate (any and all, issue #2377)Over no candidate
allistrue, which on a requirement nothing tests reads as “every test passed”;all_passed = { kind = "all", test = "status == 'passed'", over = "tests_back", empty = false }givesfalsethere instead. No candidate is what is left oncewherehas dropped the needs it does not hold on. Unset,emptyis the kind’s own value (alltrue,anyfalse), so no existing rule changes; on any other kind, or with a value that is not a boolean, the rule is refused (needs.derive_invalid).✨ A need type’s declaration of a field or link type carries a
severity: a constraint reported, not failed (issue #2374)severity = "warning"(or"info") on a[needs.types.<t>.fields.<f>]or.links.<l>entry is the severity of every constraint of the type’s declaration – itsschemakeywords, its links’minItemsandmaxItems, andnullable = false– where each was aviolation. The failures are reported assn_schema_warning.field_fail(sn_schema_info.*), a warning rather than an error. A field not nullable belowviolationis asked for, not enforced: a need without it is created, the fieldNone, and reported at that severity (schema pathfields > nullable), so switching the schema validation off (needs_schema_validation_enabled) silences it; the needs.json writes such a field nullable. A type inheriting the declaration keeps its severity and may raise it; one lowering a severity an ancestor gives is aneeds.type_wideningwarning, and is ignored. Aseverityon a needs_fields or needs_links entry, which takes none, is aneeds.configwarning. Without aseveritynothing changes. The fields-per-type conformance corpus may now pin a finding’s severity. See A constraint reported, not failed.✨ A need type declares how many links it must receive:
[needs.types.<t>.back_links.<l>]takes a count (issue #2375)schema = { minItems = 1 }on aback_linksentry named after a link typelsays that every need of the type is the target of at least onellink, its back links<l>_back(maxItems: of at most so many), so acoverage-*-backschema rule that only counts folds into the type’s declaration. The count is every link oflto the need, asminItemscounts the outgoing ones (a link to a part of the need included); it is inherited, and narrowed, by the types inheriting from the type; it is checked by the schema validation once every link is final, alink_failof the field<l>_backat the entry’sseverity; a need from needs_external_needs is not counted, an imported need is. The entry takes adescription,minItemsandmaxItems, and aseverity; any other key is aneeds.type_conflict, and so is an entry naming no link type (“did you mean” the link type it is close to). Alinksorfieldsentry named<l>_backis still refused, and now names theback_linksentry.back_linksis a key of a needs_types entry. This supersedes the proposal of issue #2323. See Links a type must receive.✨ A need type declares the shape of its ids:
id_regexon a[needs.types.<t>]entry (issue #2373)The id of a need of the type matches the pattern, beside needs_id_regex and the
id_regexof every type it inherits from, checked where and asneeds_id_regexis (re.match, an authored or a generated id, never an imported or external need’s): a need whose id does not match is not created (needs.create_need, naming the pattern and the type that gives it). So anid-prefix-<type>schema rule folds into the type’s declaration when a wrong id should refuse the need; one that should only be reported stays a rule. A pattern that is not a regular expression is aneeds.type_conflictwarning, and is ignored. See The ids of a type.✨
create_need: an extension creates a need with its fields and links as two mappings, and gets the need back with its nodes (issue #2137)sphinx_needs.api.create_need(app, state, source, need_type, title, *, id, fields, links, content, ...)takes the need’s field values asfields(the core fields such asstatusandtags, and the project’s fields) and its links aslinks, kept apart from its own parameters, so any name a project gives a field can be used. It returns(need, nodes): the need as recorded, which an extension no longer has to look up or re-derive the id of, and the nodes to insert. Its location is aNeedItemSource(below), and only one: any other object, one with theNeedItemSourceProtocolinterface alone included, is refused with aTypeErrornamingNeedItemSource.from_directive(self)andNeedItemSource.on_page(docname, lineno=...). A name in the wrong mapping, or one of its own arguments given in a mapping (title,content, …), is refused, naming where it belongs. This package’s need directives,list2needandneedservice, sphinx-codelinks’ one-line needs and sphinx-test-reports’ needs are created through it;needimport,needs_external_needsand sphinx-codelinks’ multi-line needs through the same path, as records.add_needis deprecated in its favour (see Deprecations). Seecreate_need().✨ Extensions that wrap or preset need directives can ask which option a need type’s directive takes for a name:
sphinx_needs.api.resolve_need_option(app, need_type, name)It answers as the need directive matches an option it is given, against the same names – the directive’s own options (
id,status,hide, …) and every field and link type the project declares (one another need type declares alone is matched too, and the directive then reports it as not declared for this type) – a name equal to one first, else one equal ignoring case, returned as declared ("owner"and"OWNER"give a field declaredOwner), andNonefor no such option; a need type the project does not have is aValueError. It is available once sphinx-needs has built the build’s schema, in its ownenv-before-read-docshandler: from a handler at a priority above 500, or any later event. Called earlier, it raisesRuntimeError, also on an incremental build, where the previous build’s schema is still in the environment. So an extension no longer keeps its own copy of the directive’s options. Seeresolve_need_option().✨
NeedItemSource: one class for where a need comes from, public fromsphinx_needs.api, withNeedItemSource.from_directive(self)as the source of a need an extension’s directive creates andNeedItemSource.on_page(docname, lineno=lineno)for a need at a line the caller gives (issue #2137)The source
create_need()takes is one frozen class,NeedItemSource: the hops the need’s text came through, and the location facts the hops cannot give yet (lineno,lineno_content,parser_lineno,is_import). Every need sphinx-needs creates has one, and so does every need sphinx-codelinks and sphinx-test-reports create. In a directive,NeedItemSource.from_directive(self)records what a need directive records: the line the directive is written on (resolved throughrst_prologand includes), its parser line and content offset, and the file and page it is written in, after any hops given asfirst; it takes any docutilsDirective, not only aSphinxDirective.NeedItemSource.on_page(docname, lineno=lineno)gives a need its page and the line the caller passes, the sourceadd_needbuilt: for a need at its directive’s parser line, asadd_needtook it (sphinx-codelinks’ needs sit there), or at a line the directive’s data names. The class’s name,from_directiveandon_pageare stable, and so is reading a source throughNeedItemSourceProtocol; the general constructor and its keywords (hops,lineno,lineno_content,parser_lineno,is_import) are provisional, for sphinx-needs’ own producers and advanced use, ashopsand the hop types,NeedSourceHop,NeedSourcePhysicalandNeedSourceSemantic, now also importable fromsphinx_needs.api, are, untilneeds.jsoncarries them: through 9.x a minor release may add an optional field, a hop kind or a keyword, and a rename, a removal, or a change to an existing one’s meaning or type waits for 10.0, because published sibling extensions construct them (What is public). A need’sdocname,linenoand the other location keys are unchanged, and so isNeedItemSourceProtocol, which is how a need’s source is read; the first build after upgrading reads every document again. See Migrating from add_need.👌 A needs_fields entry naming a core field a need computes (
type_name,docnameand the other core fields that take no declaration) is reported as ignored, with aneeds.configwarning, where it was ignored silently. Nothing read such an entry, so no output changes, but a build run with-W(warnings as errors) that has one now fails until the entry is removed👌 The
needs.derive_scopewarning at a needextend whose filter names a computed field says what computes it: “a derive rule” for a field a derive rule computes, “a dynamic function or variant” for a[[…]],<<…>>or<{…}>, and “a derive rule, a dynamic function or a variant” when the filter names fields of both, as ubCode words it (issue #2207)It said “a dynamic function or variant” for a derived field too, where the project wrote neither. The warning’s code and severity are unchanged.
👌
-D needs_variant_data_fileswaps the data file, never the table it is read from (issue #2378)The rule is now ub-project’s reading contract (section 6.8), shared by every tool that reads
ubproject.toml, and sphinx-needs passes the value to it rather than removing keys from the toml itself. For a project that builds without warnings, nothing changes in the output (a project on the legacy location gains one-vline naming it, as it has without-D): the value replaces the data file of the location read,[variants]or[needs], without opening the toml’s own file, and that location’s inline table still applies;-D needs_variant_data_file=(no file) replaces it by none, so the location’s inline table is used alone. The location, the refusals and the warnings are now always those of the toml as written, so two projects that already warned or failed without-Dnow do so with it too: a[variants]declared by itsdata_filealone stays the location read, with theneeds.variant_data_locationwarning for the[needs]keys beside it, where[needs]used to be read silently; and an empty or non-stringdata_fileis refused. See Variant data: the [variants] table.👌 An unknown key in a field’s or a link type’s entry, and an unknown keyword in its
schema, is reported and ignored (issue #2206)A key a needs_fields, needs_links, needs_extra_options or needs_extra_links entry does not have, such as a misspelt
deriveortarget_types, was ignored in silence, so a field meant to be derived stayed authorable and a link type meant to be restricted was not. Each is now oneneeds.configwarning, naming the entry, the key and the keys the entry has; the key is ignored and the entry kept. Aseverityin aneeds_fieldsorneeds_linksentry is the one exception to the wording: its warning names the need type’s entry that takes it (see above). Anamein aneeds_fieldsentry, or anoptionin aneeds_linksentry, left from the list spelling, is accepted in silence where it repeats the entry’s name, as a migrated entry does, and reported where it gives another (it was always ignored: the entry is named by its key). Aneeds_extra_optionsentry is read forname,description,schema,deriveandderive_by_typealone, as before, and its other keys, such asnullable, are now reported. A keyword theschemaof such an entry does not have (enmu,minimumon astring,uniqueItemson a link type), at its top or in itsitemsorcontains, is oneneeds.configwarning too, and dropped, the rest of the schema kept, where it stopped the build (Invalid schema: Additional properties are not allowed); so is one in the schema of a field an extension registers withadd_field. The keys known are those of the configuration’sNeedFields,NeedField,NeedLinksConfigandLinkOptionsTypetypes, whoseNeedFieldnow lists the keys aneeds_extra_optionsentry is read for, and the keywords those of the schema types the schema is validated against.👌 A field or link type declared on need types alone whose name is close to a declared one is reported, “did you mean” (issue #2299)
A
fieldsorlinksentry of a needs_types entry naming nothing declared elsewhere declares a field (or link type) of the need types that declare it alone, so a misspelt name,aslmeant to narrowasil, constrained nothing and was not reported. When the name is withindifflib.get_close_matches(name, known, n=1, cutoff=0.8)of a core field an author sets, a registered field (a needs_fields entry, an extension’s, a service’s) or a global link type, it is now oneneeds.type_near_namewarning,needs_types['req'].fields['asl'] declares a field of need types 'req' alone; did you mean 'asil'?; the field is declared all the same. A deliberate near name, such as atagof one type besidetags, is reported too:suppress_warnings = ["needs.type_near_name"]silences these alone. See A misspelt field name.
Deprecations¶
⚠️
add_needis deprecated, and is removed in 10.0:create_needreplaces it (issue #2137)Each call of
add_need()is one PythonDeprecationWarning, at the line that calls it, namingcreate_needand Migrating from add_need; it creates the need as before. It is not a Sphinx warning, so a build run with-W(warnings as errors) is not failed by an extension that still calls it, such as sphinx-codelinks 2.0 and sphinx-test-reports 3.0. An extension whose own test suite turns warnings into errors (filterwarnings = error) does fail there, on its first call ofadd_need, until it moves tocreate_need.create_needtakes the need’s location as oneNeedItemSource(NeedItemSource.from_directive(self)in a directive), its fields and links as two mappings, and returns the need with its nodes; the migration section maps each ofadd_need’s arguments.generate_need,add_external_needandingest_need_recordare not deprecated.⚠️ A
need_sourcethat is not aNeedItemSourceis deprecated ongenerate_need,add_external_needandingest_need_record, and is refused from 10.0, ascreate_needrefuses it nowAn object with the
NeedItemSourceProtocolinterface alone, given to one of them, is one PythonDeprecationWarningat the line that calls it, namingNeedItemSource.from_directive(self)andNeedItemSource.on_page(docname, lineno=...); the need is created as before. Likeadd_need’s, it is not a Sphinx warning, so a-Wbuild is not failed by it, andadd_needgives no second warning for it. Only aNeedItemSourcecarries the hops a need’s origin is read from, thec.sourcefacets among them: a source with the protocol alone gives a need none. Reading a need’s source through the protocol (need.source) is unchanged. See What is public.⚠️ The five source classes
NeedItemSourceUnknown,NeedItemSourceDirective,NeedItemSourceService,NeedItemSourceExternalandNeedItemSourceImportare deprecated names ofsphinx_needs.need_item, and are removed in 10.0:NeedItemSourcereplaces themEach is a function now, taking its class’s keywords and returning the
NeedItemSourcewith the location keys that class gave, and reading the name (from sphinx_needs.need_item import NeedItemSourceUnknown) is aDeprecationWarningat that line. They were not documented API, and what they did beyond their keywords is gone: a source is aNeedItemSource, soisinstance, amatchclass pattern or a subclass naming an old name raisesTypeError(a function is no class: testisinstance(source, NeedItemSource)),type(source)is never one of them, and an annotationNeedItemSourceUnknown | Noneevaluated at run time raises too;dataclasses.replaceraisesTypeError(build a new source) anddataclasses.asdictgives the one class’s fields; the attributesurl(NeedItemSourceExternal),path(NeedItemSourceImport),external_urlandis_external(NeedItemSourceUnknown) are gone (readsource.dict_repr);dir(sphinx_needs.need_item)and, at run time,from sphinx_needs.need_item import *no longer include them (a type checker sees each as a deprecated function of its keywords); and no combination of keywords is refused: givenhops, the hops decidedocname,external_url,is_external(butNeedItemSourceUnknown(is_external=True)still puts an external hop first) and, without alineno, the line, while alinenogiven is the need’s, and anexternal_urlwithoutis_externalis dropped.
Bug fixes¶
‼️ A directive option matches a field, link type or core field ignoring case, in reStructuredText and MyST alike, and its value is stored under the declared name (option names and case)
docutils lowercases every reStructuredText option name, so a field or link type declared with capitals (
needs_fields = {"Owner": {}},needs_links = {"Satisfies": {}}) could not be set from reStructuredText at all –:Owner:and:owner:were bothUnknown option 'owner'and the value was lost – while MyST took:Owner:alone, and MyST’s:Status:was an unknown option where reStructuredText’s setstatus. Now any case of the name sets it, on a need directive, aneedextend(+and-keys too) and aneedservice(whose service reads the declared name), andneeds.json, filters and tables keep the declared spelling. An option written exactly as a name matches it first, so no value set before changes: only an option that was an unknown one now lands. Where MyST writes one name twice in two cases, that option, or else the first written, keeps its value and the other is ignored with a warning (needs.directive;needs.needextendon aneedextend). Two names equal ignoring case are now a configuration error that stops the build: two fields, a field and a core field (Status), a field and a link type, two link types, a link type’s back links and another name (Tests_Backbesidetests), or a name and an option a directive reads itself (Strict, needextend’sstrict). Names spelt alike are handled as before. The options oflist2need’s items,((name="value")), are matched exactly, as before.🐛 A need a needimport or needservice creates records the line its directive is written on (changed output)
rst_prolog, an.. include::above the directive, and the include it is written in each shifted itslinenoby the lines they insert, as they did for need directives before 8.4.0 (issue #1349): a needimport on line 14 of a page below an include was recorded at line 33. Filters, tables,needs.jsonand the warnings placed at a need’s line now give the directive’s line in the file it is written in, the included file’s inside an include. The warnings about the needs’ content and rendered templates do not move.🐛 A need in a sliced include records the line it is written on in the file, where it recorded its line in the slice (changed output) (issue #2428)
docutils numbers an include’s slice (
:start-line:,:start-after:) from the slice’s first line, so a need written on line 22 of a fragment included with:start-line: 3hadlineno19 in filters, tables and needs.json, and its file hop had no line. sphinx-needs now recovers the slice’s start from the include’s options, on docutils 0.21 to 0.23, and takes the line it gives where the file holds the directive there: thelinenoof a need directive’s need, alist2needitem and a test need written in the slice (sphinx-test-reports) is the file’s line, and so is the file hop of those and of the needs aneedimportor aneedservicecreates. The warnings placed at a need’s recorded line, such as a failed constraint or the “defined at” of a duplicate id, now name the file’s line too; docutils’ and Sphinx’s own messages about the same text, and the warnings a directive locates through docutils (most of a directive’s option errors), still name the slice’s line. Where the slice cannot be matched with the file – aninclude-readhandler that rewrote it, a file decoded otherwise than with the project’ssource_encoding, a:parser:include – and for a need in a table cell, inlist2needitem content, in content parsed in a declared markup, or generated by atest-report, the line stays the slice’s.:end-line:and:end-before:move nothing, except on docutils 0.22 and later where a form feed above the need had shifted it by a line, which is now the file’s line too. MyST includes are unchanged.🐛 A needs_external_needs source whose
target_urlrenders an absolute URL (scheme://…or//…) links to that URL, wherebase_url/was put in front of it (issue #2389)With
target_url: "{{need['remote_url']}}", abase_url: ""linked every need to/https://github.com/…, and abase_urlsuch ashttps://sitetohttps://site/https://github.com/…; both now link tohttps://github.com/…, and the need’sexternal_urlis that URL. Every other render,req:REQ_1included, is still appended tobase_url. Two configurations change. Abase_urlthat is itself a URL-prefix service, such ashttps://proxyin front of an absolutetarget_url, is no longer put in front: put the prefix in the template instead,target_url: "https://proxy/{{need['remote_url']}}". And a template whose render starts with//because a leading field is empty ("/{{need['x']}}/{{need['id']}}"rendering//REQ_1) is now a scheme-relative URL, where it wasbase_url//REQ_1: fill the field, or write the template without the leading/.🐛 A field named like a parameter of
add_need–state,app,need_type,full_title,need_sourceorallow_type_coercion– is an ordinary field in a need directive,list2need,needservice,needimportandneeds_external_needs(issue #2392)The first need setting one ended the build with
TypeError: add_need() got multiple values for keyword argument 'state', and a need settingallow_type_coercionlost the value without a word; an external needs.json record carryingapp,need_sourceorallow_type_coercionended the build the same way. A needimport or external record’s field namedneed_typewas overwritten by the record’s type, and one namedfull_titledropped as the legacy key; both are read now. Every producer now creates its needs with the fields as a mapping.add_needitself still takes them as keyword arguments, so an extension calling it keeps the collision of its own parameters’ names;create_needhas none. Two more names of the same kind: a field named like one ofgenerate_need’s own keywords (needs_config,needs_schema,template_root) no longer stopsadd_needwith the sameTypeError, and a field the project declares under one ofadd_need’s deprecated keys (delete,hide_status,hide_tags,links_string) is a field through the producers, whereadd_needdropped it with aDeprecationWarning.🐛 An external need keeps a field named
statethe project declares (issue #2403)add_external_needdropped a record’sstateas if it wereadd_need’s parser state, so the field wasNoneon every external need. Astatethat names no field of the project is reported as an unknown key of the source and dropped, as before.🐛 A schema rule’s property on an array field may give
containswithoutitems("tags": {"contains": {"const": "a"}}): the build stopped with a schema error, where the rule now applies, the field’s item type standing foritems. A link type’s property is unchanged.🐛 A needs_types entry with a
titleand aprefixnaming a need type an extension adds no longer stops the build withNeedsApiConfigException: testcase already exists as need typefrom the extension’sadd_need_type: the entry narrows the type (issue #2371).add_need_typestill refuses a directive another extension added, and a default type no entry of the project names.🐛 The
needs_schemaof a needs.json writes a link type’s literal default (changed output) (issue #2208)It wrote
"default": []for every link type but one derived by type alone, also for one with a literaldefault, such as[needs.links.rel] default = ["REQ_1"]: a reader of the schema took the wrong value for an absentrel. It now writes that default as a need holding it writes its links, sorted and deduplicated, with each link’s condition under needs_json_include_link_conditions (the default) and without it otherwise. A default a dynamic function or a variant computes, and a derived link type, still write[]; a need type’s own default is not written. Under needs_json_remove_defaults a need holding the link type’s default now leaves it out, and a reader restores it from the file’s own schema, asub-needs-exchange(needimport, needs_external_needs) does; a reader that does not restore defaults from the schema reads such a need as having no links of that type.🐛 A build that fails with needs_build_json, needs_build_json_per_id or needs_build_needumls set stops with its own error. Each of these writers ran after the failure as well and raised in turn, so a configuration error was reported as
Handler <function build_needs_json ...> for event 'build-finished' threw an exception (exception: Needs schema has not been initialized yet.), with the real cause only in the chained traceback🐛 A need takes the name of its nearest enclosing domain object as its
signaturehowever the domain writes that name (changed output) (issue #2394)Only a name written as plain text was read, as the Python, reST and standard domains write it. The C, C++ and JavaScript domains usually wrap it in further nodes, so a need inside a
c:functionnamedcfunchad nosignature, and one inside acpp:functioninside apy:classtook the class’s name; both now take the function’s name, which filters and needs.json show. A need whose nearest enclosing object writes its name as plain text keeps its value, and a need inside acpp:aliasstill has none. An empty name counts as no name, where an emptydesc_namewith no content failed the build.🐛 An incremental build re-writes every page showing a need that changed: a page whose needtable, needflow or other view lists it, whose
:need:role names it, whose needs link to it or are linked from it, or whose need computes a value from it, kept its old values until a full build, and so did the needs aneedextendchanged or no longer changes (issue #2376, issue #346)The needs of every document re-read are compared, as read, with what that document gave before; on a change, the pages showing it are re-written, never re-read. An edit that changes no need, such as prose below the needs, re-writes nothing more, and one that only moves needs (lines added above them) re-writes the views and the pages whose roles name them, unless anything else in the project may read a line number. A dynamic function is read by its arguments, so
copyof a need’s own field does not make its need depend on others (a back-link field does: other needs write it, as they decidehas_dead_linksand the other values computed when the needs are resolved); a value of any other shape, a variant say, is taken to read every need. A changedneedextendwith a filter re-writes every need-relevant page, as does every change in a project whose needs or extends link to needs they do not name before the needs are resolved, or with aneedextendwith a filter whose dynamic function reads needs it does not name, and so does every change of a need that aneedextendwith a filter links to or copies. A view without a sort, such as aneedlistor aneedflow, now lists the needs in document order on every build, where an incremental build listed those of the re-read documents last and a parallel one in the order its readers finished. Needs fromneeds_external_needsare not compared (issue #353). See Incremental builds.🔧
ENV_DATA_VERSIONis 25: the first build after upgrading re-reads every document, which records the views and need roles each document holds and where each hidden need is (issue #2398), stores each need’s source as one class, with the hops above, computes again the selections and derived values of a filter usingc.is_a, which 9.1.0 refused, computes the links acopyorcollecton a link type, refused until now, computes, leaves the summary link types out of a needflow without:link_types:, records the file’s line for a need in a sliced include (issue #2428) and the directive’s line for a need aneedimportor aneedservicecreates, and locates each need in one walk of the doctree🐛 A need with
:hide:is located as a visible need in the same place is (changed output) (issue #2398)A hidden need that was the first child of its container – a
.. only::, a.. note::, a parent need’s content, apy:functionbody – had emptysections, nosignatureand no parent need, and a hidden need following another need, hidden or not, took that need as itsparent_need(so the other need listed it inparent_needs_back): the needs a needimport with:hide:imports were each the child of the one before. Both now get thesections,signatureandparent_needsa visible need in the same place gets, which filters, tables, needflow diagrams and needs.json show. A visible need keeps its own location; itsparent_needs_backnow lists every hidden need inside it – it lacked a hidden first child, and any hidden need that followed another need inside it – and no longer lists the hidden needs that merely followed it. A hidden need after a title or a paragraph keeps its values. list2need places the children of a hidden item outside it, as before, so such a child is located there: its parent is the hidden item’s own parent need, or none at the top level, which can differ from the same list written without:hide:. An existing build directory is read again in full once.
Documentation¶
📚 Reading the configuration through
NeedsSphinxConfigis documented, and stable: an extension readsNeedsSphinxConfig(app.config).<name>for the configuration valueneeds_<name>as resolved,ubproject.tomlincluded, and fortypes,layouts,functionsandwarningswhat extensions and services add, as the 9.1.0 notes recommended fortypesandlayouts. Reading only;variant_data_proxyis documented beside them, and the class’s other members are internal. See Reading the configuration.📚 Derived fields shows how to start a list roll-up one rung up (Starting a list roll-up one rung up): a
copyofidoversatisfieswithselect = "list"on the specification, then acollecton each rung below, and why a plaincopyof the requirement’s ownidcannot start it; and the same chain read upwards, which gives each need the tests that reach it (issue #2379)
Internal changes¶
🔧 Each need is located by one walk of the doctree: its
sections,signatureandparent_needsare written from the semantic location recorded on its placement inneed.source, which a second, older walk duplicated until now. Every value a doctree of Sphinx’s or docutils’ own gives is as before. Where an extension builds the doctree by hand, the one walk reads the need’s real place: adesc_signatureoutside anydesc, or one the need is placed in, gives nosignature, adesc_nameholding an empty text node is no name, and a need whose target an extension dropped keeps itssectionsand takes its nearest enclosing need as its parent, rather than none or the need before it. The undocumented helpersget_sections_and_signature_and_needsandprevious_siblingofsphinx_needs.directives.needare removed without a deprecation. An existing build directory is read again in full once.🔧 The
varproxy over the variant data and the need typesc.is_areads are kept by sphinx-needs rather than on Sphinx’s configuration, which holds the declared options alone (issue #1840, issue #2402):app.config.needs_variant_data_proxy, undocumented since 8.2.0, is removed without a deprecation, and is read asNeedsSphinxConfig(app.config).variant_data_proxy🔧 The benchmark workflow measures sphinx-needs rather than the runner: a build time is the fastest of several fresh builds with no PlantUML diagram rendered (about three quarters of the old documentation figure was Java), the peak memory of the documentation build is tracked, and a regression is judged against the median of recent results on the same CPU model instead of the single result before it, which failed about one push in ten in 2026-10 on runners of different speeds
🧪 A test fails when the shape of the data sphinx-needs stores in the environment changes without a bump of
ENV_DATA_VERSION, and when the version is bumped without re-pinning that shape (issue #2420). It builds a project with every producer of needs, collects every class of sphinx-needs the pickled environment and doctrees hold, with theTypedDictclasses their annotations name, and compares their fields with the pinned ones
9.1.0¶
- Released:
22.10.2026
- Full Changelog:
Fields and link types declared per need type are the heart of this release. A needs_types entry may
inherits another and declare fields and links of its own, each with its description, schema, default,
predicates and derive rule; a field or link type may be declared on the need types that have it alone, under one
rule, “one name, one shape”; needs_types may be a table keyed by directive; a link type’s target_types says
which need types its links may point to; a derived union of link types replaces copy = true, and the
join role and links_from_match link needs whose field values match. A dynamic
function of your own can declare what it reads and is then computed in order, like a built-in one, and every read
of a value not yet computed is reported where it was silent. A filter
string in the portable filter language is evaluated without Python’s eval, five to six times faster, with a
conformance corpus that defines the language and a needs_debug_filters record naming the tier that answered
each filter; every tier reads a filter for its truth, and a filter that is a constant is refused instead of selecting
every need or none. A needs.json is read through the new ub-needs-exchange library and may carry a format_version,
and a file written without its defaults restores them from its own schema. The package ships py.typed. Two
changes are breaking, each with its migration under Breaking changes below: the built-in GitHub services are
registered only when needs_services names them, and app.config.needs_types and needs_layouts no
longer hold the types and layouts that extensions add. The documentation gains a page mapping Sphinx-Needs,
Sphinx-CodeLinks and Sphinx-Test-Reports across the V-model’s five steps.
Improvements¶
✨ A function of your own can declare what it reads, and is then computed in order, like a built-in function (issue #2354, PR #2366)
@sphinx_needs.api.reads(own="test_option", every="target_option")names the parameters whose argument is a field the function reads on its own need or on every need, andadd_dynamic_function(app, func, reads=reads(...))declares a function you do not own. Such a call is computed after what it declares and before what reads it, where a function of your own is computed after every built-in function of its step: alinks_from_filter, alinksorunionderive rule, or any other built-in function reading the links it computes holds them. A read of its own field is aneeds.derive_cycleand a read of a later step is not run (needs.derive_scope). A name that is not a parameter of the function is oneneeds.configwarning when it is registered, and a call whose declared argument is not a field name written out (aneed.<field>, a number) is computed last, with oneneeds.configwarning per function. A field the function reads by a name written in its code cannot be declared yet. Afunctools.wrapswrapper carries the declaration; sphinx-test-reports’tr_linkdeclares its reads. A function that declares nothing is computed as before. See Declaring what a function reads.👌 A read of a value the pass has not computed yet is reported as it happens, where several were silent (issue #2354, PR #2366)
A built-in function or derive rule whose filter or
wherereads a value your own function (one that declares nothing) or a call whose filter cannot be read computes – the filter oflinks_from_filter,links_from_content,links_from_match,copy,calc_sumandcheck_linked_values, thewhereof alinksorcontent_linksrule – read it empty and said nothing, as did your own function reading a value computed after it (by another of your functions, a call whose filter cannot be read, a union computed after them, or a later step). Each is now oneneeds.derive_scopeper reader and cause, naming the needs read: your own function once for all its calls computing a field, a built-in call or rule once for every need it computes the field on. A function that declares its reads is reported for every read of a value computed in its own step that it does not declare. No value changes: the reader still computes what it read. Only the reads that touched such a value are reported, so a filter whoseandstops before it is not; a whole-need read such asdict(need)reads every field. A built-in function’s filter is watched only in a step with a call computed after the built-in functions, and your own functions’ calls as they run, so a project without functions of its own and without a filter that cannot be read runs as before; a project that declares nothing computes the values it did. See Reads that cannot be ordered.Upgrading: a project whose built-in functions or rules read what its own functions compute, or what a call whose filter cannot be read computes, may see new
needs.derive_scopewarnings where its values were silently wrong, and a build with-Wfails on them. Declare such a function’s reads (Declaring what a function reads) to have it computed in order and its readers hold its values; fortr_link, upgrade sphinx-test-reports to its release that declares them. A reader then holds every value it selects, which can make a build slower and, for alinksrule selecting many needs, reportneeds.derive_dense.suppress_warnings = ["needs.derive_scope"]silences the new warnings meanwhile, with every other scope finding.⚡️ A filter string in the portable filter language is evaluated without Python’s
eval, five to six times faster, for the whole language; a conformance corpus defines it and pins its answers (issue #2346, PR #2350)A filter string that the index path does not answer is compiled once and evaluated need by need without
evalwhen it is written in the portable filter language, which now holdsx is None/x is not None;len(x),x.lower()andx.upper()as operands, on either side of a comparison, ofin, ofsearch()and alone;x.startswith('...')/x.endswith('...'), after any of those (id.lower().startswith('req')); a field against a field in every comparison (variant == current_variant);c.this_doc(); a negative number;True/False; and avar.chain alone. Whatevalcosts is its context, a copy of every field of the need per evaluation, so the forms that used to reach it are five to six times faster now (over 14 000 needs,len(tags) > 0: 29 ms to 5 ms), and a form the fast path already took costs what it cost. Its answers areeval’s, an error included, but for the three smaller cases Filter string performance lists. A string newly in the language whose value is not a boolean –len(tags)alone,title.lower(),True and owner, avar.chain alone holding a string – selects the needs it is true for, where it was refused withFilter did not evaluate to a booleanand selected nothing;evalnow reads every filter for its truth too (below). A string the language does not hold – a fieldina field, a list beside==, a subscript, a comprehension, arithmetic, another call – is evaluated byevalas before. Of the strings this repository’s documentation and tests wrote, eleven of the sixteen that reachedevalno longer do.tests/fixtures/filter_conformance.tomldefines the language and pins every rule’s answers, so the three tiers are held to the same results; see Filter string performance.👌 needs_debug_filters says which tier answered each filter: every record of
debug_filters.jsonlholdstier,"index","fast","eval"or"refused"(a constant, below), and for"eval"fallback_reason, the construct that kept the string out of the portable filter language (subscript,call:any,compare:name-in-name, …), orfilter-code/filter-funcfor a directive’s filter code (issue #2346, PR #2350)👌 A filter string selects the needs its value is true for on every tier, and a filter that is a constant is reported instead of selecting every need or none (issue #1773, issue #2355, PR #2364)
A filter string selects the needs its value is true for, whatever the value’s type and whichever tier answers it:
evalrefused a value that is not a boolean (Filter did not evaluate to a boolean) where the index path and the portable filter language read its truth, sotagsand[t for t in tags]answered differently. A filter that is a constant alone – a literal such as'x',-5,10.5orNone, a display such as[1]or{}, the trailing-comma typostatus == 'open',, a generator expression, which is true whatever it would yield, an f-string with no placeholder, parenthesised or not, after any leading spaces and tabs – says nothing about a need. The views, need_count, the content lines of needpie and needbar, needextend, needs_warnings, needs_builder_filter, thefilter()of needuml andcopy(filter=...)refuse it before any tier runs, with oneneeds.filterwarning, and select nothing, so:filter: 'x'no longer selects every need without a word; needimport, a predicate of needs_fields,links_from_filterandlinks_from_matchrefuse it with the warning they give a filter that fails, where the two functions linked nothing silently. Anywhere else a constant fails as a filter that cannot be evaluated fails there.TrueandFalsealone still select every need and none. A content line or cell that is a number such as10.5or-5still counts zero with aneeds.filterwarning; one that is a string such as'x'counted every need and now counts zero with that warning. needs_debug_filters records a constant’s tier as"refused".✨ A derived union of link types: a link type deriving
unionholds the links of the link types it names (issue #2279, PR #2343, PR #2353)derive = { kind = "union", fields = ["links", "blocks", "tests"] }on a needs_links entry (or[needs.links.<l>], a need type’slinksentry,derive_by_type) gives each need the links oflinks,blocksandtests, in that order, each link once by its target, part and condition – parts and conditions carried as written – with back links of its own (<l>_back). Its members are link types the need has, derived ones and other unions included (computed first); a field, a<l>_back,parent_needs, a name declared nowhere, no member, one named twice, and a union naming itself or two naming each other are each oneneeds.derive_invalid, the union holding no links. It is computed after every needextend, so a link a needextend adds to a member is in it, closed to authors, left out of fingerprints and not computed on imported or external needs, as every derived link type. Dead links and link conditions are its members’ where its rule computed it: a union reports neither, a dead link of a member that allows dead links makes no dead link forbidden (and is drawn as allowed), and anallow_dead_linkson a link type all of whose rules are unions is refused (beside a union that cannot be read, for a member or on a cycle, which is no union, it is kept; beside one cycling on some need types only, still a union on the others, it is refused, as the cycle’s finding says); on an imported need, which keeps its file’s union, it is checked as any link type.needs.derive_densedoes not count its list. A member filled by one of the project’s own functions (needs_functions), or by a call whose filter cannot be read (alinks_from_filterwhose filter namesneeds), is computed before the union: those run after the built-in functions, in need-id order, and the union right after the last such member (a union of that union after that). Those computed after the union read it complete, those before it empty – such a call whose filter names the union is oneneeds.derive_scope, as is acopyreading it, when it runs, and the project’s own functions, a read throughneedsand one ofcurrent_needby a key that is not written out, as they run (above) – and a built-in function or rule of that step reading such a union cannot wait for it, and is oneneeds.derive_scope(alinksrule on every need computing it). It is whatcopy = truegave, declared (see Deprecations); see A union of link types for how to read it in place oflinks. The derive conformance corpus pins it (union-*), as does the field-declaration corpus for a union declared on need types.✨ A link type’s
target_typeslists the need types its links may point to (issue #2300, PR #2319, PR #2342)target_types = ["req"]on a needs_links entry (or aneeds_extra_linksone, or[needs.links.<l>]) accepts a link to areq, or to a need of any type inheriting fromreq, and reports every other link, once per distinct link, at the need it is set in, asneeds.link_target_type; the link is kept. A need type’slinksentry may narrow it for its needs and the types inheriting from it (within the types it inherits, the subtypes of a listed type included; anything else is aneeds.type_widening), and each root of a link type declared on need types alone gives its own. It is checked once every link is final, whether or not the schema validation runs, and unlike a filter or a schema rule’sconstit followsinherits. Dead links are left to the dead-link warning, a part link is checked by its need’s type, the links of a need from needs_external_needs are reported asneeds.external_link_target_type. While a link type copies intolinks(copy),linksis part written, part copied, so atarget_typesonlinksis refused, oneneeds.configwarning per declaration, and ignored untilcopyis replaced. The link type’sschemacount (minItems,maxItems) is checked apart, by the schema validation: it counts every link, a refused or dead one included. A derived link type takes none in this release. The names that are no need type are oneneeds.configwarning per declaration, and ignored; atarget_typesnaming none keeps the target types of the declaration before it. The field-declaration conformance corpus pins it (link-target-types-*), with two new shared codes,link_target_typeandexternal_link_target_type.👌 A needservice naming a service that is not registered is one
needs.load_service_needwarning, checked before the directive’s options: for a built-in GitHub service that is not configured it says so and gives the configuration to add (see Breaking changes), and with no service registered at all it sayscould not be found: no service is registeredwhere it listed none (PR #2321)✨
add_need_layout()adds a need layout from an extension, beside needs_layouts, asadd_need_typeadds a need type (issue #2265, PR #2307)🏷️ sphinx-needs ships a
py.typedmarker (PEP 561) and theTyping :: Typedclassifier, so a type checker (mypy, pyright, ty) reads its annotations instead of treating the package as untyped. A project that type-checks code calling sphinx-needs’ API may see new diagnostics where those calls disagree with the annotations (PR #2241).✨ The join role of a derive rule, reserved in 9.0.0, and its inline spelling, the dynamic function links_from_match (issue #2224, PR #2228)
join = { field = "case_name", equals = "test_case" }on alinksorcopyrule makes its candidates the needs whosecase_nameequals one of the need’s owntest_casevalues: both are text fields, a string split on,and stripped, or an array of strings, compared value by value. Each need that matches is a candidate once, in need-id order; the need itself only withinclude_self = true; needs only, never their parts.linkslinks them (wherenarrows them, andlinksrequireswhereorjoin), andcopyreads them as over a link type,selectincluded. The needs are indexed by the field once for the link fields and once for the other fields (and once more for the rules computed last), shared by every rule and call on it.[[links_from_match("case_name", "test_case")]]links the same needs from one need; the nearest spelling of sphinx-test-reports’tr_link(test_option, target_option)islinks_from_match(target_option, test_option, include_self=True)– the arguments swapped, and it differs wheretr_linklinks once per matching value, follows the project’s order, compares the candidate whole and fails when the need’s own value is an array or number. A rule that cannot be read is reported asneeds.derive_invalid, as every rule is; three refusals of an existing rule changed their words with it (links“requires the role ‘where’ or ‘join’”, andcopy’sfrom/over/joinandselecttexts).👌 A link type that computes more links than needs_derive_max_links_per_need (default
100) per need of the project is reported once, as the warningneeds.derive_dense(issue #2202, PR #2258)The links a
linksorcontent_linksrule computes are counted, or, on a link type without one, those itslinks_from_filter,links_from_contentandlinks_from_matchcalls compute; written links, those a needextend adds and back links are not, and the needs of the project are every need but need parts. It counts rather than times, so every build of a project warns alike, and the warning names the links, the needs computing them, the longest list, and what to do instead (What a rule costs). It is on by default: a build with-Wand such a rule fails until the warning is silenced withsuppress_warnings = ["needs.derive_dense"], or the threshold is raised or set to0(or less), which never warns.♻️
FieldsSchema.for_typeandFieldsSchema.add_type_overlay, the first slice of per-type fields (discussion #1646): a need type may declare a field anew, and need creation, needextend’s per-needallow_extend, dynamic and derived values and the field validation read a need’s fields as its type declares them; nothing changes for a project – the configuration surface follows (PR #2266)♻️ The fields schema has two tiers: the union answers a field’s shape and
for_typeits full declaration, the schema freezes once it is first read (the first need, or the first validation), and a per-type declaration is a narrowing (needs_schema.narrowing_problems); the second slice of per-type fields (discussion #1646) – nothing changes for a project; the configuration surface follows; an extension that changes the schema after the schema is first read now gets aTypeError, andFieldsSchema’s getters are typed as shapes (read a full declaration throughfor_type) (PR #2275)✨ needs_types can be a dictionary from directive name to the other items of a type, beside the list, in
conf.pyand as[needs.types.<directive>]tables in a needs_from_toml file; both shapes keep the order the types are given in. The value is validated when the configuration is read, and what cannot be used is aneeds.configwarning instead of a traceback or silence: an entry that is not a dictionary, names no directive, or lacks a stringtitleorprefixis ignored (a missingtitleused to end the build with aKeyError), but for one naming a default type with neithertitlenorprefix, which is that type, narrowed: it takes thetitle,prefix,colorandstyleit leaves out, and aneeds_typesnone of whose entries gives atitleor aprefixkeeps the default types, each narrowed by its entry (an entry naming no default type declares nothing); acolororstylethat is not a string, and an unknown key, are ignored and the type kept – the unknown key an old project most likely still carries iscontent, which sphinx-needs 1.0 read and PR #610 stopped reading; a value of neither shape stops the build with an error. A directive declared twice in the list is now its last entry on every path – a need of list2need took the first entry’s prefix – and is listed once in the legends and in needreport, and, when it was the first type, a needservice datum without a type takes the type that now comes first; the duplicate is reported, where Sphinx used to warn that the directive was already registered (issue #2262, PR #2276, PR #2353)✨ A need type declares its fields: an entry of needs_types may carry
fieldsandlinks, each a dictionary from a field or link type to the type’s declaration of it (description,schema,nullable,default,predicates; a link type is not nullable), andinherits, one parent whose declarations the type starts from (Fields per need type); a default type declares its own in an entry naming it with neithertitlenorprefix, which keeps the other default types ([needs.types.req.fields.x]alone). A declaration narrows the one before it – the field’s own, then each ancestor’s – and what cannot be used is reported and ignored as a whole, the build going on:needs.type_inheritsfor aninheritsnaming no need type or on a cycle (every type on it),needs.type_conflictfor a declaration naming no field of its table or setting what the field does not take (a default of a derived field among them), andneeds.type_widening, one warning per reason, for a declaration that widens. A needextend deleting a field now empties it as the need’s type declares it (Nonewhere nullable on that type, else the empty value of its type). The per-type declarations of issue #2269, after the schema’s two tiers (PR #2275) and theneeds_typestable (PR #2276) (discussion #1646; PR #2278, PR #2353)✨ A field may be declared on the need types that have it alone: a
fieldsentry of needs_types naming no field needs_fields, an extension or a service declares, and no core field or link type, declares a field of the types that declare it – in their own entries or an ancestor’s, an empty entry included – absent on every other type (Fields per need type). Every type that declares it agrees on its type and items’ type, which the first need type without an ancestor declaring it that gives aschematypesets; such a declaration of another type is aneeds.type_conflictwarning, and does not declare the field (a child of a declaring type still declares it, through its parent). On a need of another type the field holdsNone, a value set for it in a need is ignored as aneeds.undeclared_for_typewarning naming the need, and a need imported or external drops it with the same warning (silently when it holdsNoneanyway, as a needs.json writes it on every need); the needs.json describes it asDeclared by need types ..., naming the declarations without a declaring ancestor that are not refused. Aderivein a need type’sfieldsorlinksentry is the field’s (or link type’s)derive_by_typeentry for the type and the types inheriting from it, read and checked with the others (a rule that cannot be read is reported for each type that reads it); beside aderive_by_typeentry for the same type it is aneeds.configwarning, and thederive_by_typeentry used for that type (the types inheriting from it still read the entry’s rule). A field declared on need types alone is derived on every type that declares it, or on none, and alinksentry naming no link type declares a link type of the types that declare it, its labels, styles,copyand dead links set by its first root ([]on the needs of every other type; issue #2285). A needextend refused on the needs of a type is oneneeds.needextendwarning for each need type, naming its needs, instead of one for each need. The fields schema is frozen once built, before any document is read: an extension that changes it from anenv-before-read-docshandler now gets aTypeError. A per-typeminItemson a link type ortagsneeds nodefault: the empty value of a field’s type kept from its global declaration ([],"",0,0.0,false) is no default for a per-type narrowing (issue #2277). The per-type fields of issue #2269 (discussion #1646; PR #2281, PR #2284, PR #2292)👌 A derived field cannot be set on a need:
need[name] = valuefor a field with a derive rule raisesKeyError, where it used to set a value the rule then overwrote (needs-before-post-processing) or kept (needs-before-sealing, a filter function, a dynamic function writing another need’s field). An extension, a filter function or a dynamic function writing a derived field now meets the refusal: from an event or a filter function the build fails, with the field named (a filter function atdoctree-resolved, whatever needs_allow_unsafe_filters says); from a dynamic function the call is reported, for exampleError while resolving dynamic values for field 'plain', of need 'R_001': Error while executing function 'meddle': "Cannot set derived field 'copied' in NeedItem: its value is computed by its derive rule." [needs.dynamic_function], and the field the call was computing does not get its value (PR #2289)
Breaking changes¶
‼️ The built-in GitHub services
github-issues,github-prsandgithub-commitsare registered only when needs_services names themThey were registered in every build, so every project carried their twelve fields (
url,user,avatar,service,created_at,updated_at,closed_at,query,specific,max_amount,max_content_lines,id_prefix), null on every need of its needs.json, their three need typesissue,prandcommitin every legend and needreport, and thegithublayout, whether or not it used GitHub. Now a built-in is registered only when needs_services names it with a mapping of options –{}will do – inconf.pyor as a[needs.services.<name>]table of the needs_from_toml file. A configured service brings the twelve fields, thegithublayout and its own need type alone (github-issuesbringsissue); a project that names none has none of them. What to do:A needservice naming a built-in service now needs its entry; without it the directive creates nothing and warns, for example
Service 'github-issues' is a built-in service that is not configured, so it is not registered: name it in needs_services to use it, ... [needs.load_service_need]:needs_services = {"github-issues": {}}
[needs.services.github-issues]A hand-written
.. issue::,.. pr::or.. commit::(or a type thatinheritsone, or:layout: github) needs the service configured, or the type declared in needs_types (and agithubentry in needs_layouts).:url:,:user:and the other ten set on needs of your own types are nowUnknown optionwarnings and dropped, and a filter, needs_warnings check or needtable:columns:naming one finds no such field: declare them in needs_fields (or configure a service).The needs.json of a project that configures no service no longer carries the twelve keys, nor their
needs_schemaentries, nor the three types; a consumer indexing them reads them with a default. A needs.json written by an earlier version still imports (needimport, needs_external_needs) without a warning for its empty service keys: a project with no service drops the twelve keys silently where they are null or"", and reports one holding a value as an unknown key, as before. Needs that a GitHub service made (of theissue,prorcommittype, with thegithublayout) need that service configured, or their type declared (and, for needimport, agithublayout); without it each is refused (needs.import_need/needs.load_external_need), and a needimport’ed need of a declared type with the layoutgithubstops the build, as any unknown layout does (needs_external_needs drops the layout). Since 9.4.0 an unknown layout is aneeds.layout_unknownwarning instead, and the default layout is used in its place (issue #2324).A built-in named in needs_services only by an extension’s
config-initedhandler above priority 12 (or at 12, connected after sphinx-needs) is no longer registered: the built-in services are decided by sphinx-needs’ own handler at priority 12. Name it inconf.py, the needs_from_toml file, or a handler at priority 11 or below; a needservice naming it says so.An incremental build after a built-in service is configured or removed re-reads every document, as one after a change to needs_types does, also where the project declares the service’s type itself; the first incremental build after upgrading re-reads every document once.
A service of your own built on
GithubService, such as the GitHub Enterprise example, gets no need type and no layout from its class: configure the built-in service it imitates too (as that example does), or declare the type in needs_types. ItsService need could not be created: Unknown need type 'issue'.warning now says so, naming the built-in to configure.
An extension reading
get_need_types()findsissue,prandcommitonly for the configured services, listed from sphinx-needs’ ownconfig-initedhandler at priority 12 on, so from a handler above 12 (PR #2321).‼️
app.config.needs_typesandapp.config.needs_layoutsno longer hold the need types and layouts added by extensions or by the configured GitHub services, and the types and layouts sphinx-needs reads cannot be changed throughNeedsSphinxConfig(issue #2265, PR #2307)The two values hold what the project configures –
needs_layoutsalso sphinx-needs’ own layouts and the compiled needs_card_layouts, as before – so Sphinx compares the same values on both sides of an incremental build. A type added withadd_need_type(), the configured GitHub services’issue,prandcommit, and theirgithublayout are kept in sphinx-needs’ own registry instead.An extension that looks a need’s type up in
app.config.needs_types(or a layout inapp.config.needs_layouts) no longer finds the added and the GitHub services’ ones there, and nothing warns about it. Read them throughNeedsSphinxConfig, which returns every type and layout on this version and on every one from 2.0 (where the GitHub services’ types are in it once sphinx-needs’ ownenv-before-read-docshandler has run):from sphinx_needs.config import NeedsSphinxConfig need_types = {t["directive"]: t for t in NeedsSphinxConfig(app.config).types} layouts = NeedsSphinxConfig(app.config).layouts
get_need_types()gives the directive names alone. The twoNeedsSphinxConfigreads are read-only: a change through them, or assigning either attribute, raisesNeedsApiConfigException, where it used to change the configuration value. Add a type withadd_need_type, and a layout with the newadd_need_layout(), from an extension’sconfig-initedhandler.add_need_typecannot carry aninherits,fieldsorlinks: an extension whose type needs one appends the whole entry toapp.config.needs_typesfrom aconfig-initedhandler at a priority above 12 and below 500 – after sphinx-needs has resolved the configured types to their list, and before it registers their directives. Such an entry is part of the configuration, as a project’s own is.The configured GitHub services’ types are read from sphinx-needs’ own
config-initedhandler at priority 12 on, so a handler at a priority above 12 now sees each configured one ofissue,prandcommittoo, after the types added by then; they used to appear only fromenv-before-read-docs.
Deprecations¶
⚠️
copy = trueon a link type is deprecated, and is removed in 10.0: a link type deriving the union oflinksand the copying link types replaces it (issue #2279, PR #2343, PR #2353)The links are still copied into
links. Each declaration writingcopy = true– a needs_links or needs_extra_links entry, a[needs.links.<l>]table, a need type’s entry of a link type need types alone declare – is oneneeds.deprecatedwarning naming it and the replacement; none forcopy = false, and none where the key is already refused (beside a derive rule, in a need type’s entry of a link type declared outright). A union differs from the copies in three ways: a link a needextend adds to a member is in it, a need from needimport or needs_external_needs keeps the union its needs.json carries rather than copying, and a dead link is reported once, at the member. One case keepscopyuntil 10.0, with the warning (suppress_warnings = ["needs.deprecated"]silences it, and every other deprecation): a project relying on check_linked_values, calc_sum withlinks_onlyor theneed_outgoingandneed_incomingroles written in a need, which read onlylinks. Wherelinksis derived the copy copies nothing, and the warning says to remove it. The documentation’s own configuration no longer setscopy.♻️ needimport and needs_external_needs read a needs.json through the new
ub-needs-exchangelibrary, a new dependency of sphinx-needs (ub-needs-exchange>=1.1.0,<2); nothing they read or report changes, but for one addition: a top-levelformat_versionis now readub-needs-exchangeis the record of the needs.json format: its reader, which 9.0.0 shipped assphinx_needs.exchange, moved there with that one addition, beside a contract document and a conformance corpus that ubCode is to vendor, so that every tool reads the file the same way.sphinx_needs.exchangeis kept through 9.x as a deprecated alias ofub_needs_exchange: importing it gives aDeprecationWarning, and it is removed in 10.0. The addition: a needs.json may carry a top-levelformat_version– nothing writes one yet. Absent or1, the file is read as before; one that names a later format – an integer above 1, or a pre-release such as"2a1"– refuses that source, in one warning saying which format the file is of, and so does any other value.
Bug fixes¶
🐛 A filter in the portable filter language that fails on a need is reported once and the need left out, as in
eval, whatever the error: an error of the kind a failed filter raises, from a value’s own method, ended the build there (issue #2360, PR #2364)🐛 The filter fast path answers as
evaldoes where it did not: a list or a tuple of literals afterincompares a list field item by item (tags not in ['a']raised there and was true ineval), and a name no field defines that is a Python builtin is the builtin (filter != 'x'was refused there as undefined, and is true ineval) (issue #2346, PR #2350)🐛 The console message of a schema finding names the need the rule selected, under which
schema_violations.jsonfiles it. A finding of anetworkornetwork_backrule that failed on a linked need named that linked need: a rule selecting the tests, withT_001 > verifies > S_001as its need path, reportedNeed 'S_001' has schema violations, as if the spec broke it. It now readsNeed 'T_001' has schema violations; theNeed pathline still gives the chain, and the finding’s code, severity andschema_violations.jsondo not change (issue #2297, PR #2340)🐛 The
needs_schemaof a needs.json writes a core field as the project declares it, as it writes an extra field: a needs_fields entry narrowingstatusto a non-nullable field with the default"open"is written"type": "string","default": "open", where it was written with the built-in["string", "null"]andnull, and a default given to a core field in needs_fields or needs_global_options is written as itsdefault. The file’s content changes only for such projects, and its format does not change. Under needs_json_remove_defaults a value equal to that default is now left out, and a reader restores it from the file, as needimport does. Its other constraints, such as anenum, are still not written, as for an extra field, see issue #2316 (issue #2263, PR #2318)🐛 A field’s
defaultorpredicatesset both in its needs_fields entry and in the deprecated needs_global_options is taken from needs_fields, and theneeds_global_optionsvalue is reported as ignored, in oneneeds.configwarning per field naming both values. The legacy value replaced theneeds_fieldsone silently, so every need that did not set the field held it. A field needs_fields declares without the key still takes theneeds_global_optionsvalue, a core field narrowed in needs_fields follows the same rule, and a need type’s own declaration still wins over both (issue #2264, PR #2318)🐛 A link type’s
defaultorpredicatesset both in its needs_links (or deprecated needs_extra_links) entry and in the deprecated needs_global_options is taken from that entry, and theneeds_global_optionsvalue is reported as ignored, in oneneeds.configwarning per link type naming both values, as for a field. The legacy value replaced the entry’s silently, so every need that did not set the link type linked to the legacy targets. A link type declared without the key still takes theneeds_global_optionsvalue, and a need type’s own declaration still wins over both (issue #2317, PR #2328)🐛 An incremental build after a change to needs_types re-reads every document, as one after a change to needs_fields does. The option only rebuilt the HTML, so the needs of the documents that were not re-read kept what the previous entries gave them: a
deriverule added to or removed from a type entry, a field or link type it declares, its default, aninherits, or the type’stitleandprefix. A field whose rule was removed heldNonewhere a fresh build held its authored value. The complete list of need types is compared with the one the documents were read with, so a change to a type added withadd_need_type(), which the option does not hold, re-reads every document too. An unchanged list re-reads nothing more, and the first incremental build after upgrading re-reads every document once (issue #2287)🐛 A layout’s
{{field}}placeholder (Layouts) no longer stops the build withTypeError: replace() argument 2 must be strwhen the need’s value is unset or not a string. A value is written as its text, a list as its values joined with", "(asmetashows them), and when the field is unset or empty – as on every need of a type that does not declare a field declared on need types alone – the layout function’s element is left out, asimage("field:...")leaves out its image, rather than built from an empty value (_images/.png) (issue #2303)🐛 A needtable’s sort no longer stops the build when some needs leave the field unset, as every need of a type that does not declare a field declared on need types alone does:
Nonebeside a number or a string raisedTypeError. An unset value now comes first, whatever the field’s type, as an empty string already did; values of different types are ordered booleans, numbers, then text, so they never meet in a comparison, and needs with equal values are ordered by id (they kept the needs’ own order, which could differ between a fresh and an incremental build). A sort key that is not a field of the needs is aneeds.filterwarning, the rows left in the filter’s order, rather than aKeyError. The sort_by option of the filter directives crashed the same way beside a number (it compared an unset value, and0, as"") and now orders by the same rule, comparing text as it is. A table sorted by a list field may change order: a list is now compared as its values joined with", "(by:sort:without regard to case), where it was compared value by value, with regard to case (issue #2253)🐛 A needextend no longer stops the HTML build with
NotImplementedError: ... departing unknown node type: Needextendin a project with no needs, or with needs_include_needs set toFalse: its node is now removed on those paths too. In a project with no needs it matches nothing and says so, as it does in one with needs (issue #2296)🐛 An incremental build no longer reports
The configuration has changed (… options: 'needs_layouts', 'needs_types')– one of the two, or both – on every build after the first (Sphinx 8.1 and later print the line; Sphinx 7.4 and 8.0 compare only the options that rebuild the environment, so they did not report it). The GitHub services’ need types (issue,pr,commit) and theirgithublayout were appended to needs_types and needs_layouts when the services were registered, after Sphinx had compared the configuration with the one pickled by the previous build. They, and every need type added withadd_need_type(), are now kept in sphinx-needs’ own registry and read beside the configured ones, in the same order as before: the configured types, then the added ones, then the configured GitHub services’ ones, which give way to a type or layout of their name, configured or added at any time (see Breaking changes for what this changes for an extension). A change to a layout added withadd_need_layoutis not a configuration change: as for any change to an extension’s code, build with-Eto see it; a change to a type added withadd_need_typere-reads every document, as one to needs_types does. After upgrading, the line is still reported until a build re-reads a document, as the environment Sphinx loads was pickled with the old values: edit any page, or build once with-E(issue #2265, PR #2307)🐛 Configuring your own
issueorprneed type – or adding one withadd_need_typefrom another extension – no longer stops the configured GitHub services from adding their other need types: a configuredissuedroppedprandcommit, and a configuredprdroppedcommit. Each of the three now gives way on its own (PR #2307)🐛 A built-in GitHub service named in needs_services with a value that is not a mapping of options –
-D needs_services.github-issues=1sets the string'1'– no longer ends the build withAttributeError: 'str' object has no attribute 'get': it is aneeds.configwarning, and the service is not registered (PR #2321)🐛 Under needs_json_remove_defaults, a value equal to its field’s default but of another JSON type (
1.0against a default of1,[1.0]against[1]) is now written, so a reader gets it back as written. The writer compared with Python’s==, so anumberfield authored1(held as1.0) with an integer default of1was left out and read back as1. Nothing else is written that was left out before (PR #2306)🐛 A
fieldsentry of a need type named as a link type’s back links (links_back,parent_needs_back, orrel_backbeside arellink type) is refused, oneneeds.type_conflictwarning, as alinksentry of that name already was, and alinksentry of that name now says so too (“which is a link type’s back links”). It used to declare a field the computed back links replaced on every need, its authored value lost and its schema checked against the back links of every need, those of the types that do not declare it included; beside a needs_extra_links link type the build stopped instead (issue #2301, PR #2305)🐛 One rule for a link type whose back links,
<name>_back, have the name of a field or of another link type, applied when the schema is built (issue #2293, PR #2305)Between global declarations, a name declared outright wins: the link type is refused, one
needs.configwarning naming both and where the field comes from, and does not exist (no directive option, no back links, no needs.json entry), while the field or link type of that name keeps its values in needs.json, in filters and in the validation alike. A link type that is itself refused claims no name: of the link typesx,x_backandx_back_back,x_backis refused andxkept, its back links namedx_back. A feature that names a refused link type (a needgantt’s:starts_with_links:, a network rule of the schema) stops the build, as it does for a link type that was never declared. Through needs_links, an extension’sadd_field, a service’s field, or a second link type, the back links used to overwrite the field silently (or the link typex_backhid the back links ofx); through needs_extra_links, the build stopped with “Same name for automatically created link and field”.linksandparent_needs, which every project has, never yield: a field or link type namedlinks_backorparent_needs_backis ignored instead, oneneeds.configwarning.🐛 The
needs.configfinding for a needs_global_options value with unknown keys lists them sorted, so its text is the same on every run. The keys came from aset, whose order follows the hash seed, so the message changed from run to run and could not be pinned by a test; it now reads as the import and external-need unknown-key findings do (issue #2288)🐛 With needs_debug_measurement on, a measured callable that has no
__name__or whose source cannot be read is measured rather than failing. Afunctools.partialnamed by:filter-func:ended the build withAttributeError, one registered withadd_dynamic_functionfailed its call with a warning and lost the field’s value, and a function whose file is gone raisedOSError. A partial is now recorded aspartial(<name>), a callable instance by its type’s name, with no file or line where inspect cannot give one.debug.START_TIMEandEXECUTE_TIME_MEASUREMENTSare annotated, so ty now checks the measuring wrapper, and two# ty: ignorecomments go (issue #1835)🐛 need, need_outgoing and need_incoming – and so a need’s links and backlinks rows – and needtable’s id and link columns no longer end the build on a need that has no document and is not external (one added through the API with
docname=None); they show its text without a link (issue #2244)🐛 A need with no document and no external url – one added through the API with
docname=None– no longer ends the build with anUnboundLocalErrorwhen a needflow or needuml draws it; it is drawn without a link. A need the builder can make no URL for is drawn without one too, where the PlantUML source used to carry an empty[[]]that PlantUML refuses as a syntax error, and needuml’sref()then gives its label as plain text🐛 Listing
sphinx_test_reportsbeforesphinx_needsinextensionsno longer warns that the directivestestfile,testsuiteandtestcaseare already registered: a need type registers its directive once, whetheradd_need_typeor sphinx-needs’ own configuration step comes first. A directive of another kind under a need type’s name is handled as before, with Sphinx’s warning (issue #2271, PR #2276)🐛 A filter
id == Noneselects nothing wherever it is used. On a view already narrowed – a needtable or needlist with:status:,:tags:or:types:, or a filter such astype == "spec" and id == None– it selected every need of the view, as its fast path matchedNoneagainst the empty part id each need carries; an id is a string, so a constant of any other type now matches no need and no part, as the same filter evaluated in Python does (issue #1835)🐛 A filter
status in [...]whose list holdsNoneselects the needs without a status too, asstatus == Nonealready did and as the same filter evaluated in Python does: its fast path kept only the strings of the list, sostatus in ["open", None]selected the open needs alone andstatus in [None]none at all (issue #1835)
Documentation¶
📚 The need_count example counting the needs whose title is longer than ten characters is written in the portable filter language, and counts them (issue #2359, PR #2364)
It wrote a raw string,
search(r"[\w\s]{10,}", title), which the portable language has not, and the role removed its backslashes, so the pattern it ran was[ws]{10,}and the example counted no need. It now writes each backslash twice for the role and twice for the string literal, and the note under it says so: in a role a backslash of a pattern is written four times, or avoided with a character class.📚 A need type’s own entry is documented as the place for most rules about its needs, beside schema rules for the rest (PR #2295)
The schema validation page gains Per-type configuration or schema rules?: what a type’s
fields,linksandinheritscan declare, what still takes a schema rule, and how each is reported – a constraint keyword by the schema validation, the need kept; a field required on the type when the need is created, the need not created. The new how-to Modeling need types walks through fields, status values, tags, links and defaults per type, movingneeds_global_optionspredicates into a type’s entry, and filters over a field some types lack. Both examples are projects in the test suite, which checks the warnings the pages quote.needs_links lists its
schemakey, the Tutorial points toneeds_fieldsschemas instead of the deprecatedneeds_statusesandneeds_tags, and the schema page’s link counts are corrected:maxItemsis a maximum, and a schema rule reports a need with no links only throughrequired, as a localminItemsalone does not📚 This documentation’s own configuration declares its need types as
[needs.types.<directive>]tables, and itshours,amount,valueandunitfields on the need types that use them, a live example of Fields per need type that its build checks (PR #2302)📚 The need-type pages are split into a walkthrough and a reference, with Mermaid diagrams (PR #2309)
Modeling need types gains a “How it works” section before its recipes: the mental model, and two diagrams on its example project – where the fields of each type’s needs come from (a field narrowed by a type and inherited by the type inheriting from it, and fields one type declares alone), and how far a field or link type declared on need types alone reaches: the type declaring it and the types inheriting from it. Fields per need type stays the reference, every rule kept, and points to the walkthrough instead of repeating its worked example. Processing order gains a diagram of the whole path of a need’s values, from what it sets, its defaults and copied links when it is created, through
needextend, the link fields, the back links and every other field, to the checks and the schema validation. The Tutorial gains a short step on a need type thatinheritsanother. The documentation’sdocsextra gainssphinxcontrib-mermaid📚 Derived fields have a page of their own, Derived fields, under Delayed field evaluation (PR #2344)
The “Derived fields” section of needs_fields moves there, reordered for a reader, every label with its text, and the kinds, the roles, what a derived field holds, how a rule is computed and detecting a changed need gain labels of their own; the built-in calls each kind spells (Rules and inline calls) move with it. The docstrings of links_from_content, links_from_filter and links_from_match name their declared forms and say that a link type they fill may be a member of a union, which the derive conformance corpus now pins for an inline
links_from_content(union-over-links-from-content; from the review of PR #2343). Said once now, and linked from the other places: need-id order, the nearest declared form oftr_link, the default values of a field and a link type (Default values), and how to register a function (Registration, whoseadd_dynamic_functionexample now runs as written). The derived-fields page tells the three meanings ofcopyapart, and the[variants]note says that ubCode reads the table from 0.37.0
Internal changes¶
🏷️ ty’s
possibly-unresolved-reference,disjoint-castandmissing-type-argumentrules are on: the bug above is what the first found, and the rest of its findings are rewritten so the checker can follow them🏷️
list2needparses each list item into a typed record (aTypedDict), and_get_titletakes its content as lines (Iterable[str]), as both callers pass it; fifteen# ty: ignorecomments go (issue #1835)🏷️ The
needs,needumlsandschemabuilders’ do-nothing overrides ofget_target_uri,prepare_writingandwrite_doc_serializedtake Sphinx’s own parameter names (andprepare_writingan abstractSet, as Sphinx 8.1 and later declare it), and the needumls files written beside another builder’s output join their directory onto the builder’soutdiras a path rather than a string; ten# ty: ignorecomments go (issue #1835)🏷️ The
needextract,needtable,needbar,needpie,needlist,needsequenceandneedganttnodes declare their attributes’TypedDict(as theneedflownodes already did), and each node handler narrows the node it is handed, so the checker follows a directive’s options from the directive to its handler.needextract’slayoutandstylearestr | None, as an absent option leaves them;build_need_reprtakes any element. Fourteen# ty: ignorecomments go (issue #1835)🏷️ The filter and
needbarattributes declare what the directives store: an absent option isNone(filterandsort_byof every filtering directive, needbar’s axis titles, label rotations,text_color, and itsxlabels,ylabelsandcolors, split once into lists), and a directive’s content is aStringList(filter_code, needbar’scontent).filter_needs_and_partsreturns items of the kind it is given, a filter code’s namespace is typed as the user’s,NeedsView.filter_statusesand its parts twin take any iterable of statuses,Noneamong them, and theid,type,statusandis_externalfast paths of a filter pass only a constant their index can hold, with the same results but theid == Nonefix above. Nineteen# ty: ignorecomments go (issue #1835)🏷️ A
FieldSchemaconstructed with predicate defaults no longer raisesTypeError: its value check readisinstance(v, A) | B. No build reached it, as predicates are attached after construction. That fix, and two infilter_common.pyandviews.py, remove three# ty: ignorecomments (issue #1835)🏷️
NeedsListdeclares theneeds.jsonit holds as aTypedDict, the envelope and each version (every key of a version optional, as aneeds_fileof an older shape can leave any of them out), rather than letting the checker infer it from the first literal; the written file is unchanged. Eleven# ty: ignorecomments go (issue #1835)🏷️ A
needextendappend that joins a computed value with another value of the same field or link type reads the computed value as theFieldFunctionArrayorLinksFunctionArrayit is, andFieldFunctionArraydeclares one tuple whose items are computed parts, text or numbers, rather than one tuple per item type, which no join could be proved to keep. The values a build gives are unchanged. Eight# ty: ignorecomments go, seven inneedextend.pyand one inneeds_schema.py(issue #1835)🏷️ Every function in the shipped code is annotated, and ruff’s
ANNrules keep it so across the workspace;sphinx_needs.setupnow declares its types, and the internalprofiledecorator preserves the signature of what it wraps🧪 A conformance corpus for fields per need type,
tests/fixtures/field_declaration_conformance.toml: 38 cases, one project each, the rules of the section as cases, with the values their needs hold and the findings they give; this repository is its repository of record and ubCode is to vendor it. Its runner and the derived-field corpus’s share their corpus-independent half,sphinx_needs_testkit.conformance(issue #2269, PR #2291)🔧
ENV_DATA_VERSIONis 13: the first build after upgrading re-reads every document, so ajoinrule that 9.0.0 refused, and alinks_from_matchit did not know, are shown on the pages whose sources did not change too (PR #2228), and every stored need carries the names of its derived fields (PR #2289)
9.0.0¶
- Released:
14.10.2026
- Full Changelog:
This release is about computed values. A field or link type can be derived by a rule
in its configuration, per need type with derive_by_type (PR #2178, PR #2191,
PR #2204, PR #2205), and every dynamic function, variant and rule is computed in
dependency order (PR #2134). It is a major release because computed values,
needextend filters (PR #2127) and the needs.json readers (PR #2189) can change need
data in certain corner cases – a value that reads another computed value, a needextend
filter that relied on an earlier needextend’s change, an external source’s lowercase
id_prefix, or a record whose id differs from its key – and their new warnings can
turn a -W build red until the cause is fixed or suppressed; Python 3.11 is the minimum
(PR #1844), and [[…]] in need content and the need_func role are gone
(PR #1919). Also new: [variants] in ubproject.toml (PR #1996), choose /
when / otherwise (PR #2020), :extend_priority: (PR #2083) and content
parsed in its declared markup (PR #2135).
Improvements¶
✨ New choose,
whenandotherwisedirectives include one of several branches of content, chosen by variant data (PR #2020)A
chooseruns itswhentests in order, and the firstwhenwhose condition is true is included; anotherwise, the optional default, comes last; when no test holds and there is nootherwise, nothing is rendered. The other branches are never parsed, so the needs inside them are never created:.. choose:: .. when:: var.arch == "arm" ARM content. .. when:: var.arch == "x86" x86 content. .. otherwise:: Content for every other architecture.
Conditions are exactly those of the if directive, evaluated by the same code, and the conditions after the branch that is taken are not evaluated. A
choosemay contain onlywhenandotherwisedirectives and comments, and nothing outside a branch is ever parsed. Every mistake warns once under the newneeds.choosetype and skips the wholechoose: content outside a branch (refused before the body is parsed, so nothing in it runs), a branch inside another directive or supplied through an include, a branch written with one colon, no branch at all, awhenwithout a condition, anotherwisewith one, a misplaced or secondotherwise, an argument onchoose, variant data that is not configured, and a condition that cannot be evaluated — so a mistake that makes a condition unevaluable, such as a misspelt key or a syntax error, never renders a later branch or theotherwisein its place. Works in reStructuredText and in MyST Markdown. The undocumented warningifgives for a condition whose result is not a bool is now listed in its documentation.✨ Dynamic functions and variants are computed in dependency order, and a value that cannot be computed is reported (changed output) (issue #2064, PR #2080, PR #2081, PR #2134, PR #2136, PR #2143)
A
[[…]],<<…>>or<{…}>is now computed after every value it reads, so a chain of copy calls, a calc_sum over computed summands, a check_linked_values over computed values and a variant condition naming a computed field give the chained value in every build, whatever the document names, the documents an incremental build re-read,-j, the order of the options in a directive, or the order the fields are declared in. The link fields are computed first, then the back links are built, then every other field, so[[copy("links_back")]]reads the need’s back links, in need-id order, and acalc_sumwithlinks_onlyreads the links a[[…]]computes. Your own functions run after the built-in ones of the same step. Link conditions are checked once every value is computed, against the complete back links. The new Processing order section documents the whole order, from theneedextenddirectives to the constraints.A value that reads itself, directly or through other computed values, is not computed and is reported as
needs.derive_cycle(Cycles): a link or array field keeps the items written in it, any other field is left empty; this includes:hours: [[calc_sum("hours")]], whose sum includes its own need, and a variant whose condition reads the field it sets. A read that cannot be ordered is reported asneeds.derive_scope(Reads that cannot be ordered): a link field’s[[…]]or<<…>>reading a computed field that is not a link field, a back link or a dead-link flag (acheck_linked_valuesorlinks_onlysum whose need computes itslinkstoo reads the field on every need, as the needs those links name are known only once the links are computed), and aneed.<field>argument that selects what its call reads while the field is computed in the same step, neither of which is run (the field keeps what a cycle member keeps); aneedextendfilter naming a computed field; and a built-in function reading a field your own function computes. ubCode’s phase 1 computes the same values and reports the same findings, but for three kinds of difference. Registered in ubCode’s divergence register: a boolean result in an integer field, an unparsable variant condition, and the dead-link flagshas_dead_linksandhas_forbidden_dead_links, which are not in ubCode’s vocabulary (a condition naming one is reported there). Removed on ubCode’s side by its own phase 1: a copy of an empty back link list ([]here), and an authored array field that is not computed (on a cycle, or whose result the field cannot hold), which keeps its written items here. Not evaluated by ubCode’s phase 1: thefilterarguments of the built-in functions, which it evaluates from its phase-2 release, but for afilternamingneeds, or readingcurrent_needby a key that is not written out, which ubCode reports instead. The notice warningneeds.derive_unresolvedof the unreleased PR #2080, which reported such reads, is gone, and asuppress_warningsentry naming it is a no-op.A
need.<field>argument is accepted in field and link values, aneedextend’s included (argument); a need that used one in its own field was not created, and aneedextendvalue that used one was dropped with aneeds.needextendwarning. One that selects what its call reads fails the call when its field is unset or empty. ANoneresult, such as acopyof an unset field or a failedcheck_linked_values, adds nothing to a field: alone in a nullable string or array field it leaves the field unset, where it was stored as the text"None", or as[None], which schema validation then refused.✨ A field or link type can be derived by a rule declared in its configuration (issue #2030, PR #2178, PR #2191, PR #2204, PR #2205)
A
derivetable on its needs_fields or needs_links entry, inconf.pyor the TOML file (or passed toadd_field()), names a kind and the kind’s roles, and the rule computes the value for every need from the project’s sources; aderive_by_typetable gives a rule per need type instead, overridingderivefor the types it lists, and a need of a type without a rule holds the field’s default (elseNone, or the empty value of its type), the field closed on every type (Rules per need type). The kinds arecopy(a lookup: the need’s own field, a named need’s, or over a link type),sum,count,min,max,any,allandcollect(roll-ups over a link type or its back links, narrowed by awherefilter),max/minclosed over a link type (transitive),hash(computed after every other field) andfingerprinton a field;links(every need passing a filter) andcontent_links(the needs a need’s content references) on a link type. A rule is computed with the[[…]]of its step, in dependency order, and its findings are those of a call (needs.derive_cycle,needs.derive_scope,needs.dynamic_function), withneeds.derive_uniquefor acopywithselect = "unique"that finds several values. The built-in functions are their per-need spellings (Rules and inline calls). A derived field is closed to authors: a value written for it in a need, or set by aneedextend, is ignored and reported asneeds.derive_authored, and it takes no default. A rule is checked when the configuration is read: one that cannot be read is oneneeds.derive_invalidwarning, naming the kind and the role, and the field holds its empty value; adefaultorpredicatesbeside a rule is reported the same way, and ignored, as is a link type’scopy = trueinto a derivedlinks, or on a derived link type. The empty value a derived field holds is not checked against the field’sschema, asNoneis not; a computed value the schema refuses is reported asneeds.dynamic_function, and the field holds its empty value. The schema in needs.json marks a derived field or link type"readOnly": true, and a need created byneedimportkeeps the derived values it carries. A rule on a core field, or on theparent_needslink type, is not available in this release, and is reported. Afingerprintdigests the whole need – its id, type, title, status, tags, content and every field and link type the project declares that is not derived,linksamong them, each where it differs from its default, a link’s condition dropped – so that a link condition naming it (:links: REQ_1[fp == "…"]) reportsneeds.link_condition_failedonceREQ_1changes; its one role,exclude, leaves names out (Derived fields). No later release changes which names a fingerprint includes, when a name enters, or how the text is written: a fingerprint written down stays current until the need, or the configuration of the fields it reads, changes. ubCode reads the same configuration, and computes the same values and findings, from its phase-2 release.✨ New dynamic function links_from_filter, which links to every need that passes a filter string (PR #1984, PR #2191)
:links: [[links_from_filter("type == 'req' and status == 'open'")]]links a need to every open requirement, in need-id order. The need that contains the call, and its own parts, are left out unlessinclude_self=True; parts are tested only withinclude_parts=True. No match is no link, and no warning; an empty filter is an error. A need the filter cannot be evaluated on, such ashours > 1on a need withouthours, is not linked, without a warning, as for thelinkskind. It is the per-need spelling of thelinkskind of a derived link type.✨
needextendgains:extend_priority:(default 500, lower applied first) (issue #1658, issue #2064, PR #2083)The
needextenddirectives are applied sorted by extend_priority, then by document name and line, so a project that never sets the option keeps its order, and where two set the same option the higher priority is applied last and wins. The priority is set on eachneedextend; there is no project-wide setting for it.✨
generate_need_id()returns the idadd_need()assigns to a need that is given none (issue #2084, PR #2111)An extension that creates needs can now find out, before it calls
add_need, whether that id is already taken – a second definition of the same generated id – without importing the private_make_hashed_id.add_needderives the id with the same code, so the two cannot drift: it takes the same arguments,contentas astror aStringList, and an unknown need type raises the sameinvalid_typeexception.✨
add_need()takes aMarkupContentascontent, and the newingest_need_record()creates a need from a needs.json-style record (issue #1885, PR #2135)A need’s content can be parsed as reStructuredText or MyST Markdown whatever the page’s parser, with its warnings at the source file and line it came from (Content written in another markup); this is what the multi-line needs in source comments of sphinx-codelinks (issue #1885, to follow) build on.
needimportnow creates each of its needs throughingest_need_record. Nothing changes for existing callers. The content is not yet restricted: file-reading directives,raw, relative image paths and nested need directives in it are not refused.✨ needimport can parse each imported need’s content in the markup its
doctypenames: needs_import_parse_by_doctype, and the directive’s:parse_by_doctype:option (issue #1898, PR #2153)Markdown exported from a MyST page then renders as Markdown in a reStructuredText page, and reStructuredText as reStructuredText in a MyST page, where both were parsed in the importing page’s markup, and still are by default: the option is off in 9.x, and turning it on by default is a question for a later major, after feedback. A
doctypethe project cannot parse falls back to the page’s markup with oneneeds.import_doctypewarning per directive perdoctype; a need rendered through atemplateis parsed in the page’s markup.✨ An interactive needtable is Sphinx-Needs’ own script,
needstable.js, instead of the vendored DataTables, and loads only on the pages that hold one (PR #1920)A table with the default
:style: datatablesstill sorts, searches, pages, and switches columns off, in place: every row and cell Sphinx-Needs rendered stays the same element, so:style_row:classes and the links inside cells survive sorting and searching. Two new options set its paging: needs_table_page_size (default10) and needs_table_page_sizes (default[10, 25, 50, 0], where0means all rows); a table can override the first with its own page_size. Removed: the Excel and PDF export buttons and the column reordering of 8.5.0’s DataTables; a table exports through Copy and CSV only (a CSV file opens in a spreadsheet, and a browser prints). The script and its own stylesheet are added only to the pages with an interactive table, sosearch.html,genindex.htmland every page without one load neither; the small commonneedstable.cssthat styles every needtable is still on every page, as in 8.5.0.✨ The variant data can be declared in the
[variants]table of the needs_from_toml file, which other tools reading the same file share (PR #1996, PR #1998)[variants] dataanddata_file(or[<prefix>.variants]underneeds_from_toml_table) are read throughub-project, the shared reader ofubproject.toml, which becomes a dependency (ub-project>=1.1.0,<2). The legacy[needs] variant_dataandvariant_data_filekeys keep working; when both locations are set,[variants]wins, whole (Variant data: the [variants] table). Two new warning types, each of which fails a-Wbuild until it is fixed or suppressed:needs.variant_data_location, once per ignored[needs]key when both locations are set, andneeds.variants_unknown_key, for any other key in[variants]. A mistake in the variant data, whether declared in the TOML file or set inconf.py, is now reported inub-project’s words.👌 The common CSS files are registered in a sorted, deterministic order, so the HTML and the CSS cascade no longer vary between otherwise identical builds (issue #1913, PR #1914)
⬆️
jsonschema-rsis allowed up to 0.58 (>=0.37.1,<0.59; 8.5.0 capped it below 0.53) (changed output) (PR #1851, PR #1980)An invalid regex
patternin a schema now names its location in the error (On instance["properties"]["id"]["pattern"]:) rather thanOn instance:.
Breaking changes¶
‼️ Python 3.10 is no longer supported: the minimum is 3.11 (PR #1844)
requires-pythonis now>=3.11; 8.5.0 accepted 3.10.⬆️ docutils 0.21 or newer is now required (PR #1977)
8.5.0 declared none, so it accepted whatever Sphinx did, which is 0.20 for Sphinx 7.4 through 9.0. Sphinx-Needs imports docutils directly, and 0.21 is the oldest series it is type-checked and tested against. The requirement has no upper bound: Sphinx caps docutils per series itself.
‼️
[[…]]in a need’s content is plain text, and theneed_funcrole is removed (PR #1919)Both were deprecated in 4.0.0, with the ndf role as their replacement. A
[[…]]in a need’s content is no longer executed: it renders as written, as in any other Sphinx document. A document that still writes:need_func:gets docutils’ ownUnknown interpreted text role "need_func"error. Write:ndf:`copy("id")`instead (see Dynamic functions).[[…]]in a need’s options –:status:,:tags:,:links:, extra fields, the needs_global_options defaults – is unchanged.‼️ Computed values are computed in dependency order (changed output) (issue #2064, PR #2134)
Where a
[[…]],<<…>>or<{…}>read a value another one computes, its result depended on the order the needs were read in, and was often the unresolvedNone(stored as the text"None"in a string field), an empty value, or a summand silently dropped. It is now the chained value, in every build, so a project that relied on the old value gets another one: a chain gives its last value; a sum includes its computed summands; a variant condition sees the computed fields of its need, whatever their declaration order;[[copy("links_back")]]reads the back links instead of[]; your own functions run after the built-in ones, so they see computed values; and a need that used aneed.<field>argument is created. A cycle and a read that cannot be ordered are new warnings, so a-Wbuild with one fails: a cycle (needs.derive_cycle), including acalc_sumover every need written into the summed field itself and a variant whose condition reads the field it sets, is not computed; a link field’s call reading a later value (needs.derive_scope) is not run; such a field, and a field whose call fails or returns a result the field cannot hold (needs.dynamic_function, as before), keeps the items written in it if it is a link or array field, and loses the computed ones, and any other such field is left empty. Aneedextendfilter naming a computed field (needs.derive_scope), which never matched the computed value anyway, reads the value from before it is computed. The warnings of the pass come in the order the values are computed (the link fields first; each value after those it reads, otherwise by need id and field), not in document order. To keep such a build green while you fix them, add"needs.derive_cycle"and"needs.derive_scope"tosuppress_warnings.‼️
needextendfilters are evaluated against the needs as written (changed output) (issue #1658, issue #2064, PR #2083, PR #2127)Every needextend filter is evaluated against the needs as written, before any
needextendis applied (Filters see the needs as written); it used to see the changes of theneedextenddirectives applied before it. So noneedextendchanges which needs another one’s filter matches, whatever their priorities and the names of their files.A project whose filter relies on a change made by an earlier
needextend(a filter onstatus == "closed"after theneedextendthat closes the needs it means) now modifies the needs written with that value instead, and no warning says so. To keep what such a filter modified, name those needs by ID, or write the condition on the values as written.A filter is evaluated once in each document it is written in, so a
needs.filterwarning it gives there is reported once, at the firstneedextendapplied that carries it. The notice warningneeds.needextend_match_orderof the unreleased PR #2083 is gone, and asuppress_warningsentry naming it is a no-op.‼️
needimportandneeds_external_needsread a needs.json alike (changed output) (issue #2003, issue #1414, PR #2189)The two readers now read the file, and create each need, through one path, so a project that read a needs.json one way through one of them can notice:
an external source’s
id_prefixis added as written: it is no longer upper-cased, so the ids of a lowercase prefix change (ext_givesext_REQ_1, notEXT_REQ_1), and every reference to them has to follow;needs_id_regex is no longer applied to imported needs (it never was to external ones): the regex is for the ids this project authors, not for the ids it reads – an imported or external need’s id is the data of the project that wrote it, and an
id_prefixmay not match any pattern of this project;a record without a
titleis refused byneedimport(needs.import_need), as it already was for external needs; acontentthat is not a string is refused for external needs (needs.load_external_need), as it already was on import;a need’s id is the key of its record in the version’s
needsobject, not the record’sidfield. A record whoseidfield differs from its key is imported under the key and reported (needs.needimport/needs.external_needs); theidfield used to win, silently. A record whose key is empty is refused by both readers, where the key used to be ignored and the record imported under itsidfield (an external source whoseidfield was empty too created a need with an empty id, or with the bare, upper-casedid_prefix);when two external sources define the same id, the first source listed keeps it and the second is refused with a
needs.load_external_needwarning (the first among the records that were added: a first source whose record is refused leaves the id to the next). This used to depend on the sources’base_url: with different values the second was already refused (the first won), but with the samebase_urlthe second source silently deleted and replaced the first (the last won);a need of this project with the id of an external need replaces the external need, with a
needs.create_needwarning, where it used to be refused and not rendered;a needs.json that cannot be obtained or read – missing, a failed download, not valid JSON, without the version asked for, or without
versionsorneeds– is one warning and adds no need, where the build used to abort (or, for an external source with missing or emptyversions, stayed silent; a missingneedimportfile was already a warning);with an
id_prefix, a link field or an id written in thecontentthat names a need of the file gets the prefix even when:ids:or:filter:leaves that need out of the import. It used to be prefixed only when the target was imported, so such a reference could resolve to a need of the importing project, or to the same id imported unprefixed by anotherneedimport. It is now rewritten to the prefixed id, which exists only if that need is imported with the same prefix; otherwise a link field or a:need:role naming it is a dead link, reported asneeds.link_outgoingorneeds.link_ref(a plain-text id is rewritten and nothing resolves it) – not as a reader warning, sosuppress_warningshas to name those. A reference to an id the file does not contain is still left unprefixed and may resolve in the importing project: the file’s ids are its namespace, and the prefix is the only way to say so;an external source’s
target_urltemplate sees the need with the file’s schema defaults merged, itsidthe key, and a legacydescriptionascontent.
The new warnings (
needs.needimportand the newneeds.external_needs) fail a-Wbuild that used to abort or stay silent; to keep such a build green while you fix the file, add"needs.needimport"or"needs.external_needs"tosuppress_warnings. A reference the prefix rewrites to a need that is not imported is reported asneeds.link_outgoing(a link field) orneeds.link_ref(a:need:role in the content), not as a reader warning, so suppressing the two reader codes does not keep such a build green:suppress_warningshas to name those two as well.
Internal changes¶
🔧 The repository is a uv workspace, and Sphinx-Needs lives in
packages/sphinx-needs(PR #1839, PR #1846)The published package is unchanged; two things that name the repository change. An install from git of a commit after the move needs the subdirectory –
pip install "sphinx-needs @ git+https://github.com/useblocks/sphinx-needs@<ref>#subdirectory=packages/sphinx-needs"– because the repository root is not a package. And release tags aresphinx-needs-v<version>, the shape every package in the repository shares; the bare<version>tag is still pushed beside it, sogit+…@<version>pins and the documentation’sstableversion keep working.🔧 The sdist no longer ships
tests/orperformance/(PR #1905)The suite loads its fixtures from a workspace member that is never published, so a shipped suite could not run;
docs/is still included. Run the suite from a repository snapshot.
Bug fixes¶
🐛 needimport and needs_external_needs read needs.json through one reader and one record path (issue #2003, issue #1414, issue #2158, issue #2165, issue #1472, PR #2189)
Both readers take the file’s envelope, the version and the need records from one reader, and create each need through one record path, which keeps the ten fields each reader reads differently (how an imported need is rendered; where an external need was) as the one stated difference. A file no need can be read from is one warning, at the directive for
needimportand asneeds.external_needsfor an external source, and the build goes on. The key of each record is its id, so a record with a missing or non-stringidis read under its key instead of crashing the build, and anidthat differs from the key is warned about. A record whosepartsis not a mapping is refused with a warning instead of crashing the build. A file written without its defaults and without the schema to restore them is warned about. A record whose key is empty is refused. With anid_prefix, a link or a reference in the content to a need of the file is prefixed also when:ids:or:filter:leaves that need out, a link given as a string is prefixed too (unless it holds a dynamic function or a variant, which is left as written), anulllink no longer crashes the build, and an id inside a longer word of the content is no longer rewritten. An:ids:naming an id the file does not have is warned about, and a:filter:that fails is warned about once per directive rather than once per need. An external need left from a previous build is replaced on an incremental build (or removed, when the source now refuses its record), a need of this project that holds an external need’s id is reported with aneeds.create_needwarning on every build, and a duplicate across this build’s sources is warned about. A download that fails, also with an HTTP error status, is reported with its reason;needimportreads afile://URL as a URL, and a local file it misses is read on the next incremental build once it exists. An external source’starget_urltemplate sees the need with its schema defaults merged, itsidthe key, and a legacydescriptionascontent.🐛 check_linked_values and calc_sum with
links_onlyread the need of a link to a need part, and skip a link to no need (changed output) (issue #2173, PR #2177, PR #2194)A link may name a need part (
:links: REQ_1.a), and both functions looked such a link up by its whole text, which names no need: the call failed with aneeds.dynamic_functionwarning and the field was left empty. A part link now reads its need’s fields, as the back links already count it on that need, so two parts of one need read that need twice, as a need linked twice is read. A link whose text has a dot is read as<need>.<part>, as every other reader of a link reads it, so one naming a part the need does not have reads the need, and one whose text before the dot names no need is a link to no need. A link to no need is now skipped, as the derived-field kinds skip it; it failed the call, a second report of the dead link, which is reported as before, and the field was left empty. ubCode reads a part link the same way, and skips a link to no need as it does from its phase-2 release.🐛 A needs_fields entry named after a link type (
links,parent_needs, or one of needs_links orneeds_extra_links) is reported and ignored, instead of stopping the build (“Field ‘tests’ already exists”, or “Same name for link and field”) (PR #2194)It is a
needs.configwarning; aparent_needsentry carrying aderiverule is reported as a rule on a core field,needs.derive_invalid. The link type works as before.🐛 An integer a dynamic function or a variant gives is a float in a
numberfield (changed output) (PR #2194):hours: [[copy("points")]],pointsbeing anintegerfield, stored3in thenumberfieldhours, where an authored3is3.0:needs.jsonwrote3, and ahashrule over the field read[3]; so did<{ var.n }>withnan integer in the variant data. A value computed into a field takes the field’s type, as a derived field’s does and as ubCode stores it: a float in anumberfield (and in an array of numbers), an integer in anintegerfield. A float returned into anintegerfield is still reported, and a boolean is not a number.🐛 copy with
upper=Trueorlower=Truechanges the case of each item of a list (changed output) (PR #1984, PR #2194)The whole list used to be converted to its printed form first, so
:tags: [[copy("tags", "SRC_1", upper=True)]]on a need taggedalpha, betagave one tag,['ALPHA', 'BETA'], brackets and quotes included. It now gives the two tagsALPHAandBETA. A value that is not a list is unaffected.🐛
c.this_doc()works in thefilterof copy (changed output) (PR #1984, PR #2194)The filter was evaluated without the document of the need, so
c.this_doc()ended in athis_doc can not be used in this contextwarning, nothing passed the filter, andcopyread the current need instead.🐛 ndf shows a link a dynamic function returns as its need id (changed output) (PR #1984, PR #2194)
A function returning links, such as links_from_content, was shown as
NeedLink(id='REQ_1', part=None, condition=None); it is nowREQ_1, orREQ_1.p1for a part.🐛 The
filterof calc_sum can nameneeds(changed output) (issue #1452, PR #1453, PR #2194)The filter was evaluated without the list of all needs, although a Filter string documents it, so a filter such as
any(id in s["links"] for s in needs if s["type"] == "story")ended in aname 'needs' is not definedwarning for every need, and the value was summed as if there were no filter. Such a filter is evaluated after the other built-in functions; a flag declared on each need, and a filter naming it, is the portable and faster spelling (Derived fields).🐛 Link ids that sort alike are listed in one order in every build (changed output) (PR #2193)
needs.jsonand the HTML list a need’s links and back links in natural order (REQ_2<REQ_9<REQ_10, letters case-folded), and ids that order alike in it, such asR_02,R_2andr_2, came in the order of the build’s set of links, which could change from one build to the next. They now follow the id itself, compared character by character:R_02,R_2,r_2, and links to one target under several conditions follow the link with its condition (R_2, thenR_2[status == 'closed'], thenR_2[status == 'open']). Ahashrule writes ids with one natural key in the same order, and a target under several conditions once, as it drops the conditions. ubCode sorts them the same way from its phase-2 release.🐛 A change to needs_fields or needs_links (and the deprecated
needs_extra_options,needs_extra_linksandneeds_global_options) re-reads every document (PR #2192)The needs of the documents an incremental build did not re-read kept what they were created with: a
defaultorpredicatesadded to a field (or toneeds_global_options) was not applied to them, and a field made derived kept its authored value there. A changed field or link configuration now re-reads every document.🐛
needextend’s:+field:on a nullable field the need never set sets the field, instead of crashing the build (issue #2038, PR #2102)A field of needs_fields is nullable unless it says otherwise, so a need that does not set it holds no value. Appending a value to such an unset array field ended the build with
Value after * must be an iterable, not NoneType, and appending a dynamic function to an unset array or string field ended it withCannot append non-string/array value; appending a value to an unset string field already set it. Appending to an unset field now sets it to the appended value in every case, as:+tags:does on a need without tags. The two events an extension can connect to around theneedextenddirectives,needs-before-post-processingandneeds-before-sealing, are now documented in the Python API.🐛 An if condition whose result has no truth value is reported, instead of ending the build (changed output) (issue #2025, PR #2029)
Taking the truth value of a result runs the result’s own
__bool__, which may raise, as it may for a value of needs_variant_data of a user-defined type. That ended the build with a traceback, after the warning for a result that is not a bool. It is now the onedirective expression failedwarning of theiforwhen, and the condition cannot be evaluated: the body is skipped, and awhenskips its wholechoose, as for any other condition that fails. A result whose truth value can be taken but whose repr raises, which ended the build too, is now reported with a placeholder in the warning for a result that is not a bool, and its truth value is used.🐛 An if warning in an included file names that file by its absolute path (changed output) (issue #2027, PR #2029)
It named the file as docutils records it, relative to the working directory (
docs/inc.txtfor a build run from the project’s parent directory), where awhenin the same file names it absolutely, as Sphinx names the file of a node’s location.🐛 calc_sum and copy(filter=) read needs in need-id order (changed output) (issue #2064, PR #2078)
A whole-project
calc_sumadds the needs’ values in ascending need-id order, andcopywith afiltercopies from the match with the lowest id, comparing ids as strings (REQ_10comes beforeREQ_9). Both used to read the needs in the order they reached the build environment, so the last digits of a sum of non-integer values, and which needcopy(filter=…)copied from, depended on which documents the last build re-read and on-j; they no longer do, and for a sum of literal values over every need, the total is the one ubCode computes. Acalc_sumwithlinks_onlykeeps adding in the order the links are written. The error for acalc_sumoutside a need now namescalc_sum.🐛 A
functionskey under[needs]in the TOML file is ignored with a warning instead of crashing the build (changed output) (issue #2064, PR #2079)needs_functions holds Python callables, which a needs_from_toml file cannot hold, and the key ended the build with
'str' object has no attribute '__name__', whether it was an array, a string or a table. It is now oneneeds.configwarning and the key is ignored, whatever its value: an emptyfunctions = []is reported as well, and no longer clears theneeds_functionsofconf.py. The same crash came fromconf.pyfor aneeds_functionsentry that is not callable, which is now skipped with aneeds.configwarning instead.🐛 A needs_functions value that is not a list, and an entry without a
__name__, are reported with a warning instead of crashing the build (changed output) (issue #2073, PR #2112)needs_functions = None, or a bare function where a list of functions belongs, ended the build withTypeError: ... is not iterable, and an entry without a__name__, such as afunctools.partialor an instance with__call__, ended it with anAttributeError, because a dynamic function is registered, and called, by its name. A value that is not a list or tuple is now oneneeds.configwarning naming its type, and nothing is registered from it; a string, which was read one character at a time with a warning for each, is reported the same way. A set of functions, or another iterable of functions that is neither a list nor a tuple (a frozenset, a generator), used to register them beside Sphinx’s own type warning, and is now ignored with the sameneeds.configwarning. An entry without a__name__is skipped with aneeds.configwarning, and the rest of the list is still registered. Such a callable is registered withadd_dynamic_function()and itsnameargument, which now raisesNeedsApiConfigExceptionasking for that name when it is not given, instead of anAttributeError.🐛 Under
-j N, a need id defined in two documents renders its card once, on the document that kept the need (changed output) (issue #2087, PR #2106)Serially, the second definition is refused with a
needs.create_needwarning. In a parallel build, two documents read by different processes each created the need; the merge kept one and warnedneeds.duplicate_idabout the other, but the other document’s page still rendered a card: the kept need’s title and fields over the dropped directive’s content. A needextract of the id could copy the dropped directive’s content as well. A need’s card is now rendered only on the document the need is recorded on, in every builder, andneedextractcopies the kept need’s content.🐛 On Sphinx 7.4 with
show_warning_types = Truethe[needs.*]type of a warning is shown once, not twice (issue #2091, PR #2108)Before Sphinx 8, Sphinx-Needs appends the type to its warnings itself, as Sphinx 8 does by default; it also did so when
show_warning_typeshad Sphinx 7.4 append it, so the line ended in[needs.link_outgoing] [needs.link_outgoing]. It is now appended only where Sphinx does not append it.🐛 A service whose
classcannot be registered is skipped with a warning instead of crashing the build (changed output) (issue #2067, PR #2113)A needs_services entry with both
classandclass_initis registered from them, and aclassthat is not callable or has nooptionsended the build with'str' object has no attribute 'options'– which everyclassset in a needs_from_toml file did, since that file can only give it a string. Aclass_initthat is not a mapping ended it the same way. Such a service is now oneneeds.configwarning, naming the key and what is wrong with its value, and is not registered; the build goes on. A service whoseclassis callable withoptionsand whoseclass_initis a mapping registers as before, whether or not the class derives fromBaseService, and a table that holds a service’s options only is read as before, without a warning.🐛 A needservice naming a service that is not registered is a warning instead of a traceback (changed output) (issue #2101, PR #2113)
It ended the build with a raw
NeedsServiceExceptiontraceback, which, deriving fromBaseException, escaped Sphinx’s own error handler, so no log file was written either. It is now oneneeds.load_service_needwarning located at the directive, with the same text, which names the service and the registered ones; the directive adds nothing and the build goes on. This is also the path of a service skipped for its configuration, above.NeedsServiceExceptionnow derives fromException.🐛 A needextend option whose dynamic or variant function cannot be parsed is a warning instead of crashing the build (changed output) (issue #2109, PR #2116)
A value such as
:status: [[copy(need.id)]]ended the build with an uncaughtFunctionParsingException, because aneed.<attr>argument is not admitted where the directive parses its options; any other dynamic function that cannot be parsed, and a variant function that cannot be parsed (VariantParsingException), ended it the same way. Each is now oneneeds.needextendwarning at the directive, naming the option and the parse error, and that option is skipped while the directive’s other options still apply, as for a value that cannot be converted. Whether aneed.<attr>argument should be admitted in aneedextendvalue is a separate question, unchanged here.🐛 needimport imports a need without
tagsunder:tags:, and reports a need whosecontentis not a string instead of crashing the build (changed output) (issue #2132, issue #2147, PR #2163)A
:tags:option ended the build withKeyError: 'tags'on a needs.json record that has notagskey, as a hand-written file or another producer may omit it, and with aTypeErroron one whosetagsisnull, a string or another value that is not a list. The option’s tags are now added to the record’s own for a missing,null, list or stringtags: a missing ornulltagsgets the option’s tags, a list is extended, and a string, an empty one included, is extended with the option’s tags and converted asadd_needconverts a stringtagswithout the option (with:allow_type_coercion: falsethe record’s string is refused as it is without the option); any other value is refused byadd_needas atagsvalue that is invalid. A record whosecontent– or, when that is empty, the legacydescription– is not a string, such as5ornull, ended the build with anAttributeError, whether or not its content was parsed by itsdoctype; one whosetypeis a list or an object ended it with aTypeError. Each is now theneeds.import_needwarning naming the need and the key (content must be a string, not int), and the need is skipped; a record whosetypeis another value that is not a string, such as5ornull, is reported with the same text instead ofUnknown need type 5.. A record with nocontentkey, or an empty one, still imports with empty content.🐛 needgantt rounds a completion given as a float to a whole percentage (PR #1870)
PlantUML’s gantt grammar takes an integer percentage, and PlantUML 1.2026.8 rejects a statement such as
is 90.0% completed, losing the whole chart; a completion field typednumberis how such a float arrives.
8.5.0¶
- Released:
03.09.2026
- Full Changelog:
This release is about charts, and about the tooling behind the project. needpie
and needbar gain a scope — the same :filter:, :status:, :tags: and
:types: options a view directive takes — and accept the cypher option a chart
authored for ubCode carries, so one document builds in both tools. Schema validation
errors now name the keyword that failed and report a $ref at its definition, which
changes their text. The bug fixes continue the previous release’s theme: a needuml,
needarch or needextract input that used to end the build with a traceback,
and a malformed needs_warnings filter, are now located warnings — and, for a project
that builds with -W, can turn a green build red until the reported mistake is fixed or
suppressed. Under the hood the development toolchain moves to a committed uv.lock,
poe tasks and ty; none of that touches the published package.
Improvements¶
✨ needpie and needbar now accept the
:filter:,:status:,:tags:and:types:options, as the scope a chart is counted over (PR #1831)The four options were rejected on both chart directives with an
unknown optionerror. They now select the needs and parts a chart counts over, once for the whole chart: every content line or grid cell is counted as its own result restricted to that scope, a static value such as10is left alone, and a chart that carries none of the four counts over the whole project exactly as it did before.A scope holds what the same four options select on a view directive such as needlist, so a chart and a list written with the same options select the same needs. On needpie a
:filter-func:is handed the needs of the scope, as the same view an unscoped chart hands it, so a scope restricts what such a function counts from, not what it returns. The view gains one public method for that,NeedsAndPartsListView.filter_id_complete, which selects exactly the given needs and parts byid_complete.Neither directive gains an empty state it did not have: a pie of only filter lines whose scope selects nothing shows its
:filter_warning:text, exactly as it does for filters that match nothing, while a bar chart, which has no such text, draws all zeros.This is also the Sphinx-Needs half of a chart authored for ubCode: the
cypherquery ubCode reads as a chart’s scope is ignored by a Sphinx build, so writing the same scope with these options beside the query makes both tools count over the same needs. See common filters and common filters.👌 Schema validation errors now name the failing keyword, and report
$reftargets at their definition (changed output) (PR #1819)The
jsonschema-rsrequirement moves from~=0.37.1to>=0.37.1,<0.53.0, which brings a rewritten error renderer with it. Which schemas validate, which needs are reported, and the warning subtypes (sn_schema_violation.*) are all unchanged — only the message text is different.The failing keyword is now named, and the instance path is given relative to the sub-schema that failed rather than from the root:
- Failed validating in schema + Failed validating "pattern" in schema["properties"]["efforts"] - On instance["properties"]["efforts"]: + On instance:
A
$refis reported where it is defined, instead of through the reference:- Failed validating "const" in schema["properties"]["contains"]["$ref"]["properties"]["type"] + Failed validating "const" in schema["$defs"]["LinkItemSchemaType"]["properties"]["type"]
And the names listed by
Unevaluated properties are not allowed (...)are no longer sorted alphabetically. The set of names reported is unchanged, and the order is stable.If you match on this text — in a test, a log filter, or a
suppress_warningsentry keyed to a message body rather than to a subtype — it will need updating.✨ The
cypherdirective option is now accepted on needpie and needbar for ubCode compatibility (PR #1818)The two chart directives join needlist, needtable and needflow in accepting this option and then ignoring it, so that a document authored for ubCode also builds with Sphinx-Needs, instead of failing with an
unknown optionerror. The option never reaches a node, the rendered output, or theneeds.jsonfile.On needpie the no-op is visible in the chart, though, which it is not on the three view directives: ubCode reads the query as the scope each content line is counted over, whereas Sphinx-Needs ignores it, so the same chart can show different numbers in the two tools.
On needbar the option is accepted so that a document already carrying it builds in both. See ubCode compatibility for the exact per-directive list.
Internal changes¶
🔧 mypy is replaced by ty for type checking (PR #1830)
The
typingdependency group is the pinned floor environment — the oldest supported Sphinx and Docutils series, the stubs, and ty itself — installed into.venvs/typing, anduv run poe typecheckchecks against it, as do the prek hook and CI. Nothing about the published package changes: the group is development-only metadata, like the rest of[dependency-groups].🔧 The development extras
test,test-parallelandbenchmarkbecome dependency groups, tox is replaced by poe, and CI installs every job fromuv.lock(PR #1823)The three extras installed only the tools this project is developed with, so this does not affect users of the package;
pip install sphinx-needs[test](or[test-parallel], or[benchmark]) no longer resolves, because dependency groups are not published metadata. A contributor gets them withuv sync, and every task — the test suite against each supported Sphinx series, the type checker, the documentation builds — is listed byuv run poe, as Contributing describes.The
plotting,docsand the othertheme-*extras are unchanged.theme-furonow requires furo 2025.12.19 or newer, the first release of that theme that supports Sphinx 9. Every earlier release caps Sphinx below 9.0, so a documentation build with the furo theme could not use the Sphinx this package already supports.
Bug fixes¶
🐛 A needs_warnings filter that is neither a string nor a callable is now reported, instead of ending the build (changed output) (PR #1830)
The guard for such a value called the warning logger without its
subtypeandlocationarguments, so it raisedTypeErrorat the end of the build rather than logging anything. The entry is now reported as aneeds.configwarning and skipped, and the remaining warning checks still run.🐛 Eight needuml and needarch inputs that were ignored, or that ended the build, are now reported (changed output) (PR #1800)
Three of them ended the whole build with a Python traceback and a “report this to the developers” banner, none of them naming the document it came from:
An
:extra:value containing a second colon — a URL, a time, a namespaced identifier — raisedValueError: too many values to unpack. A pair is now split on its first colon only, with both halves stripped, so such values are usable; a segment carrying no colon at all is reported and skipped, and an empty one (from a trailing comma) is skipped in silence, as an empty:config:segment always has been.uml(id, key=...)naming an arch key the need does not carry raised a bareKeyError, because the guard subscriptedarchbefore testing for the key. The message the code already held, naming both the key and the need, is now the one raised.import()given an option holding a plain string consumed it one character at a time, looking each character up as a need id and reporting the first character as an unknown id. Such a value is now refused by name, and a list of ids is imported as it always was. Note the one shape this ends: under aneeds_id_regexpermitting single-character ids, a string of concatenated ids used to import them one by one, and now errors. An option that is defined but unset still imports nothing, silently.
The whitespace strip is the one change to what a working document renders. It only affects an
:extra:written with spaces around a pair, which the documented example never had::extra: a:1, b:2stored the key" b", unreachable from a template, so{{ b }}rendered empty and now renders2; and:extra: name: Xstored" X"and rendered a leading space, which it no longer does. Both are what the author wrote the pair to mean.The rest were silent, and are unchanged in what they render:
Without
sphinxcontrib.plantumlinstalled, every diagram in the project was replaced by an error node on the page and nothing at all was logged.A
:config:name thatneeds_flow_configsdoes not define was dropped. The names it does define are still applied.A non-numeric
:scale:fell back to 100, which it still does.ref()given bothoptionandtext, or neither, was accepted without a word: its own validation read(option and text) and (not option and not text)and so could never hold. What is rendered is unchanged —optionstill wins overtext, and a call with neither still renders a link with no label.import()ignored an option name the need does not carry.
The two template-function warnings above are emitted once per distinct message for the whole build, so the same call on the same need in a second document is not reported again.
If you build with
-W, the general rule applies here as it does elsewhere in this release series: a mistake that used to be silent — or to crash — is now a warning, and a warning fails a-Wbuild. A project can start failing where it passed even though nothing about it changed, most easily by not havingsphinxcontrib.plantumlinstalled, which now reports one warning per needuml. Silence them withsuppress_warnings = ["needs.needuml"]; the:scale:one keeps the existingneeds.diagram_scalesubtype shared with the other diagrams, so covering both takessuppress_warnings = ["needs.needuml", "needs.diagram_scale"]. A third subtype,needs.uml, already existed and is unchanged: it covers only the needs_uml_process_max_time warning.Finally, the needumls builder no longer truncates the
.pumlfiles an earlier run saved. The generated content is filled in while a document is written, after the environment has been pickled, so a build that re-read nothing held an empty value for every needuml and wrote it over the good file — reproducible with two consecutivesphinx-build -b needumlsruns, the second leaving zero bytes behind. A needuml with no generated content is now skipped instead, which also means a build over an already up-to-date.doctreeswrites nothing rather than emptying everything; use a fresh output folder or-Eto regenerate. A needuml is still not re-rendered when a need it references changes in another document; that needs dependency tracking and is not addressed here.🐛 Six needextract inputs that ended the build are now reported instead (changed output) (PR #1795)
Each of these ended the whole build with a Python traceback and a “please report this to the developers” banner, three of them from the directive’s own option surface:
an argument that looks like a need ID but names no need,
an argument and
:filter:together — the combination the documentation warns about,needs_include_needs = Falsewith any needextract in the project, which gave no diagnostic at all,a
needtablein the content of an extracted need,a
needextractin the content of an extracted need,a footnote reference in the content of an extracted need.
The first three were one defect: the name holding a needextract’s filter result was assigned inside the loop over a document’s nodes and read once after it, so any node taking an early exit left it unbound. All three are now reported (or, under
needs_include_needs = False, silently dropped, exactly as every other view directive drops itself) and the rest of the build stands.The other three come from when a need’s content is copied. It is snapshotted while the need’s directive runs, before any of its document’s transforms, and spliced into the extract’s document after all of that document’s transforms — so it sees neither document’s pipeline, and a handful of transforms are replayed over it by hand. One of those replays,
env.resolve_references(), ends by emittingdoctree-resolved, with the detached container holding the copy standing in for a document: every listener of the event ran a second time on a node that is not a document, this extension’s own listeners included. Sphinx’s post-transforms are now applied directly instead, so the event is emitted once per document and always with a document — a guarantee a third-party listener gets too.What a copy cannot render is now dropped from it and named, rather than reaching a processor or the writer that cannot cope:
needbar,needextract,needpie,needtableandneeduml— and soneedarch, which isneedumlrestricted to a need’s content — in the content of an extracted need are omitted from the copy, each reported at the needextract site.A footnote reference in it is rendered as the marker its author wrote, without the trailing
_, and reported. The footnote’s own text stays where it is, so nothing disappears from the page.
Everything else a copy carries is unchanged, byte for byte: rich markup, code blocks, images, substitutions, nested needs, figures under
numfig, and needs extracted in their own document or defined later in the build. In particular the reference contract is untouched — a:ref:or:need:inside extracted content still resolves to the page the need is written on, and so does the extract card’s own ID chip.
8.4.0¶
- Released:
27.08.2026
- Full Changelog:
This release is about the view directives, and about a build that no longer stops at
the first bad value. needflow gains a portable vocabulary — a :direction: that
means the same thing on both engines, named legend configurations, and a
:show_link_names: that says what each connection is labelled with — alongside a long
list of fixes to both of its emitters. needs_card_layouts describes a need’s card
as a small dictionary instead of a hand-written layout string, list2need builds its
needs directly and so works in Markdown documents and records the line each need was
written on, and every view can cap what it shows with max_items. Running through the
rest is one theme: configuration mistakes and render failures that used to end the build
with a traceback are now located warnings, which leaves the rest of the build in place —
and, for a project that builds with -W, can turn a green build red until the reported
mistake is fixed or suppressed.
Improvements¶
✨ list2need works in Markdown documents, and records the line each need was written on (issue #1349, PR #1790)
The directive used to render every item into a need directive through a template and hand the result back to the parser. That step is gone: the items are built directly, and a nested item is placed inside its parent. The syntax and its parsing are untouched — the same list structure, the same
(ID)capture, the same:delimiter:split, the same((option="value"))region, the same validation — so a list that built before builds the same needs, with the same IDs, apart from the one class of item named under Breaking changes below.What the step cost, and is therefore fixed:
A list written as a
{list2need}fence in a MyST Markdown document produced no needs at all, only an error naming a myst-parser internal. It now creates its needs, like any other directive.Handing generated text back to the parser advanced its line counter for the rest of the file, so every need from the directive onwards — the items themselves, and any ordinary need directive written below them — was recorded at a line further down the file than it was written, by an amount that grew with each list in the document. Every
linenoinneeds.jsonis now the line the need was written on, inside aneval-rstblock in a Markdown document too.An item written
()with options, such as* ()A title ((status="open")), lost them: they became body text. They are now set.
Four inputs that used to be errors are now defined, none of which a document that built cleanly can contain:
((id="MY-ID"))names the need. The template wrote both the derived ID and this one as two:id:lines of the same generated need, which docutils refused withduplicate option "id", so the item was dropped. The ID is applied before:links-down:is built, so the links of the other items agree with it. An empty((id=""))is refused with a diagnostic instead.An inline option naming the same link field as
:links-down:—((links="X"))under:links-down: links— used to produce one corrupt link value and anunknown outgoing linkwarning. The two sets of links are now merged.An item carrying
((title_from_content="true"))reads it as a need directive does.A child of a
((hide="true"))item is rendered at the level above it, rather than being placed inside a need that is taken out of the document.
The content of a parent need no longer holds the generated reStructuredText of its children — nesting is a property of the document, not of the parent’s text — so
needs.json, and a filter readingcontent, see the item’s own text only.👌 needs_variant_data is resolved while the configuration is being initialised (issue #1783, PR #1787)
The needs_variant_data_file is loaded, and the inline needs_variant_data merged on top of it, during
config-initedinstead of when document reading starts. What is merged, and which value wins — inline over file,sphinx-build -Dover needs_from_toml — is unchanged, as are the errors reported for a file that is missing or does not contain valid variant data. Only the point in the build at which the work happens has moved. The full-rebuild fix this also brings is described under Bug fixes below.A file that cannot be used now fails the build during configuration, before any document is read, rather than once reading has begun.
An extension that handles
config-initedafter Sphinx-Needs can now read the merged map, which matters because configuration deciding which documents exist at all — such asexclude_patterns— can only be changed while that event is running.In return, an extension that writes needs_variant_data from its own
config-initedhandler no longer has the file merged into what it wrote, and no longer has it validated: resolution has already happened by then, so the value is taken as it stands. It is used consistently — the variant role andvar.*filter expressions always read the same map — but if you write the configuration this way and rely on the merge or the validation, set needs_variant_data inconf.py, in needs_from_toml, or withsphinx-build -Dinstead.✨ New needflow
:direction:option and needs_flow_direction configuration (PR #1782)A diagram says which way it flows as an intent —
down(the default),up,rightorleft— and each engine spells that in its own language, so the same document renders the same way on either engine. The tokensTB,TD,BT,LRandRLare accepted as aliases, so a habit picked up from Graphviz or Mermaid does not have to be unlearned... needflow:: :direction: right
PlantUML has no bottom-up or right-to-left layout, so
upis drawndownandleftis drawnright, with oneneeds.needflowwarning per project; Graphviz draws all four. A diagram is never refused for asking: a plainer diagram is better than a failed build.An explicit
:direction:also wins over a layout that the:config:it is written beside happens to set, on both engines, and the disagreement is reported. A diagram that does not use the option keeps byte-identical diagram source.✨ needflow
:show_legend:takes the name of a legend configuration (PR #1782)Written bare it draws exactly the legend it always drew, so no existing diagram changes — including the long-standing difference that
plantumllists every configured need type whilegraphvizlists only the ones it drew. Written with a value it names an entry of the new needs_flow_legends:needs_flow_legends = { "beside": {"parts": ["types", "links"], "placement": "external"}, }
A legend with
placement = "external"is rendered as a document table beside the diagram, so it looks the same on both engines, its text is selectable and searchable, and it can describe link types — which no in-diagram legend ever could. It lists only what the diagram actually drew.partsis an ordered list, and the order is contract:["links", "types"]puts the link table first and keeps it there.The new needs_flow_show_legend says which legend a diagram gets when it asks for one without naming it — never whether: asking stays with the directive. Resolution is a chain — the option’s name, then the project default, then the engine’s own legend — and a name that is not defined warns and hands on to the next step, so a typo in one diagram does not cost the project the legend it configured.
A
needs_flow_legendsentry that cannot be used is reported as aneeds.configwarning and skipped, rather than failing the build.✨ New needs_card_layouts configuration, for describing layouts declaratively (PR #1765)
A card specification states what a need should show —
header,meta,footer,sideandcollapse— as a small dictionary, instead of as hand-written layout strings. Specifications are compiled into needs_layouts entries during configuration, so a card works wherever a layout name is accepted, and can inherit from another card or from a built-in layout viaextends:needs_card_layouts = { "product": { "extends": "clean", "meta": {"include": ["status", "tags"]}, "footer": ["id", "type"], "collapse": "closed", } }
needs_layoutsis unchanged and remains supported for layouts the card vocabulary cannot express. A specification that cannot be compiled, or whose name is already taken by an existing layout, is reported as a newneeds.card_layoutwarning and skipped, leaving the rest of the build untouched. See Card layouts for the full vocabulary and its documented limits.✨ needs_card_layouts elements gain an object form (PR #1766)
Every element string is now shorthand for an object with a
typekey —"image:diagram"is spelled{"type": "image", "field": "diagram"}— and the two spellings mix freely in one list. An object without options compiles to exactly the same layout as its string shorthand; the strings stay valid and remain the documented default. The object form exists to carry options:heightandwidthonimageelements, andlabelonfieldelements, replacing the field name in the renderedname: valuepair:needs_card_layouts = { "illustrated": { "footer": [ "id", {"type": "field", "field": "owner", "label": "Owned by"}, ], "side": { "elements": [{"type": "image", "field": "picture", "height": "40px"}] }, } }
Option values are grammar-bound; an option on the wrong type, an unknown key, or a value outside its grammar is reported as a
needs.card_layoutwarning and the card is skipped, like any other invalid specification. See the object form for the option table and grammars.✨ The
cypher,widthandheightdirective options are now accepted for ubCode compatibility (PR #1760)needlist, needtable, needflow and needsequence accept these ubCode-only options and then ignore them, so that a document authored for ubCode also builds with Sphinx-Needs, instead of failing with an
unknown optionerror. Nothing about the build changes: the options never reach a node, the rendered output, or theneeds.jsonfile. See ubCode compatibility for the exact per-directive list.✨ The
max_itemsoption on needlist, needtable, needflow and needsequence now limits how many items a view shows (PR #1761)The limit is applied after filtering and sorting, so a view keeps the first items it would otherwise have rendered; on needsequence it counts messages rather than needs.
:max_items: 0means no limit, and a view without the option falls back to the new needs_views_max_items configuration, which defaults to0— so nothing is limited until you ask for it, and existing projects render exactly as before. A view that was truncated says so, instead of silently dropping needs: it adds a notice to the page and emits aneeds.max_itemswarning, which a project that caps deliberately can silence withsuppress_warnings = ["needs.max_items"].Previously the option was accepted and ignored for ubCode compatibility, which was only ever in an unreleased state, so no released behaviour changes. The stored environment version is bumped for the new directive option, so the first build after upgrading re-reads every document.
👌 needs_string_links is validated when it is loaded, and no longer fails the build (PR #1767)
A configuration entry used to be looked at only while a need was being rendered, and then indexed into blindly. A missing key, a regular expression that does not compile, a template that does not parse, or an entry that is not a dictionary each aborted the whole build with an uncaught exception naming neither the entry nor a file — and did so even when no need used the field the entry names.
Every entry is now validated once, during configuration. A problem is reported as a new
needs.string_linkwarning naming the entry, and only that entry is skipped, so a configuration that used to fail the build now builds and renders everything else. The same warning also covers the cases that previously passed in silence — an unknown key inside an entry, anoptionsentry naming a field that is registered nowhere, an emptyoptions— none of which skips the entry.If you build with
-W, take this as the general rule: a configuration mistake that used to be silent — or to crash — is now a warning, and a warning fails a-Wbuild. So a project whoseneeds_string_linkscontains anything questionable can start failing where it passed, even though nothing about it changed. The same goes for the list-field fix below, which reaches render-time failures that the meta area used to swallow. Silence the configuration warnings withsuppress_warnings = ["needs.string_link"]; render-time failures keep the existingneeds.layoutsubtype, so covering both takessuppress_warnings = ["needs.string_link", "needs.layout"].Two spellings of
optionsare now skipped with a warning, and both used to render links, so if your links have disappeared this is the paragraph to read. A bare string was accepted before, but with two contradictory meanings: the,/;splitting silently did not happen, while the per-field test degraded into a substring match, sooptions = "myfield"also applied to a field namedmy. A mapping ({"myfield": True}) worked by accident, through iteration over its keys. Write either as a list. A list, tuple, set or frozenset of names is accepted, as is an already-compiledre.Patternforregex(a bytes pattern is not, as it could never match a field value).👌 needflow
:debug:shows the generated diagram source as a code block under the plantuml engine too (changed output)The plantuml engine emitted raw HTML, an unnumbered and unstyled
<pre>block, where the graphviz engine emitted a literal block, so the same option gave the source line numbers and the theme’s code styling on one engine only. Both now emit a literal block. The plantuml source is shown unhighlighted, because Pygments has no PlantUML lexer.This is a deliberate change to the rendered page rather than a fix: a project that styles or scrapes the debug block sees the new markup.
Deprecations¶
🔧 The undocumented
needtable:style_col:option is deprecated — it was declared but never read, so it has never had any effect. A document that sets it still builds and now gets adeprecatedwarning; the line can simply be deleted.
Breaking changes¶
‼️ A list2need item written
()gets the same generated ID as one written without brackets (PR #1790)Writing an empty bracketed group used to suppress the ID of the generated need, which sent it down the need directives’ own ID generator — a different one, which reads needs_id_from_title where list2need’s does not, and hashes the content when the title is empty. One list could therefore carry two kinds of generated ID at once, chosen by two characters of punctuation. The directive now derives every ID itself.
Under the default configuration the two generators agreed for an item whose title carries no options, so almost every project sees no change. A project that sets
needs_id_from_title, writes()on an item with no title, or writes()on an item that also carries an((option="value"))area, gets a different ID for those items, and any:need:reference to the old ID has to be updated. Give such an item an explicit ID —* (MY-ID)A title— if its ID has to stay as it was.The third case is the widest of the three, because it needs no configuration: the ID list2need derives is the hash of the title before the option area is removed from it, which is the ID an item without the
()has always been given, while the second generator hashed the title after it. So* ()A title ((status="open"))moves fromR_328F3toR_0FF10— the ID* A title ((status="open"))already had.‼️ needflow
:show_link_names:takes an optional value, and now wins over needs_flow_show_links (PR #1782)The option chooses what each connection is labelled with:
none,outgoing,incomingortype. Written bare it still meansoutgoing, which is what the flag has always drawn, so no existing document changes; the other three values are new.needs_flow_show_linkstakes the same four values, andTrue/Falsekeep meaningoutgoing/none. Any other non-string value is read for its truth, because that is what a value declared a boolean for years actually did —1still draws labels.A string that is not one of the four values now warns and falls back to
none, where it used to be truthy and draw labels. That is the one input whose behaviour changes. If you build with-W, note that the warning fails the build; silence it withsuppress_warnings = ["needs.config"]or, better, write one of the four values.The option now overrides the configuration instead of being combined with it. A project that turned labels on previously left no way of drawing a single unlabelled diagram;
:show_link_names: noneis that way.Enumerated
needs_flow_*configuration values —needs_flow_show_links, needs_flow_direction and needs_flow_engine — are now matched without regard to case or surrounding whitespace, exactly as the matching directive options always have been. A project whose value only differed in capitalisation stops warning and starts being honoured.
Internal changes¶
These changes do not affect user-facing behaviour:
♻️ needflow’s two engines now share one graph-model pass, with no change to the generated diagram source
Bug fixes¶
🐛 An invalid
predicatesexpression warns instead of ending the build (PR #1791)A
predicatesmatch expression on a needs_fields or needs_links default that cannot be evaluated — one namingsection_nameorcontent, say, neither of which a predicate has access to — used to raise out of the need’s creation and end the whole build with a traceback and a “please report this to the developers” banner. No need was created, no other warning in the project was ever reported, and nothing said which document the expression had failed on.Such an expression is now reported as a
needs.configwarning, located at a need it was evaluated against and naming the field, the expression and the underlying error, and is then skipped: the remaining predicates are still evaluated, and if none of them matches then the plaindefaultapplies, exactly as it does for a predicate that simply did not match. A statically malformedpredicatesvalue — the wrong number of items in a pair, say — has always been reported this way; only the expression itself was left to end the build.The warning is deduplicated on its full message, so a single configuration mistake – such as the name typo above, which fails identically for every need – is reported once rather than once per need. An expression that fails only for some needs, or for different reasons on different needs, is reported once per distinct error.
🐛 A need records the line it is actually written on (changed output) (issue #1349, PR #1789)
rst_prolog,.. include::and list2need each put text into the document being parsed, and each one used to shift thelinenorecorded for every need after it by the length of that text. The shifts compound, so in a document with a prolog and a couple of includes the recorded line was routinely past the end of the file. The line is now resolved back to the one the directive stands on — the same line the directive’s own warnings have always reported.No warning location regresses. The only warning locations that move are the ones this corrects — sites that report at a need’s stored line now name the true one. Everything anchored through the directive’s own location helper, including the content a pre_template or post_template renders, is byte-identical to before.
One thing is deliberately unchanged:
lineno_contentis still the parser’s own counter, because that is what it is used as. (The needs list2need generates recorded their position inside the generated block when this entry was written; PR #1790 builds them directly, so they now record the line of their own list item.)🐛 Fix needs_variant_data_file triggering full rebuilds (issue #1783, PR #1787)
The merged variant data was written back onto the configuration after Sphinx’s
config-initedcheckpoint, so the pickled configuration held the merged map while the next build compared it against the unmerged one — a difference Sphinx read as a changedenvvalue, re-reading every document on every incremental build. The merge now happens before that checkpoint, so an unchanged file is recognised as unchanged and nothing is re-read.Editing the file’s contents is now what triggers the rebuild, because the merged map is part of the configuration being compared. The variant role previously advised a clean build (
sphinx-build -E) to pick such an edit up; that advice is gone, along with the need for it.Projects that set needs_variant_data inline only were never affected and are unchanged.
🐛 needs_string_links no longer makes a field value disappear when its template fails
A template that fails at render time — an unknown filter, say — logged a warning and then returned nothing at all, and the value vanished from the page rather than merely losing its link. It now falls back to the plain text, which is what a non-matching regular expression has always done, and the warning says which need it came from.
🐛 needs_string_links renders separators between items only (changed output) (PR #1718)
In a need’s meta area, the separator condition counted the characters of the value instead of its items, so every item got a trailing
;— and a single-character value got no separator at all. N items now produce N-1 separators, exactly as needtable cells have always done. Fields not named in anyoptionsare unaffected. The one-line fix landed in PR #1718; this release also pins the rule with regression tests on both surfaces.🐛 needs_string_links applies to list fields in the meta area (changed output)
A field holding a list (
tags, or any array field) was linked element by element in a needtable but rendered as plain text in the need itself. Both surfaces now link the elements, so the same field no longer renders differently depending on where you look at it. Empty elements are left alone on both surfaces, rather than linked to the bare url.One consequence is worth calling out for
-Wbuilds: a template that fails at render time on a list field is now reported (as aneeds.layoutwarning, the subtype every render-time failure uses), where the meta area previously failed silently. A project whose list-field template is broken and which has no needtable rendering that field emitted no warning at all before.🐛 needs_string_links drops items that are empty once stripped, so
AB-1, , AB-2is two items rather than three with an empty one in the middle.🐛 needflow no longer fails the build when a need type has no
color(or an empty one) and the diagram shows a legend (issue #1664).coloris optional in needs_types, but both engines read it unguarded while building the legend, so:show_legend:ended the build withKeyError: 'color'. Such a type keeps its legend row, with an empty color swatch; a type whosecoloris set to an empty string no longer emits an empty swatch value either.🐛 needflow needs whose ids differ only in punctuation are no longer drawn as a single node by the plantuml engine.
PlantUML entity names cannot contain punctuation, so ids such as
R-1andR=1both becameR_1and silently collapsed into one node, taking their edges with them. Entity names are now assigned per diagram, so that they stay unique; the names shown by:debug:therefore change for such ids. needuml entity names are unchanged.🐛 needflow
:border_color:accepts a value written with a leading#.#00FF00previously reached graphviz as##00FF00and PlantUML asline:#00FF00, which PlantUML rejects outright. Both engines now normalise the value and add the prefix their own syntax needs. Relatedly, a variant expression that matches nothing now means “no border color” under graphviz, instead of the literal color#None.🐛 needflow
:highlight:filters that consultneedsnow also work for a need with parts or child needs.The graphviz engine draws such a need as a subgraph, and that path evaluated the filter without the needs list, so the same expression could behave differently – or fail the build – depending on whether a need happened to have children.
🐛 A graphviz needflow image without an
:alt:option now getsalt="needflow graphviz diagram".The intended default was unreachable, so every such image was published with an empty
altattribute. Writing:alt:with no value still gives an emptyalt, for a diagram that is purely decorative. The stored environment version is bumped, because the option is recorded differently when it is not given, so the first build after upgrading re-reads every document.🐛 The needflow warning for an unknown
:config:name now names needs_flow_configs, which was misspelled asneed_flows_configs.🐛 The needflow warning for an unknown
:link_types:value now carries the source location of the directive under the graphviz engine, as it already did under plantuml.🐛 A wrapped needflow graphviz label no longer breaks an HTML entity in two.
A need title is wrapped to the label width and escaped for graphviz’s HTML-like labels, but the escaping ran first, so the wrapper counted the characters of an entity and could break inside one: a title holding a quote wrapped to
&quo<br/>t;, which graphviz refuses to render, ending the build withnot well-formed (invalid token). Wrapping now happens first, which also makes the wrap width count what the reader sees rather than what the escaper wrote.🐛 A needs_graphviz_styles element type holding something other than a mapping of attributes is now reported and ignored.
Such a value travelled unchecked into the emitter, where
'str' object has no attribute 'items'ended the whole build with a traceback instead of a message. It is now reported as aneeds.needflowwarning naming the config, and the diagram is drawn without the offending style.🐛 An unknown needs_flow_engine value is now reported, and the default engine draws the diagram.
The value was checked with a bare
assert, which ends the build with a traceback rather than a message — and whichpython -Ostrips altogether, leaving the unknown name to fail somewhere further downstream. It is now aneeds.configwarning, said once for the project.🐛 needflow naming several graphviz
:config:styles no longer leaks the merged style into the diagrams after it.The merge took the first style’s attributes by reference and then updated that same dictionary with the second style’s, rewriting the configured (and built-in) styles in place: every later diagram naming the first style inherited the second one’s attributes, for the rest of the build. A page therefore rendered differently depending on which diagrams came before it.
🐛
c.this_doc()now works in needpie, needbar and the need_count role (issue #1449)These evaluate their filters themselves, and did not pass on the document the directive or role was written in, so
c.this_doc()ended in athis_doc can not be used in this contextwarning and counted nothing. They now resolve it against their own document, as needtable, needlist and the other directives whose:filter:runs throughprocess_filtersalready did.🐛
c.this_doc()now also works in needsequence:filter:, needflow:highlight:and needgantt:milestone_filter:These three options are evaluated with
filter_single_need, which raises on an invalid filter, and none of the four call sites caught it — soc.this_doc()here ended the build withthis_doc can not be used in this contextrather than merely warning. Each now resolves the filter against the document its own directive is written in, continuing the coverage that the entry above began.Filters configured in conf.py, such as needs_constraints and needs_warnings, remain uncovered: they belong to the project rather than to any document, so there is no origin document to resolve
c.this_doc()against.🐛 needpie and needbar images are now byte-identical between builds of unchanged sources.
Matplotlib writes the wall clock time into every SVG and PDF it produces, and — with no hash salt configured — derives an SVG’s internal element ids from a random
uuid4, so two builds of the same chart never agreed byte for byte. The date is now left out of both formats, and the ids are salted with the chart’s own file name, which is already derived from the directive’s target id. This covers every image the directives write: SVG for the HTML builders, PDF for the LaTeX builder, and PNG, which already carried no timestamp. Nothing about the rendered chart changes.🐛 needbar no longer fails the build when
:ylabels: FROM_DATAis given on its own.The default xlabels —
1,2, … one per column — were derived before the ylabels column had been taken out of the content, so there was always one too many of them and the build ended withlength of xlabels: N+1 is not equal with sum of columns: N. Grids that give both label options, or only:xlabels: FROM_DATA, are unaffected.🐛 A needpie with a title now uses it as the image’s
alttext, as needbar already did.Until now every pie was published with the
altdocutils falls back to — the image’s own file URI — which tells a screen reader nothing. A pie without a title keeps that fallback.🐛 A needpie whose values are all zero no longer writes an unreferenced image file.
Such a pie is replaced by the “No needs passed the filters” paragraph, but the chart had already been rendered into
_images/, where it then stayed, referenced by nothing.🐛 needreport reports a template it cannot render, instead of ending the build
A template with a Jinja syntax error — or one that merely applies a filter to a variable that does not exist, which is what the stale example in these docs did — raised out of the directive and took the whole build down with it. That is the failure mode PR #1105 set out to remove, and the missing-file case has warned rather than aborted ever since; the render case now does too, as a
needs.needreportwarning naming the template and repeating the engine’s own explanation. The directive then contributes nothing to the page, exactly as it already did for a template that is missing.Two smaller diagnostics come with it. A needs_render_context entry that takes over one of the reserved context names —
types,links,optionsorusage— is now reported; which value wins is deliberately unchanged, since these have been silently overridable for years, and onlyreport_directiveis meant to be set this way. The collision is a property of the configuration rather than of any one directive, so it is reported once per build. And when needs_report_template holds a path that is absolute in the POSIX sense, the “could not load” warning explains why it names a path nobody wrote down: the value is always resolved relative to the source directory, so such a path is appended to it rather than read from where it points. A Windows drive-letter path is not relative, so it is used as it stands.One consequence is worth calling out for
-Wbuilds: a project that overrides one of those four reserved names renders exactly as it did before, but now emits a warning where it emitted none, so a green build turns red until the entry is removed or the warning is suppressed.🐛 needreport renders without an extension providing
dropdown(issue #899)Each section of the default template is wrapped in a
dropdowndirective, which neither Sphinx nor Sphinx-Needs provides. A project without an extension supplying one got a docutils error per section — at line numbers belonging to the template rather than to the document, so pointing at innocent lines — and, because Sphinx stripssystem_messagenodes, the report then vanished from the page altogether: an empty section, four errors on the console, and a build that still exited0unless-Wwas in use.When nothing provides
dropdown, the report is now rendered withadmonitioninstead, and oneneeds.needreportwarning names both remedies. Projects that do load such an extension are unaffected: the directive is looked up in the registry, so a provider is used exactly as before and nothing is warned about. Nor is an explicit choice ever second-guessed —needs_render_context = {"report_directive": "dropdown"}is honoured as written, provider or not.The substitution is decided on the rendered report and adopted only when it changes it, so a project with a template of its own gains neither the substitution nor the warning unless it was actually rendering a
dropdown. A template that never produces one — because it writes its own directive, or shadowsreport_directivewith a{% set %}— is left exactly as it is, and so is one with.. dropdown::hardcoded in it, which re-rendering cannot reach. If the substituted render fails where the default one succeeded, the default is kept and nothing is reported.The decision is a textual scan of the rendered report, so a template that merely shows
.. dropdown::as example markup while producing it throughreport_directiveis treated as though it used it.🐛 needgantt draws each task once, in its type color (changed output) (PR #1778)
Tasks are declared as
[<title>] as [<id>], which binds every later[...]reference to the id, but the completion and color lines addressed tasks by their title. PlantUML does not reject an unbound reference — it silently declares a second, zero length task of that name — so every need carrying a type color or a completion value was drawn twice, which, since needs_types entries carry a color by default, is every need in almost every chart. The color and the completion landed on the phantom bar, too, leaving the real one in PlantUML’s default grey: a three need chart rendered as six bars, three of them grey and full length, three of them zero length and correctly colored. Both lines now address the task by its id, so a chart of N needs draws N bars, colored and shaded as configured.🐛 start_date names the month it was given, and a December date no longer ends the build (changed output) (PR #1778)
The date was reformatted through a month name table indexed with the 1-based month number, so the chart started one month later than asked for —
2020-03-25becamethe 25th of April 2020— and any December date raisedIndexError: list index out of range, aborting the build. The generated statement is now the ISO date, which PlantUML also accepts (Project starts 2020-03-25) and which renders the identical chart, and which cannot mis-suffix a date either:2020-01-01used to be writtenthe 01th of February 2020.
Documentation¶
📚 needgantt no longer claims that task elements are linked to their related need when PlantUML’s output format is
svg(PR #1778)No such link has ever been generated; the only link a chart produces is its caption, which points at the generated image file.
📚 The needpie and needbar pages are corrected against what the two directives actually do.
Both claimed that several image files are written per chart, where exactly one is, and both called a literal content value a “float/int”, where only a non-negative integer is read as one. The pages now also say what an invalid value really does — a label,
:explode:or grid-shape mismatch, an unknown color and an unknown style all end the build — and that the rotation options take non-negative integers, that a filter containing a comma needs a custom:separator:, and that:colors:shorter than the data is extended with the default colors rather than repeated.needpiegains the missing:filter_warning:section and states that content and:filter-func:are alternatives;needbarstates that it takes no filter options at all.📚 needs_string_links documents the behaviour it always had: the
,/;splitting and its lack of an escape, that the first entry naming a field wins with no fallthrough, that the pattern is searched rather than anchored, that needs_render_context shadows same-named capture groups, and that the templates are rendered with MiniJinja rather than Jinja2.📚 The needreport and needs_report_template pages are corrected against what the directive actually does.
The “default template” the configuration page printed had drifted so far from the packaged one that copying it — the customisation route both pages recommend — ends the build, because it reads two context variables,
fieldsandjson_exclude_fields, that have never existed. The page now includes the packaged template from the source tree, so the two cannot diverge again, and the context is described as it is: the key isoptions,report_directiveis listed, and every number inusageis called out as permanently0— real counts come from the need_count role that the template emits, and those count need parts and needs_external_needs alike.The
:template:option, until now documented nowhere, gains a section of its own and the three-level precedence it takes part in is written down.needs_report_templateis described as resolved relative to the source directory rather than “must be an absolute path”; thedropdownprerequisite and thereport_directiveescape hatch now also appear on the configuration page; and an.rsttemplate kept inside the source directory is noted as being built as a document of its own, with theexclude_patternsentry that avoids it.📚 The list2need page is corrected against what the directive actually does (PR #1788)
A new Need IDs section replaces the claim that an ID is captured by “the same mechanism as need_part / np”. It is not: the bracketed group is searched for anywhere in the line, runs greedily from the first
(to the last), and accepts a far wider character class — so a title carrying a second parenthetical, as in(REQ-1) The system (as defined) shall work, yields an ID that needs_id_regex then refuses, and a title with a parenthetical but no leading ID has it taken as the ID and deleted from the title. The section also writes down the generated-ID formula — the need type’s prefix followed by theSHA1of the title, cut to needs_id_length — and the consequence that follows from the document not being part of the hash input: the same title at the same level in two documents produces the same ID, and the second need is dropped with a duplicate-ID warning.The list-structure rules are stated rather than left to be discovered: the indentation must be a multiple of two spaces and one level is always exactly two, tabs are expanded before the directive sees them and so cannot be used, and a continuation line that starts in the first column loses its first word. The Set meta-data section replaces “the position of the option-string inside the line is not important” with what the regular expression does — only the first
((...))region is read, it runs greedily from the first((to the last)), so text between two regions is deleted, and an unquoted value such as((status=open))is dropped in silence.The “List with need-ids” example built a need titled
(FEATURE, because the default.delimiter splits(FEATURE.3)before the ID is read; it now uses an ID without a dot, and says why.📚
docs/ubproject.toml, the ubCode configuration of this documentation, is brought up to date with current ubCode releasesIt now mirrors the parts of
conf.pythat ubCode also understands (the|br|substitution, the:pr:/:issue:roles and the intersphinx projects), and drops fiveextend_directivesentries for directives that ubCode now supports natively. Sphinx is unaffected:needs_from_tomlreads only the[needs]table, which is unchanged.
8.3.1¶
- Released:
11.08.2026
- Full Changelog:
This is a patch release with a PlantUML bug fix and a documentation restructuring.
Bug fixes¶
🐛 Generated PlantUML diagrams (needuml, needarch, needflow, needsequence, needgantt) now derive PlantUML’s working directory from the physical path of the source document instead of its logical docname (issue #1749).
Relative
!includepaths therefore also resolve for documents whose source file does not live undersrcdir— e.g. documents contributed by sphinx-mounts — which previously failed with a misleadingWARNING: plantuml command '...' cannot be run. Ordinary documents keep the exact working directory they had before.
Documentation¶
📚 The documentation now uses the shared sphinx-syntax-example
syntax-exampledirective, in place of the bespokeneed-exampledirective that was defined indocs/conf.py. Consequently, thedocsextra now requires Python >= 3.11.
8.3.0¶
- Released:
08.07.2026
- Full Changelog:
Improvements¶
✨ needs_role_need_template is now rendered with Jinja instead of Python’s
str.format(issue #1697, PR #1698)Jinja filters and control structures such as
{% if %}are now supported, and the additional variablesid_complete,id_parent,id_part,is_needandis_partare available (also via aneedobject, e.g.{{ need.type }}). The inline role variant:need:`[[...]] <ID>`is likewise rendered as Jinja.Deprecated since version 8.3.0: The old
str.formatsyntax ({field}placeholders) is deprecated. Templates using it are still rendered withstr.formatand emit aneeds.deprecatedwarning; migrate{field}to{{ field }}(e.g."{title} ({id})"→"{{ title }} ({{ id }})"). Support for the old syntax will be removed in a future release.
8.2.0¶
- Released:
01.07.2026
- Full Changelog:
This release is all about building one documentation source for many
product variants. If you maintain docs that differ by architecture, build
flavour, feature flags or customer edition, the new variant-data tooling lets
you describe those parameters once and let Sphinx-Needs do the branching — in
filters, in need fields, in prose, and in whole sections. The other headline is
network_back schema validation, which finally lets you express link-coverage
rules from the side of the relationship where they actually make sense.
Variant data: describe your build once, reuse it everywhere¶
The centrepiece of 8.2.0 is needs_variant_data — a structured,
namespaced replacement for the old flat needs_filter_data. You define your
variant parameters as ordinary (nestable) data and read them back through a
clean var namespace:
# conf.py
needs_variant_data = {
"cpu": "arm",
"debug": True,
"build": {"optimization": 2, "features": ["feature_a", "feature_b"]},
}
Once configured, the same var data is available in four complementary ways,
so you can pick the right tool for each spot in your docs:
In filters —
var.build.debugreads far more naturally than the old bracket syntax, and nested data avoids clashing with your need field names:.. needtable:: :filter: var.cpu == "arm" and var.build.debug == True
In need field values — inject a variant value straight into a field with the new <{ … }> syntax (for any field flagged
parse_variants):.. req:: Example :id: VD_001 :arch: <{ var.cpu }>
In prose — the new variant role drops a resolved value straight into your text, rendering the configured
cpuvalue asarm.In whole blocks — the new if directive includes or excludes entire sections (needs and all) at parse time, based on a
varexpression:.. if:: var.cpu == "arm" This section — and every need inside it — is only built for ARM.
Variant data can also be loaded from JSON via needs_variant_data_file
and swapped per build with sphinx-build -D needs_variant_data_file=...,
making it easy to generate variant-specific outputs from a single source tree
(PR #1715, PR #1716, PR #1721, PR #1737).
Improvements¶
✨ Add a
network_backschema-validation key, the sibling ofnetwork, that validates a need’s incoming links instead of its outgoing ones. This lets you state a rule from the target’s point of view — for example “every requirement must be covered by at least one test” — once, on the requirement, instead of repeating it on every test. It reuses the familiaritems/contains/minContains/maxContainsstructure and can be freely mixed and nested withnetwork(see Incoming link validation (network_back)) (PR #1731)👌 Allow link fields in needservice directive options, so needs created via a custom service can declare links to other needs (PR #1632). Thanks to @filipepcampos
👌 Honor
-Dcommand-line overrides when loading needs from a TOML file, so per-build configuration works as expected (PR #1717)👌 Include the JSON location (path) in
$refresolution error messages, making schema-configuration mistakes much easier to track down (PR #1736)👌 Track JSON files imported via needimport as build dependencies, so editing an imported file triggers a rebuild (PR #1730). Thanks to @yhontyk
🔧 Add a root
context7.jsonconfiguration file so AI assistants using Context7 can discover the live Sphinx-Needs documentation and use the project-specific reference instead of stale training data (issue #1719)
Deprecations¶
⚠️ Deprecate needs_filter_data in favour of the new, structured needs_variant_data. It keeps working for now but emits a warning; the flat data it provides is injected at the filter root and can collide with need field names, which the namespaced
vardata avoids (PR #1715)
Breaking changes¶
‼️ Remove the discontinued Open-Needs service (PR #1732)
The Open-Needs project is discontinued and
open-needs.orgno longer resolves, so theopen-needsservice has been removed. Thesphinx_needs.services.open_needs.OpenNeedsServiceimport and theparams,prefixandurl_postfixextra fields that the service registered are no longer available.
Bug fixes¶
🐛 Fix
needpieraisingAll wedge sizes are zeroon matplotlib 3.11+ when a pie has no data (e.g. zero matching needs); an empty pie with its legend is now rendered instead (issue #1727)🐛 Sort need link and backlink lists in
needs.jsonand HTML output using natural, case-insensitive ordering (e.g.REQ_2<REQ_9<REQ_10) and collapse duplicate entries, so build outputs are reproducible regardless of need load order (e.g. when using needs_external_needs) (issue #1371)🐛 Fix parent-child relationship of newly created nodes for needs. This fixes interoperability with Sphinx extensions that look up source lines, like sphinxcontrib-spelling (issue #1564). Thanks to @tim-nordell-nimbelink
8.1.1¶
- Released:
20.05.2026
- Full Changelog:
This is a patch release with bug fixes and a minor performance improvement.
Performance¶
⚡️ Add
NeedItem.is_in_document()(PR #1709)Replace direct
need["docname"] == docnamecomparisons with a method onNeedItemandNeedPartItem, encapsulating the document membership logic behind a single access point. Speeds up document purges on projects with many needs.
Bug fixes¶
🐛 Fix
needs_schema_definitionstriggering full rebuilds (issue #1710, PR #1712).resolve_schemas_configmutated the schemas dict in place after Sphinx’sconfig-initedcheckpoint, so the pickled config diverged from the config loaded on the next build — causing Sphinx to detect a spurious change and rebuild every document on every incremental run. The resolved schemas are now stored on the env viaSphinxNeedsDataaccessors, leaving the config object byte-equal across builds.🐛 Fix Docker build by switching PlantUML source to GitHub releases (PR #1708). The Dockerfile hardcoded a Sourceforge mirror that became unreachable, breaking the
Docker-Imageworkflow. The download URL now points at the officialgithub.com/plantuml/plantuml/releases/latest/download/plantuml.jarendpoint.
8.1.0¶
- Released:
20.05.2026
- Full Changelog:
This release focuses on filter performance improvements and bug fixes.
Performance¶
⚡️ Short-circuit simple filter expressions to avoid
eval()overhead (PR #1677)Common filter patterns (e.g.
id == "REQ_001",type == "spec") are now matched and evaluated directly without invoking Python’seval(), significantly reducing filtering time for large need sets.⚡️ Add
NeedItem.filter_context()to avoid costly{**need}unpacking (PR #1706)Filter evaluation no longer creates a full dictionary copy of each need on every filter call, reducing memory allocations and improving throughput.
⚡️ Cache
NeedLinkfilter string (PR #1705)Pre-compute and store the filter string on
NeedLinkconstruction, avoiding repeated string formatting on every access throughNeedItem.__getitem__.
Bug fixes¶
🐛 Fix
needflowrendering very dark / black nodes when a need type has nocolorset inneeds_types(issue #1664, PR #1702). Previously a hard-coded#000000fallback was used as the fill color, which produced unreadable nodes — especially under browser dark mode. When no color is configured, no color is emitted and the diagram engine’s default node color is used.Note
This is a minor behavior change for users with
needs_typesentries that omit thecolorkey: diagrams (needflow,needuml,needgantt) that previously rendered such nodes as solid black will now render them with the diagram engine’s default node color (typically light). To preserve the old appearance, set"color": "#000000"explicitly on the affectedneeds_typesentry.🐛 Fix
:need:role in section headings by registeringNeedRefnode with Sphinx’s LaTeX builder (PR #1700).
8.0.0¶
- Released:
19.03.2026
- Full Changelog:
This release introduces conditional link assessment — the ability to attach
Filter string conditions to links that are checked against the target need at build time.
It also overhauls the internal link representation and fixes links_from_content to
use the parsed doctree instead of fragile regex matching.
Conditional link assessment¶
A major motivation for requirements-management tooling is ensuring traceability —
not just that two needs are linked, but that the link is valid in context.
For example, a specification should only link to requirements that are in an
"open" or "approved" state, or a test should only reference an implementation
at a compatible version.
Sphinx-Needs now supports this via inline conditions on link references (see conditional links). Append a Filter string in square brackets after the target ID:
.. spec:: My Specification
:links: REQ_001[status=="open"], REQ_002[version>=3]
Each condition is evaluated against the target need’s fields.
If a condition evaluates to False, a needs.link_condition_failed warning is emitted;
if the condition syntax is invalid, a needs.link_condition_invalid warning is emitted.
Links without conditions continue to work exactly as before.
The condition is a standard Filter string expression, so you can use any Python-style
comparison operators (==, !=, >, <, >=, <=), membership checks
(in, not in), boolean connectives (and, or, not), and built-in helpers
like search().
This means conditions already work with numeric fields such as integer or number
(decimal) types. For example, if you define a version field:
[needs.fields.version]
schema.type = "integer"
nullable = false
You can then enforce version constraints on links:
.. spec:: My Specification
:links: REQ_001[version>=2]
When the condition contains square brackets (e.g. for list indexing), use multiple opening
brackets — the parser matches N opening [ with N closing ]:
REQ_001[[tags[0]=="important"]].
✨ Add conditional need link assessment (PR #1675)
♻️ Add
_split_link_listparser with condition syntax support (PR #1674)👌 Parse link conditions from imported and external needs (PR #1680)
👌 Add needs_json_include_link_conditions config option (PR #1681)
Controls whether conditions are included in
needs.jsonoutput (default:True). Backlink fields are never affected.👌 Add
parse_conditionsconfiguration for link types (PR #1684)Per-link-type control over whether
[condition]brackets are parsed. Setparse_conditions = falseon a link type to treat brackets as literal ID text.[needs.links.raw_links] parse_conditions = false
Note
Potential future directions:
Hash-based checks: combined with a
hashfield and a dynamic function that computes a content hash, conditions likeREQ_001[hash=="abc123"]could detect when a linked need’s content has changed since the link was authored.Semantic version comparisons: a dedicated semver field type would enable conditions like
REQ_001[version~=">=1.2.0"]with proper semver semantics.Terse constraint syntax: a more compact notation (e.g.
REQ_001[s=open,v>=2]with field shorthands) is under consideration for common cases, but would complement — not replace — the current filter-string syntax.
links_from_content rewrite¶
The links_from_content dynamic function previously used a regex to
extract :need:`ID` references from raw RST source text.
This was fragile and could not handle custom titles (e.g. :need:`My Title <REQ_001>`),
nested content, or other edge cases.
It now walks the parsed doctree for the source need, collecting NeedRef nodes
directly. This is more robust and correctly handles all role syntax variants.
Limitations: links_from_content requires a stored doctree node.
It will emit a warning and return an empty list for:
External needs (loaded via
needimport/needs_external_needs) — they have no doctree.Need parts — not supported; a warning is emitted.
♻️ Fix
links_from_contentto use parsed doctree nodes instead of regex (PR #1685)
Breaking changes¶
‼️
ENV_DATA_VERSIONbumped to 4 (PR #1683)The internal format for storing link data in the Sphinx build environment has changed (links are now stored as structured
NeedLinkobjects instead of plain strings). Incremental builds from a previous version will trigger a full rebuild automatically.‼️
need["links"](and other link fields) now returns a freshlist[str]copy rather than a reference to the internal storage (PR #1670)Previously, code like
need["links"].append("NEW_ID")would mutate the internal list. This now silently has no effect — the returned list is a projection from the internalNeedLinkrepresentation. This should only affect exotic use cases such as dynamic functions or custom extensions that mutate link lists via__getitem__access. Use theNeedItemAPI (e.g.get_links(as_str=False)) for direct access to the internalNeedLinkobjects.
Internal changes¶
These changes do not affect user-facing behaviour but improve link handling internals:
♻️ Introduce
NeedLinkstructured internal representation for links (PR #1670)♻️ Store
NeedLinkinstead ofstrinLinksLiteralValueandLinksFunctionArray(PR #1673)🔧 Use
NeedLinkdirectly inupdate_back_linksfunction (PR #1672)🔧 Store
NeedPartData.backlinksasNeedLinkinstead ofstr(PR #1679)🔧 Use
get_links(as_str=False)in needextend to avoid round-trip serialization (PR #1678)♻️ Store
NeedLinkonNeedRefnode at parse time instead of re-parsing later (PR #1682)🧪 Add tests for variants in links (PR #1669)
Bug fixes¶
🐛 Fix linkcheck CI job warnings (PR #1667)
Documentation¶
📚 Add sphinx-ai-index to Sphinx docs builder (PR #1671)
7.0.0¶
- Released:
24.02.2026
- Full Changelog:
This is a major release that consolidates field, link, and default configuration into a single, composable schema system — inspired by SysML2. See the extensible schema proposal for the full design rationale.
This release completes the first two phases of the proposal:
migrating fields (needs_extra_options → needs_fields) and
links (needs_extra_links → needs_links).
The next potential phase is per-type schemas with type inheritance,
allowing individual need types to specialize fields and links
(see discussion comment
for the implementation plan).
All deprecated configuration options continue to work in this release but emit warnings. We recommend migrating to the new options as soon as possible; deprecated options will be removed in a future major release.
Consolidated field & link configuration¶
The core theme of this release is moving from many scattered configuration options to a unified per-field / per-link definition. This makes the configuration more explicit, easier to understand, and lays the groundwork for future per-type schemas.
✨ Add needs_fields configuration, deprecate
needs_extra_options(PR #1611)The new needs_fields is a dictionary mapping field names to their full configuration. It replaces the flat list
needs_extra_optionsand also allows specializing core fields (e.g.status,tags) by narrowing their type constraints (following the Liskov substitution principle).Before (deprecated)¶needs_extra_options = ["priority", "verified"]
After¶[needs.fields.priority] description = "Priority level" schema.type = "integer" schema.minimum = 1 schema.maximum = 5 [needs.fields.verified] schema.type = "boolean"
⚠️ Migrate
needs_extra_linksto needs_links (PR #1649)The new needs_links uses the same dict-based pattern as needs_fields, replacing the list-based
needs_extra_links. The redundantoptionkey is no longer needed.Before (deprecated)¶[[needs.extra_links]] option = "blocks" incoming = "is blocked by"
After¶[needs.links.blocks] incoming = "is blocked by"
✨ Add
defaultandpredicateskeys to needs_fields and needs_links, deprecateneeds_global_options(PR #1612)Field defaults and conditional (predicate-based) defaults can now be set directly on each field or link, replacing the separate
needs_global_optionsconfiguration.Before (deprecated)¶[needs.global_options.status] default = "draft" predicates = [['status == "open"', "active"]]
After¶[needs.fields.status] default = "draft" predicates = [['status == "open"', "active"]]
✨ Add
nullablekey to needs_fields items (PR #1613)Individual fields can now declare whether
null(None) is a valid value.✨ Add
parse_variantsto needs_fields / needs_links, deprecateneeds_variant_options(PR #1614)Variant parsing is now enabled per-field/link instead of via a separate global list.
Before (deprecated)¶needs_variant_options = ["author", "status"]
After¶[needs.fields.author] parse_variants = true [needs.fields.status] parse_variants = true
♻️ Move
needs_statusesandneeds_tagschecking to schema validation (PR #1605)needs_statusesandneeds_tagsare now deprecated. Use schemaenumconstraints on thestatusandtagsfields instead:Before (deprecated)¶needs_statuses = [{name = "draft"}, {name = "approved"}] needs_tags = [{name = "security"}, {name = "usability"}]
After¶[needs.fields.status] schema.enum = ["draft", "approved"] [needs.fields.tags] schema.items.enum = ["security", "usability"]
API changes¶
✨ Add
add_fieldAPI; deprecateadd_extra_option(PR #1641)Extensions that programmatically add fields should migrate from
add_extra_option()to the newadd_field(), which accepts the same schema, default, and predicate options as needs_fields.👌 Allow
add_fieldAPI to set defaults/predicates (PR #1643)
Breaking changes¶
‼️
needs_fieldsandadd_fielddefault to nullable with no default (PR #1645)When defining a field via needs_fields or
add_fieldwithout an explicitschema, the field now defaults tonullable=Truewith no default value (i.e.null).Previously, fields without an explicit schema defaulted to
nullable=Falsewith a default of""(empty string). This was a legacy of the untypedneeds_extra_optionsera and caused confusion when users expected unset fields to benullrather than an empty string.The old
needs_extra_options/add_extra_optionAPIs retain their legacy behaviour, so only users who have already migrated toneeds_fields/add_fieldare affected.To restore the old behaviour explicitly:
[needs.fields.my_field] nullable = false default = ""
‼️ Need fields added by services default to nullable and null (PR #1644)
Fields registered by built-in services (e.g. GitHub) now default to nullable with no default, matching the new
needs_fieldsconvention.⚠️ Separate reduced vs full need representation for schema validation (PR #1652)
Schema validation now distinguishes between a reduced need representation (for type-specific
local/networkschemas, where default-valued and empty fields are stripped) and a full representation (for global field/link constraints).Previously, fields with default
[]values (link fields,tags) were stripped before validation, silently bypassing constraints likeminItems,contains, andminContains. These fields are now retained as[]in global constraint validation, so such constraints will now correctly trigger on needs that have empty link/tag lists.♻️ Replace
jinja2withminijinjafor template rendering (PR #1659)The
jinja2dependency has been replaced byminijinja(minijinja-py), a lightweight, Rust-based Jinja2-compatible template engine. This provides faster template rendering and a smaller dependency footprint.Standard Jinja2 syntax is fully supported — most custom templates will work without changes. Notable differences:
Nonerenders as"none"(lowercase) instead of"None". Use{% if field %}{{ field }}{% endif %}to guard againstNoneoutput.A few Jinja2-only filters are not available:
wordcount,center,urlize,xmlattr,forceescape. See theminijinjadocumentation for alternatives.
Compatibility changes¶
⬆️ Support Sphinx 9 and Docutils 0.22 (PR #1653)
Sphinx-Needs now supports Sphinx 7.4 through 9.x and Docutils 0.22.
Bug fixes¶
Improvements¶
Internal changes¶
These changes do not affect user-facing behaviour but improve the codebase:
♻️ Migrate use of
extra_linksto Schema-Based Access (PR #1638)🔧 Refactor schema validation: separate select filtering from local validation (PR #1655)
🔧 Simplify field/link validation (PR #1654)
🔧 Simplify
generate_needsfunction (PR #1651)🔧 Rename “option” to “field” internally (PR #1642)
🔧 Refactor
populate_field_typeto use type-directed schema walking (PR #1639)🔧 Store full schema on
FieldSchema(PR #1603)🔧 Add
validate_extra_option_schema(PR #1602)🔧 Remove use of
extra_optionsafter config resolution (PR #1607)🔧 Move link
schematoLinkSchema(PR #1617)🔧 Simplify
import_prefix_link_edit(PR #1615)🔧 Add
AGENTS.md(PR #1621)🧪 Add tests for
create_inherited_field(PR #1636)
Documentation fixes¶
6.3.0¶
- Released:
15.12.2025
- Full Changelog:
⬆️ Support Python 3.14 (PR #1598)
♻️ Remove
typeguarddependency (PR #1597)👌 Relative paths from toml configuration (PR #1589)
Ensure that file paths originating from a needs_from_toml file are relative to that file, rather than the
conf.pyfile✨ Add new
needs_linksconfiguration (dict-based) as replacement forneeds_extra_links(list-based)The new needs_links configuration uses a dictionary mapping link name to configuration, removing the redundant
optionkey required in needs_extra_links. Also adds support for adescriptionfield for link types. The oldneeds_extra_linksconfiguration is now deprecated but remains supported for backward compatibility.✨ Expose
parse_dynamic_functionsin field and link configurationAdd per-field/link
parse_dynamic_functionsoption to needs_fields, needs_links, and theadd_field/add_extra_optionAPI functions. Also add a new needs_parse_dynamic_functions global config option (defaultTrue) that sets the default for all extra fields and links when not explicitly set per-field/link. This provides a migration path to eventually disable dynamic function parsing by default in a future major release.
6.2.0¶
- Released:
28.11.2025
- Full Changelog:
This release introduces performance improvements for schema validation, to make it ~3 times faster (PR #1581, PR #1582, PR #1583, PR #1584).
This includes a change in dependencies, from jsonschema to jsonschema-rs for the core validation engine.
6.1.1¶
- Released:
25.11.2025
- Full Changelog:
This release focuses on schema validation improvements and bug fixes.
✨ Add
needs_schema_validation_enabledconfiguration (PR #1574)New configuration option to disable schema validation entirely. This is set to
Trueby default, for backward compatibility, and provides an opt-out mechanism when schema validation is not needed.See needs_schema_validation_enabled for more information.
✨ Add
allow_type_coercionconfiguration for external/importneeds.jsonreads (PR #1573)New configuration option for
needs_external_needsand theneedimportdirective that controls whether field values should be automatically coerced to expected types. For example, enables/disables parsing comma-separated strings like"a,b,c"into list types like["a", "b", "c"]. Set toTrueby default for backward compatibility. Setting toFalsemay improve performance by skipping additional parsing.See needs_external_needs and needimport for more information.
👌 Allow
\.in schema regex patterns (PR #1568)The regex pattern
\.is now allowed in schema validations.🐛 Fix schema network type injection (PR #1570)
Fixed type injection mechanism that was failing for link types called
containsoritems. Constrained the injection to specific schema path structure locations.🐛 Fix
needs.jsonschema for nullable fields (PR #1571)Nullable fields now correctly reflect that property in the
needs.jsonschemas section.
6.1.0¶
- Released:
31.10.2025
- Full Changelog:
Main focus of this release is the improvement of the schema severity handling.
👌 Improve schema severity handling (PR #1561)
The PR removes the setting
needs_schema_severity.All violations are printed to the console unless suppressed by
suppress_warnings. To enable granular warning suppression, the following warning types were added:info: sn_schema_info
warning: sn_schema_warning
violation: sn_schema_violation
The severities
infoandwarningare logged aslogger.warning(). The severityviolationis logged aslogger.error()so they appear as a different color in the output.The
schema_violations.jsonfile contains all violations, irrespective of the severity. Any downstream tool can filter for the required severity levels.In
schema_violations.json, child elements do not containlog_lvlandtypeanymore to avoid duplication.👌 Make
incoming/outgoingkeys optional inneeds_extra_links(PR #1548)Defining a link is now possible with just
needs_extra_links = [{"option": "links"}].🔧 Run new ubc action on docs (PR #1541)
A new GitHub action to run
ubcis now used to lint all RST sources in the CI. Next step is to create a pre-commit hook for local usage.
Minor documentation updates and internal improvements:
📚 Co-locate dynamic and variant function docs (PR #1544)
📚 Fix linkchecks (PR #1556)
📚 Improve schema docs (PR #1554)
📚 Enable link to full schema example (PR #1538)
♻ Early resolution of schema_debug_path (PR #1563)
🔧 Derive core
FieldSchemafromNeedsCoreFields(PR #1546)🧪 Add snapshot test for field schema (PR #1545)
6.0.1¶
- Released:
02.10.2025
- Full Changelog:
This release contains bug fixes for the 6.0.0 schema validation system and some minor improvements.
👌 Add schema to add_extra_option PR #1527
Added
schemaparameter toadd_extra_optionAPI to support typed fields in extensions that add extra options programmatically.🐛 Inject build_tags to variant filter strings PR #1531
Introduced a new context variable
build_tagsinto variant filter strings that contains all defined Sphinx build tags to be used as variant selector. The new variable can be used like this:'tag1' in build_tags. This also avoids polluting the variable namespace with tags.🐛 Fix name error schema_path_contains PR #1530
Fixed bug when using
containsvalidation on empty link lists.🔧 Fix schema json missing exc message PR #1526
🔧 Improve error for variant options PR #1524
Better error messages when variant options are incorrectly set to link types.
📚 Add release labels to changelog PR #1523
Added stable release labels to changelog for better URL references.
6.0.0¶
- Released:
28.09.2025
- Full Changelog:
This release introduces strong typing for extra option fields to the Sphinx-Needs codebase. This affects needs read from RST sources (or others like .md), but also imported/exported needs of needs.json files.
The default type for extra options is still string, so existing configuration should work
as before. Type errors are detected early once each need is fully resolved, i.e. after
reading in the sources and evaluating needs_global_options (defaults),
needextend, variants and Dynamic functions.
Errors in the typing system lead to needs not being created.
The release also introduces a new Schema validation system that integrates into the strong typing. It is JSON schema compliant in large parts with custom extensions to support network validation.
The core of Sphinx-Needs had to be refactored in large parts to enable these changes. The following are the main user-facing changes:
♻️ Allow for typed
needs_extra_optionsfields PR #1516The
needs_extra_optionsconfiguration option was extended to support schema information. The fieldschema.typeglobally sets the type for the field. Users can select betweenstring,number(float),integer,booleanandarray. For thearraytype another keywordschema.items.typedefines the list items type.Examples in TOML configuration:
[[needs.extra_options]] name = "priority" description = "Priority level, 1-5 where 1 is highest and 5 is lowest" schema.type = "integer" schema.minimum = 1 schema.maximum = 5 [[needs.extra_options]] name = "asil" description = "Automotive Safety Integrity Level" schema.type = "string" schema.enum = ["QM", "A", "B", "C", "D"]
Key Changes:
Strong typing for
needs_extra_optionswith JSON schema validationDelayed resolution for dynamic functions, needextend, defaults, and variants
Automatic type coercion from string inputs (directive options) to proper types
Missing fields are set to
None(null in JSON)needs.json import/export with type validation and coercion; empty
""field values of existing needs.json files of typeintegerare coerced to0, and for typenumberto0.0for backwards compatibility. Empty strings forbooleanfields are coerced toTrueas this is often used as a flag.Integration with schema validation system. The same fields for Supported data types and constraints can be set in the definition, so they are set globally for that field.
The implementation strives to be as backwards compatible as possible. See below for details.
✨ Schema validation PR #1467
The PR adds a fast, declarative and versatile JSON schema based need validation. The schema is defined in the needs_schema_definitions configuration option or as JSON format passed via needs_schema_definitions_from_json.
Key Features:
JSON Schema standard compliance using
$defsand$reffor reusable sub-schemasFully typed implementation with runtime validation of schema definitions
Auto-injection of default string type when not specified
Select mechanism, comparable to database queries to select need nodes for validation.
Root
validatekey withlocalandnetworksub-sections for validation types. The split enables IDE extensions such as ubCode to validate-on-type for need-local changes and also run network validation once the index is fully built.Debug mechanism using needs_schema_debug_active to check why validations pass or fail. 4 files are written per validation: original need, reduced need, applied schema and a result file with user and validation message. File naming pattern is
<need_id>__<schema_path>__<validation_rule>.<json|txt>. Nested graph-validations are also dumped.String regex pattern constraints with cross-engine compatibility
Semantic equivalence to JSON Schema spec for array
items,minItems,maxItems,contains,minContains, andmaxContains
The new validation can replace needs_warnings, needs_constraints, needs_id_regex, needs_statuses, and needs_tags in the future.
The implementation of the new strong typing and schema validation into ubCode is on the immediate roadmap.
👌 Write schema violations into a JSON file PR #1503
Schema validation violations are now exported to a JSON file (
schema_violations.json) for external tooling integration and automated quality assurance workflows. This enables CI/CD systems and external analysis tools to programmatically process validation results.Always generate schema violations.json report file PR #1511
These PRs were part of the internal changes:
🧪 Move to snapshot testing for test_schema PR #1519
🔧 Add
VariantFunctionParseddataclass PR #1515🔧 Add
DynamicFunctionParseddataclass PR #1514♻️ Auto-compute certain need fields PR #1496
♻️ Set some core need fields to nullable PR #1488
🔧 Split import item filtering to separate function PR #1484
♻️ Lazily assess directive options PR #1482
🧪 Improve test for need parts PR #1507
👌 Improve need part processing PR #1469
🔧 Centralise allowed variant core need fields PR #1424
✨ Add
is_importneed field PR #1429New field to identify needs that were imported from external sources.
Breaking Changes
Variants have to be wrapped with
<< >>. This allows for a safer parsing strategy and support for usage in array elements.The variant delimiter has changed to only allow
,. Formerly also;was possible.🐛 Fix: disallow need variants for list type fields PR #1489
Variants no longer supported in list-type fields due to parsing instability. This feature might be re-introduced in future. The new syntax
<< >>would make this much easier.‼️ remove parsing of deprecated
needs_global_optionsformat PR #1517Removes support for the deprecated legacy format of
needs_global_options. The system now only accepts the dictionary format introduced in version 5.1.0. Projects using the old format will receive a warning that the configuration is not adictand the parsing will be skipped entirely. Users must migrate to the new explicit format for global options to continue working.‼️ Improve needs default field application (via needs_global_options) PR #1478
Previously defaults would be applied to any fields of a need with a “falsy” value, e.g.
None,False,0,"",[]. This is an issue if the user wants to specifically set fields to these values, without them being overridden by defaults. Therefore, now defaults are only applied to fields with a missing or None value.‼️ Disallow
add_extra_optionoverriding an internal field PR #1477Needs are stored in a flat dictionary as of now, so they cannot overlap.
♻️ Store needs as
NeedItem/NeedPartItem, rather than standarddictPR #1485Replaces standard dictionary storage with specialized
NeedItemandNeedPartItemclasses. This allows better encapsulation and control over data mutation.This is breaking for any users doing “non-API” modifications or additions to the needs data, i.e. directly adding dict items. It should not change interactions with standard APIs like
add_needor filter strings.These PRs are also related:
♻️ Improve storage of part data on NeedItem PR #1509
🔧 Improve storage of content generation on
NeedItemPR #1506🔧 Improve storage of constraint results on
NeedItemPR #1504👌 Capture more information about modifications on
NeedItemPR #1502♻️ split off
sourcefields inNeedIteminternal data PR #1491♻️ split
NeedIteminternal data into core, extras, links and backlinks PR #1490
⬆️ Drop Python 3.9 PR #1468
⬆️ Drop Sphinx<7.4, test against Python 3.13 PR #1447
Further improvements and fixes
🔧 Improve plantuml check + add tests PR #1521
PlantUML extension detection now uses
app.extensionsfor better compatibility with dynamic registration. Thanks to @AlexanderLanin for the initial implementation.♻️ Warn for missing needimport files PR #1510
Missing needimport files now emit warnings instead of throwing exceptions, making it possible to ignore the problem for specific use cases.
🐛 Avoid leaking auth credentials for ext. need warnings PR #1512
♻️ Exclude
is_need/is_partfromneeds.jsonoutput PR #1505It doesn’t make sense to have these, since only needs are written, not parts. Also, these fields are “thrown away” when passing in external/import needs.json.
These fields are only really used during processing, within filter contexts, when filtering across both needs and parts.
👌 Reset directive option specs at start of build PR #1448
Internal fix to reset directive options for consistent builds & testing.
🐛 Warn on dynamic function with surrounding text PR #1426
Added warning when dynamic functions are used for a list type with surrounding text as the surrounding text will be silently ignored.
Allow
collapseandhideinneeds_global_optionsPR #1456🔧 Allow template global_options PR #1454
👌 Re-allow dynamic functions for
layoutfield PR #1423🔧 Allow pre/post template
global_optionsPR #1428
Minor documentation updates
📚 Clarify c.this_doc() for needextend PR #1475
📚 Fix needs_extra_links name PR #1501
📚 Format configuration.rst PR #1473
📚 Fix escape sequences PR #1470
Infrastructure
5.1.0¶
- Released:
06.03.2025
- Full Changelog:
The needs_global_options configuration option has been updated to a new format, to be more explicit and to allow for future improvements PR #1413. The old format is currently still supported, but will emit a warning. Additionally, checks are put in place to ensure that the keys used are from the allowed set (PR #1410).:
any
needs_extra_optionsfieldany
needs_extra_linksfieldstatuslayoutstyletagsconstraints
needs_global_options = {
"field1": "a",
"field2": ("a", 'status == "done"'),
"field3": ("a", 'status == "done"', "b"),
"field4": [
("a", 'status == "done"'),
("b", 'status == "ongoing"'),
("c", 'status == "other"', "d"),
],
}
needs_global_options = {
"field1": {"default": "a"},
"field2": {"predicates": [('status == "done"', "a")]},
"field3": {
"predicates": [('status == "done"', "a")],
"default": "b",
},
"field4": {
"predicates": [
('status == "done"', "a"),
('status == "ongoing"', "b"),
('status == "other"', "c"),
],
"default": "d",
},
}
5.0.0¶
- Released:
18.02.2025
- Full Changelog:
This release includes a number of changes, to bring more clarity to the needs data structure and post-processing steps. In most cases it should not be breaking, but may be in some corner cases.
✨ Add
c.this_doc()check for use in directive:filter:option PR #1393 and PR #1405This allows for filtering of needs only in the same document as the directive itself, e.g.
.. needextend:: c.this_doc() and status is None :status: open
This works for all common filtered directives, see Filtering for needs on the current page
♻️ Remove
full_titleneed field and only trim generated titles PR #1407The existence of both
titleandfull_titleis confusing and unnecessary (in most cases these are equal), and sofull_titleis removed.Trimming (when needs_max_title_length is set) is now only applied to auto-generated titles, as per the documentation in needs_title_from_content
♻️ Make
needextendargument declarative PR #1391The argument for
needextendcan refer to either a single need ID or filter function. Currently, the format cannot be known until all needs have been processed, and it is resolved during post-processing. This is problematic for (a) user readability, (b) improving processing performance and issue feedbackThis PR slightly modifies the argument processing to allow for two “explicit” formats:
<ID>, if the argument is enclosed in<>it is always processed as a single ID"filter string", if the argument is enclosed in""it is always processed as a filter string
See needextend for more information.
♻️ Remove back link manipulation from
needextendPR #1386Back links are computed at the end of the need post-processing, after
needextendhave been applied.Back links should always be in-sync with forward links, therefore it doesn’t make sense to modify back links in this way.
♻️ Do not process dynamic functions on internal need fields PR #1387 and PR #1406
For most “internal” need fields it does not make sense that these would be dynamic, and anyway this would fail since their values are not string types.
Dynamic function processing is now skipped, for core fields that should not be altered by the user. The following fields are allowed to contain dynamic functions:
statustagsstyleconstraintsall
needs_extra_optionsall
needs_extra_linksall
needs_global_options
♻️ Remove
deletefrom internal needs andneeds.jsonPR #1347The
:delete:option on a need directive deletes a need before creating/storing it, therefore it is impossible for it to be anything other thanFalse. Storing the field on a need is misleading, because it suggests that the need will be deleted, which is not possible with the current sphinx-needs logic.👌 Add type warnings of extra options in external/import reads PR #1389
Currently, the value of all extra options is expected to be a string; other types are not supported in various aspects of sphinx-needs (such as
needextend, dynamic functions and filtering), and in-fact are already silently converted to strings during the reads.The warnings
needs.mistyped_external_valuesandneeds.mistyped_import_valuesare added for non-string values, forneeds_external_needsandneedimportsources respectively.🔧 Synchronize list splitting behaviour in
needandneedextenddirectives PR #1385
4.2.0¶
- Released:
07.01.2025
- Full Changelog:
⬆️ Drop Python 3.8 and Sphinx 6
✨ Add needs_import_keys configuration PR #1379
👌 Allow
filter-funcinneedpieto have multiple dots in the import path PR #1350🐛 Make external paths relative to
confdir, notsrcdirPR #1378🔧 Release needs data mutation lock at end of process PR #1359
🔧 Add
linenoto default output ofneeds.jsonPR #1346
4.1.0¶
- Released:
28.10.2024
- Full Changelog:
New¶
✨ Add
needs_from_tomlconfiguration PR #1337Configuration can now be loaded from a TOML file, using the
needs_from_tomlconfiguration option. See needs_from_toml for more information.✨ Allow configuring description of extra options in
needs_extra_optionsPR #1338The
needs_extra_optionsconfiguration option now supports dict items with anameanddescriptionkey, See needs_extra_options for more information.
Fixes¶
🐛 Fix clickable links to needs in
needflow, when using thegraphvizengine PR #1339🐛 Allow sphinx-needs to run without
sphinxcontrib.plantumlinstalled PR #1328🔧 Remove some internal fields from needs layout PR #1330
🔧 Merge defaults into user-defined configuration earlier (to avoid sphinx warnings) PR #1341
4.0.0¶
- Released:
09.10.2024
- Full Changelog:
Breaking Changes¶
This commit contains a number of breaking changes:
Improvements to filtering at scale¶
For large projects, the filtering of needs in analytical directives such as needtable, needuml, etc, can be slow due to
requiring an O(N) scan of all needs to determine which to include.
To address this, the storage of needs has been refactored to allow for pre-indexing of common need keys, such as id, status, tags, etc, after the read/collection phase.
Filter strings such as id == "my_id" are then pre-processed to take advantage of these indexes and allow for O(1) filtering of needs, see the Filter string performance section for more information.
This change has required changes to the internal API and stricter control on the access to and modification of need data, which may affect custom extensions that modified needs data directly:
Access to internal data from the Sphinx
envobject has been made privateNeeds data during the write phase is exposed with either the read-only
NeedsVieworNeedsAndPartsListView, depending on the context.Access to needs data, during the write phase, can now be achieved via
get_needs_view()Access to mutable needs should generally be avoided outside of the formal means, but for back-compatibility the following Sphinx event callbacks are now available:
needs-before-post-processing: callbacksfunc(app, needs)are called just before the needs are post-processed (e.g. processing dynamic functions and back links)needs-before-sealing: callbacksfunc(app, needs)just after post-processing, and before the needs are changed to read-only
Additionally, to identify any long running filters, the needs_uml_process_max_time, needs_filter_max_time and needs_debug_filters configuration options have been added.
Key changes were made in:
♻️ Replace need dicts/lists with views (with fast filtering) in PR #1281
🔧 split
filter_needsfunc by needs type in PR #1276🔧 Make direct access to
envattributes private in PR #1310👌 Move sorting to end of
process_filtersin PR #1257🔧 Improve
process_filtersfunction in PR #1256🔧 Improve internal API for needs access in PR #1255
👌 Add
needs_uml_process_max_timeconfiguration in PR #1314♻️ Add
needs_filter_max_time/needs_debug_filters, deprecateexport_idin PR #1309
Improved warnings¶
sphinx-needs is designed to be durable and only except when absolutely necessary. Any non-fatal issues during the build are logged as Sphinx warnings. The warnings types have been improved and stabilised to provide more information and context, see Build Warnings for more information.
Additionally, the add_need() function will now only raise the singular exception InvalidNeedException for all need creation issues.
Key changes were made in:
Improved needs.json¶
A number of output need fields have been changed, to simplify the output. Key changes were made in:
Replacement of [[...]] and need_func in need content¶
The parsing of the [[...]] dynamic function syntax in need content could cause confusion and unexpected behaviour.
This has been deprecated in favour of the new, more explicit ndf role, which also deprecates the need_func role.
Removed deprecation¶
The deprecated needfilter directive is now removed (PR #1308)
New and improved features¶
✨ add
tagsoption forlist2needdirective in PR #1296✨ Add
idsoption forneedimportin PR #1292👌 Allow
refinneedumlto handle need parts in PR #1222👌 Improve parsing of need option lists with dynamic functions in PR #1272
👌 Improve warning for needextract incompatibility with external needs in PR #1325
🔧 Set
env_versionfor sphinx extension in PR #1313
Bug Fixes¶
🐛 Fix removal of
Needextendnodes in PR #1298🐛 Fix
usagenumbers inneedreportin PR #1285🐛 Fix
parent_needpropagation from external/imported needs in PR #1286🐛 Fix
need_partwith multi-line content in PR #1284🐛 Fix dynamic functions in
needextractneed in PR #1273🐛 Disallow dynamic functions
[[..]]in literal content in PR #1263🐛 fix parts defined in nested needs in PR #1265
🐛 Handle malformed
filter-funcoption value in PR #1254🐛 Pass
needstohighlightfilter ofgraphvizneedflowin PR #1274🐛 Fix parts title for
needflowwithgraphvizengine in PR #1280🐛 Fix
need_countdivision by 0 in PR #1324
3.0.0¶
- Released:
28.08.2024
- Full Changelog:
This release includes a number of new features and improvements, as well as some bug fixes.
Updated dependencies¶
sphinx:
>=5.0,<8to>=6.0,<9requests:
^2.25.1to^2.32requests-file:
^1.5.1to^2.1sphinx-data-viewer:
^0.1.1to^0.1.5
Documentation and CSS styling¶
The documentation theme has been completely updated, and a tutorial added.
To improve sphinx-needs compatibility across different Sphinx HTML themes,
the CSS for needs etc has been modified substantially, and so,
if you have custom CSS for your needs, you may need to update it.
See HTML Theme support for more information on how to setup CSS for different themes, and PR #1178, PR #1181, PR #1182 and PR #1184 for the changes.
needflow improvements¶
The use of Graphviz as the underlying engine for needflow diagrams, in addition to the default PlantUML,
is now allowed via the global needs_flow_engine configuration option, or the per-diagram engine option.
The intention being to simplify and improve performance of graph builds, since plantuml has issues with JVM initialisation times and reliance on a third-party sphinx extension.
See needflow for more information, and PR #1235 for the changes.
additional improvements:
needs.json improvements¶
A needs_schema is now included in the needs.json file (per version), which is a JSON schema for the data structure of a single need.
This includes defaults for each field, and can be used in combination with the needs_json_remove_defaults configuration option to remove these defaults from each individual need.
Together with the new automatic minifying of the needs.json file, this can reduce the file size by down to 1/8th of its previous size.
The needs_json_exclude_fields configuration option can also be used to modify the excluded need fields from the needs.json file,
and backlinks are now included in the needs.json file by default.
See Format for more information, and PR #1230, PR #1232, PR #1233 for the changes.
Additionally, the content_node, content_id fields are removed from the internal need data structure (see PR #1241 and PR #1242).
Additional improvements¶
👌 Capture filter processing times when using
needs_debug_measurement=Truein PR #1240👌 Allow
styleandcolorfields to be omitted forneeds_typesitems and a default used in PR #1185👌 Allow
collapse/delete/jinja_contentdirective options to be flags in PR #1188👌 Improve
need-extend; allow dynamic functions in lists in PR #1076👌 Add collapse button to
clean_xxxlayouts in PR #1187🐛 fix warnings for duplicate needs in parallel builds in PR #1223
🐛 Fix rendering of
needextractneeds and use warnings instead of exceptions in PR #1243 and PR #1249
2.1.0¶
- Released:
08.05.2024
- Full Changelog:
Improvements¶
👌 Default to warning for missing
needextendID in PR #1066👌 Make
needtabletitles more permissive in PR #1102👌 Add
filter_warningdirective option, to replace default warning text in PR #1093👌 Improve and test github
needservicedirective in PR #1113👌 Improve warnings for invalid filters (add source location and subtype) in PR #1128
👌 Exclude external needs from
needs_id_regexcheck in PR #1108👌 Fail and emit warning on filters that do not return a boolean result in PR #964
👌 Improve
Neednode creation and content parsing in PR #1168👌 Add loading message to
permalink.htmlin PR #1081👌 Remove hard-coding of
completionanddurationneed fields in PR #1127
Bug fixes¶
Internal improvements¶
🔧 Use future annotations in all modules in PR #1111
🔧 Replace black/isort/pyupgrade/flake8 with ruff in PR #1080
🔧 Add better typing for
extra_linksconfig variable in PR #1131🔧 Centralise need parts creation and strongly type needs in PR #1129
🔧 Fix typing of need docname/lineno in PR #1134
🔧 Type
ExternalSourceconfig dict in PR #1115🔧 Enforce type checking in
needuml.pyin PR #1116🔧 Enforce type checking in
api/need.pyin PR #1117🔧 Add better typing for
global_optionsconfig variable in PR #1120🔧 Move dead link need fields to internals in PR #1119
🔧 Remove usage of
hide_statusandhide_tagsin PR #1130🔧 Remove
hiddenfield fromextra_optionsin PR #1124🔧 Remove
constraintsfromextra_optionsin PR #1123🔧 Remove use of deprecated
needs_extra_optionsasdictin PR #1126
2.0.0¶
- Released:
13.11.2023
- Full Changelog:
This release is focussed on improving the internal code-base and its build time performance, as well as improved build warnings and other functionality improvements / fixes.
Changed¶
Add Sphinx 7 support and drop Python 3.7 (PR #1056). Sphinx 5, 6, 7 and Python 3.8 to 3.11 are now fully supported and tested.
The
matplotlibdependency (forneedbarandneedpieplots) is now optional, and should be installed withsphinx-needs[plotting], see Installation (PR #1061)The
NeedsBuilderformat name is changed toneeds(PR #978)
New¶
Added Builder needs_id and config option needs_build_json_per_id in
conf.py(PR #960)Added
needs_reproducible_jsonconfig option for the needs builder, see needs_build_json (PR #1065)Added error messages for constraint failures (PR #1036)
Improved¶
Performance:
General performance improvement (up to 50%) and less memory consumption (~40%).
external_needsnow uses cached templates to save generation time.Improved performance for needextend with single needs.
Improved performance by memoizing the inline parse in
build_need(PR #968)Remove
deepcopyof needs data (PR #1033)Optimize
needextendfilter_needs usage (PR #1030)Improve performance of needs builders by skipping document post-transforms (PR #1054)
Other:
Improve sphinx warnings (PR #975, PR #982) All warnings are now suffixed with
[needs], and can be suppressed (see suppress_warnings)Improve logging for static file copies (PR #992)
Improve removal of hidden need nodes (PR #1013)
Improve
process_constraintsfunction (PR #1015)Allow
needextenddirective to use dynamic functions (PR #1052)Remove some unnecessary keys from output
needs.json(PR #1053)
Fixed¶
Fix gantt chart rendering (PR #984)
Fix
execute_func(PR #994)Fix adding sections to hidden needs (PR #995)
Fix
NeedImportlogic (PR #1006)Fix creation of need title nodes (PR #1008)
Fix logic for
process_needextendfunction (PR #1037)Fix usage of reST syntax in prefix parameter of meta (PR #1046)
Internal¶
🔧 Centralise access to sphinx-needs config to
NeedsSphinxConfig(PR #998)🔧 Centralise sphinx
envdata access toSphinxNeedsData(PR #987)🔧 Consolidate needs data post-processing into
post_process_needs_datafunction (PR #1039)🔧 Replace
DirectivewithSphinxDirective(PR #986)🔧 Remove
unwrapfunction (PR #1017)🔧 Add
remove_node_from_treeutility function (PR #1063)♻️ Refactor needs post-processing function signatures (PR #1040)
📚 Simplify Sphinx-Needs docs builds (PR #972)
📚 Always use headless plantuml (PR #983)
📚 Add intersphinx (PR #991)
📚 Add outline of extension logic (PR #1012)
📚 Fixed extra links example (PR #1016)
🧪 Remove boilerplate from test build
conf.pyfiles (PR #989, PR #990)🧪 Add headless java to test builds (PR #988)
🧪 Make documentation builds fail on warnings (PR #1005)
🧪 Add testing of JS scripts using Cypress integrated into PyTest (PR #1051)
🧪 Add code coverage to CI testing (PR #1067)
1.3.0¶
Released: 16.08.2023
Improvement: Configuration option needs_debug_measurement added, which creates a runtime report for debugging purposes. (PR #917)
Bugfix: Replace hardcoded
indexwith config valueroot_doc. (PR #877)Bugfix: Fix unbounded memory usage in pickle environment. (PR #912)
Bugfix: Supports “None” body in Github services. (issue #903)
Removed esbonio for VS Code Extension.
Removed configuration option needs_ide_snippets_id to support custom need ID for VS Code Extension snippets.
Removed configuration needs_ide_directive_snippets to support custom directive snippets for IDE features.
Provided new IDE support option: VsCode extension Sphinx-Needs-VsCode.
Improvement: Added configuration option needs_report_dead_links, which can deactivate log messages of outgoing dead links. (issue #920)
Improvement: Configuration option needs_allow_unsafe_filters added, which allows unsafe filter for Filter function. (issue #831)
1.2.2¶
Released: 08.02.2023
Bugfix: Changed needed version of jsonschema-lib to be not so strict. (PR #871)
1.2.1¶
Released: 08.02.2023
1.2.0¶
Released: 24.01.2023
Bugfix: Allowing newer versions of jsonschema. (PR #848)
Improvement: Adds list2need directive, which allows to create simple needs from list. (issue #854)
1.1.1¶
Released: 21.12.2022
Bugfix: Removed outdated JS codes that handles the collapse button. (issue #840)
Improvement: Write autogenerated images into output folder (issue #413)
Improvement: Added vector output support to need figures. (issue #815).
Improvement: Introduce the jinja function
reffor needuml. (issue #789)Bugfix: Needflow fix bug in child need handling. (issue #785).
Bugfix: Needextract handles image and download directives correctly. (issue #818).
Bugfix: Needextract handles substitutions correctly. (issue #835).
1.1.0¶
Released: 22.11.2022
Bugfix: Expand/Collapse button does not work. (issue #795).
Bugfix:
singlehtmlandlatexrelated builders are working again. (issue #796).Bugfix: Needextend throws the same information 3 times as part of a single warning. (issue #747).
Improvement: Memory consumption and runtime improvements (issue #790).
Improvement: Obfuscate HTTP authentication credentials from log output. (issue #759)
Bugfix: needflow: nested needs on same level throws PlantUML error. (issue #799)
1.0.3¶
Released: 08.11.2022
Improvement: Fixed needextend error handling by adding a strict-mode option to it. (issue #747)
Improvement: Fixed issue with handling needs-variants by default. (issue #776)
Improvement: Performance fix needs processing. (issue #756)
Improvement: Performance fix for needflow. (issue #760)
Improvement: Fixed rendering issue with the debug layout. (issue #721)
Improvement: Added needs_show_link_id.
Improvement: Supported arguments as filter string for needextract. (issue #688)
Improvement: Added needs_render_context configuration option which enables you to use custom data as the context when rendering Jinja templates or strings. (issue #704)
Improvement: Supported
target_urlfor needs_external_needs. (issue #701)Bugfix: Fixed needuml key shown in need meta data by providing internal need option
arch. (issue #687)Improvement: Included child needs inside their parent need for needflow. (issue #714)
Improvement: Supported generate need ID from title with needs_id_from_title. (issue #692)
Improvement: Supported download
needs.jsonfor needimport. (issue #715)Bugfix: Fixed import() be included in needarch. (issue #730)
Bugfix: Needuml: uml() call circle leads to an exception NeedArch Loop Example. (issue #731)
Improvement: needarch provide need() function to get “need data”. (issue #732)
Improvement: needuml - flow() shall return plantuml text without newline. (issue #737)
Bugfix: Needuml used but “sphinxcontrib.plantuml” not installed leads to exception (issue #742)
Improvement: better documentation of mixing orientation and coloring in needs_extra_links (issue #764)
Bugfix: Needarch: Fixed import() function to work with new implemented flow() (#737). (issue #752)
Bugfix: Needtable: generate id for nodes.table (issue #434)
Improvement: Updated pantuml in test folder to same version as in doc folder (issue #765)
1.0.2¶
Released: 22.09.2022
Improvement: Added support for variants handling for need options. (issue #671)
Improvement: Added Jinja support for need content via the jinja_content option. (issue #678)
Improvement: Added checks and warnings for needimport and needs_external_needs. (issue #624)
Improvement: Support for needs_string_links in needtable. (issue #535)
Improvement: Added
keyoption for needuml.Bugfix: Removed default setting
allowmixingfor needuml. (issue #649)Bugfix: Fixed the collapse button issue for needs including nested needs. (issue #659)
Bugfix: Fixed needextract filter options issue involved with need_part / np. (issue #651)
Improvement: Added
saveoption for needuml.Improvement: Added builder needumls and config option needs_build_needumls in
conf.py.Improvement: Added
filterfunction for needuml.Improvement: Renamed jinja function
needtoflowfor needuml.Improvement: Added directive needarch.
Improvement: Added configuration option needs_ide_snippets_id to support custom need ID for VS Code Extension snippets.
Improvement: Provides jinja function import(need_links_option_name) for needarch to execute uml(id) automatically for all the links defined in the need links options.
Improvement: Added configuration needs_ide_directive_snippets to support custom directive snippets for IDE features. (issue #640)
Bugfix: Updated pip install URLs in Dockerfile. (issue #673)
Improvement: Providing IDE features support for ide_myst.
1.0.1¶
Released: 11.07.2022
Notice: Sphinx <5.0 is no longer supported.
Notice: Docutils <0.18.1 is no longer supported.
Improvement: Provides needuml for powerful, reusable Need objects.
Improvement: Provides needreport for documenting configuration used in a Sphinx-Needs project’s conf.py.
Improvement: Provides initial support for Sphinx-Needs IDE language features. (PR #584)
Improvement: Support snippet for auto directive completion for Sphinx-Needs IDE language features.
Improvement: Added
show_top_sumto Needbar and make it possible to rotate the bar labels. (issue #516)Improvement: Added
needs_constraintsoption. Constraints can be set for individual needs and describe properties a need has to meet.Bugfix: Fixed lsp needs.json path check. (issue #603, issue #633)
Bugfix: Support embedded needs in embedded needs. (issue #486)
Bugfix: Correct references in needtables to be external or internal instead of always external.
Bugfix: Correct documentation and configuration in tags to list type.
Bugfix: Handle overlapping labels in needpie. (issue #498)
Bugfix: needimport uses source-folder for relative path calculation (instead of confdir).
0.7.9¶
Released: 10.05.2022
Improvement: Add permanent link layout function. (issue #390)
Improvement: Support for Sphinx-Needs Docker Image. (issue #531)
Bugfix: needextract not correctly rendering nested needs. (issue #329)
0.7.8¶
Released: 29.03.2022
Improvement: Provides line number info for needs node. (issue #499)
Bugfix: needpie causing a crash in some cases on newer matplotlib versions. (issue #513, issue #517)
Bugfix: needpie takes need-parts in account for filtering. (issue #514)
Bugfix: Empty and invalid
need.jsonfiles throw user-friendly exceptions. (issue #441)
0.7.7¶
Released: 04.03.2022
Bugfix:
needrole supporting lower and upper IDs. (issue #508)Bugfix: Correct image registration to support build via Sphinx API. (issue #505)
Bugfix: Correct css/js file registration on windows. (issue #455)
0.7.6¶
Released: 28.02.2022
Improvement: Filter function support arguments. (issue #429)
Improvement: Adds needs_build_json config option to build
needs.jsonin parallel to other output formats. (issue #485)Improvement: Migrate tests to Pytest and Sphinx internal testing structure. (issue #471)
Bugfix: needs supports incremental build (no doctree deletion). (issue #481)
Bugfix: needs_external_needs working with need. (issue #483)
0.7.5¶
Released: 21.01.2022
Improvement: needbar is introduced (issue #452)
Improvement: needs_external_needs supports relative path for
base_url.Improvement:
needs.jsonschema gets checked during a needimport (issue #456)Improvement: Supports Filter function for needpie (issue #400)
Bugfix: Changed needgantt strftime format string according to C89 defined value. (issue #445)
Bugfix: needpie option :legend: is correctls rendered (issue #448)
Bugfix: needpie figures are closed after creation, to free memory and suppress matplotlib warning (issue #450)
Bugfix: Added implementation for simple_footer grid in Layouts Grids (issue #457)
Bugfix: Changed needs_external_needs Fix issue when loading needs from URL. (issue #459)
Bugfix: Changed needs_external_needs getting from URL was using parameter related to local file. (issue #458)
0.7.4¶
Released: 30.11.2021
Improvement: Adds debug flag for needservice.
Improvement: Better css table handling.
Improvement: Adds class to needtable to set own css classes for tables. (issue #421)
Improvement: Adds needs_string_links to support easy string2link transformations. (issue #404)
Improvement: Adds colwidths to needtable directive, to allow the definition of column widths. (issue #402)
0.7.3¶
Released: 08.11.2021
Improvement: Schema check for
need.jsonfiles implemented.Improvement: New option for
needtableand co: Filter function, which allows to reference and use python code as filter code from external files (issue #340)Bugfix: Fixed needs handling warnings about missing needs.json when needs_file not configured (issue #340)
Bugfix: unstable build with needs_external_needs (issue #399)
Bugfix: needs_external_needs reads external need status now and warnings gets not checked for needs_external_needs (issue #375)
0.7.2¶
Released: 08.10.2021
Improvement: New config option needs_builder_filter to define a filter for the needs builder. (issue #342)
Improvement: Added option
json_pathfor needs_external_needs to support external needs from localneeds.jsonfiles. (issue #339)Improvement: Providing needs_table_classes to allow to set custom table css classes, to better support themes like ReadTheDocs. (issue #305)
Improvement: Supporting user defined filter code function for needs_warnings (issue #345)
Improvement: Supporting caption for needtable (issue #348)
Improvement: New config option needs_filter_data to allow to use custom data inside a Filter string (issue #317)
Improvement: API to register warnings (issue #343)
Bugfix: Scrolling tables improved and ReadTheDocs Tables fixed (issue #305)
Bugfix: needtable need parts ‘id’ column is not linked (issue #336)
Bugfix: needtable need parts ‘incoming’ column is empty (issue #336)
Bugfix: needs_warnings not written to error log. (issue #344)
Improvement: Providing needs_warnings_always_warn to raise sphinx-warnings for each not passed needs_warnings. (issue #344)
Bugfix: needimport relative path not consistent to Sphinx default directives. (issue #351)
0.7.1¶
Released: 21.07.2021
Improvement: Support for parallel sphinx-build when using
-joption (issue #319)Improvement: Better
eval()handling for filter strings (issue #328)Improvement: Internal performance measurement script
Improvement: Profiling support for selected functions
0.7.0¶
Released: 06.07.2021
Improvement: Providing needs_external_needs to allow usage and referencing of external needs. (issue #137)
Improvement: New directive needextend to modify or extend existing needs. (issue #282)
Improvement: Allowing Custom column titles for needtable. (issue #299)
Bugfix: needextend does not support usage of internal options. (issue #318)
Bugfix: needtable shows attributes with value
Falseagain.Bugfix:
:hide:and:collapse: Trueare working inside needimport. (issue #284, issue #294)Bugfix: needpie amount labels get calculated correctly. (issue #297)
0.6.3¶
Released: 18.06.2021
Improvement: Dead links (references to not found needs) are supported and configurable by allow_dead_links. (issue #116)
Improvement: Introducing need_func to execute Dynamic functions inline. (issue #133)
Improvement: Support for multiline_option in templates.
Bugfix: needflow: links for need-parts get correctly calculated. (issue #205)
Bugfix: CSS update for ReadTheDocsTheme to show tables correctly. (issue #263)
Bugfix: CSS fix for needtable style_row. (issue #195)
Bugfix:
current_needvar is accessible in all need-filters. (issue #169)Bugfix: Sets defaults for color and style of need type configuration, if not set by user. (issue #151)
Bugfix: needtable shows horizontal scrollbar for tables using datatables style. (issue #271)
Bugfix: Using
id_completeinstead ofidin filter code handling. (issue #156)Bugfix: Dynamic Functions registration working for external extensions. (issue #288)
0.6.2¶
Released: 30.04.2021
Improvement: Parent needs of nested needs get collected and are available in filters. (issue #249)
Bugfix: Copying static files during sphinx build is working again. (issue #252)
Bugfix: Link function for layouts setting correct text. (issue #251)
0.6.1¶
Released: 23.04.2021
Support: Removes support for Sphinx version <3.0 (Sphinx 2.x may still work, but it gets not tested).
Improvement: Internal change to poetry, nox and github actions. (issue #216)
Bugfix: Need-service calls get mocked during tests, so that tests don’t need reachable external services any more.
Bugfix: No warning is thrown any more, if needservice can’t find a service config in conf.py (issue #168)
Bugfix: Needs nodes get
idsset directly, to avoid empty ids given by sphinx or other extensions for need-nodes. (issue #193)Bugfix: needimport supports extra options and extra fields. (issue #227)
Bugfix: Checking for ending
/of given github api url. (issue #187)Bugfix: Using correct indention for pre and post_template function of needs.
Bugfix: Certain log message don’t use python internal
idany more. (issue #225)Bugfix: JS-code for meta area collapse is working again. (issue #242)
0.6.0¶
Improvement: Directive needservice added, which allow to include data from external services like Jira or github. See also Services (issue #163)
Improvement: GitHub services added to fetch issues, pr or commits from GitHub or GitHub Enterprise.
Bugfix: Role need_outgoing shows correct link instead of None (issue #160)
0.5.6¶
Bugfix: Dynamic function registration via API supports new internal function handling (issue #147)
Bugfix: Deactivated linked gantt elements in needgantt, as PlantUML does not support them in its latest version (not beta).
0.5.5¶
Improvement: Added needsequence directive. (issue #144)
Improvement: Added needgantt directive. (issue #146)
Improvement: Added two new need-options: duration and completion
Improvement: Configuration option needs_duration_option and needs_completion_option added
Bugfix: Using of tags.has() in conf.py does not raise an exception any more. (issue #142)
Improvement: Clean up of internal configuration handling and avoiding needs_functions to get pickled by sphinx.
0.5.4¶
Improvement: Added options pre_template and post_template for needs. (issue #139)
Bugfix: Setting correct default value for needs_statuses (issue #136)
Bugfix: Dynamic functions can be used in links (text and url) now.
0.5.3¶
Improvement: Added
transparentfor transparent background to needflow configurations.Improvement: needflow uses directive argument as caption now.
Improvement: Added option align to align needflow images.
Improvement: Added option scale to scale needflow images. (issue #127)
Improvement: Added option highlight to needflow. (issue #128)
Improvement: need_count supports ratio calculation. (issue #131)
Improvement: needlist, needtable and needflow support Filter code. (issue #132)
Improvement: needflow caption is a link to the original image file. (issue #129)
Bugfix: template can now be set via needs_global_options.
Bugfix: Setting correct urls for needs in needflow charts.
Bugfix: Setting correct image candidates (issue #134)
0.5.2¶
Improvement: Sphinx-Needs configuration gets checked before build. (issue #118)
Improvement:
meta_links_alllayout function now supports an exclude parameterImprovement: needflow’s connection line and arrow type can be configured.
Improvement: Configurations added for needflow. Use needs_flow_configs to define them and config for activation.
Improvement: needflow option debug added, which prints the generated PlantUML code after the flowchart.
Improvement: Supporting Need-Templates by providing need option template and configuration option needs_template_folder. (issue #119)
Bugfix: needs_global_options handles None values correctly.
stylecan now be set.Bugfix: needs_title_from_content takes
\nand.as delimiter.Bugfix: Setting css-attribute
white-space: normalfor all need-tables, which is set badly in some sphinx-themes. (Yes, I’m looking at you ReadTheDocs theme…)Bugfix:
meta_alllayout function also outputs extra links and theno_linksparameter now works as expectedBugfix: Added need-type as css-class back on need. Css class name is
needs_type_(need_type attribute). (issue #124)Bugfix: Need access inside list comprehensions in Filter string is now working.
0.5.1¶
Improvement: Added needextract directive to mirror existing needs for special outputs. (issue #66)
Improvement: Added new styles
discreetanddiscreet_border.Bugfix: Some minor css fixes for new layout system.
0.5.0¶
Improvement: Introduction of needs Layouts & Styles.
Improvement: Added config options needs_layouts and needs_default_layout.
Improvement: Added needpie which draws pie-charts based on Filter string.
Improvement: Added config option needs_warnings. (issue #110)
Bugfix: Need css style name is now based on need-type and not on the longer, whitespace-containing type name. Example:
need-testinstead of not validneed-test case. (issue #108)Bugfix: No more exception raise if
copyvalue not set inside needs_extra_links.Improvement: Better log message, if required id is missing. (issue #112)
Removed: Configuration option needs_collapse_details. This is now realized by Layouts.
Removed: Configuration option needs_hide_options. This is now realized by Layouts.
Removed: Need option need_hide_status. This is now realized by Layouts.
Removed: Need option need_hide_tags. This is now realized by Layouts.
WARNING: This version changes a lot the html output and therefore the needed css selectors. So if you are using custom css definitions you need to update them.
0.4.3¶
Improvement: Role need supports standard sphinx-ref syntax. Example:
:need:`custom name <need_id>`Improvement: Added needs_global_options to set values of global options only under custom circumstances.
Improvement: Added sorting to needtable. See sort for details.
Improvement: Added dynamic function links_from_content to calculated links to other needs automatically from need-content. (issue #98)
Improvement: Dynamic function copy supports uppercase and lowercase transformation.
Improvement: Dynamic function copy supports filter_string.
Bugfix: Fixed corrupted Dynamic functions handling for
tagsand other list options. (issue #100)Bugfix: Double entries for same need in needtable fixed. (issue #93)
0.4.2¶
Improvement: Added
signatureinformation to need-object. Usable inside Filter string. Mainly needed by Sphinx-Test-Reports to link imported test cases to needs documented by sphinx-autodoc.
0.4.1¶
0.4.0¶
Improvement: Provides API for other sphinx-extensions. See Python API for documentation.
Improvement: Added Support page.
Bugfix: Fixed deprecation warnings to support upcoming Sphinx3.0 API.
0.3.15¶
Improvement: In filter operations, all needs can be accessed by using keyword
needs.Bugfix: Removed prefix from normal needs for needtable (issue #97)
0.3.14¶
Improvement: Added config option needs_role_need_max_title_length to define the maximum title length of referenced needs. (issue #95)
0.3.13¶
Bugfix: Filters on needs with
id_parentorid_completedo not raise an exception any more and filters gets executed correctly.
0.3.12¶
Improvement: Tables can be sorted by any alphanumeric option. (issue #92)
Improvement: need_part / np are now embedded in their parent need, if needflow is used. (issue #83)
Bugfix: Links to need_part / np are no longer rendered to parent need, instead the link goes directly to the need_part. (issue #91)
Bugfix: Links in needflow get shown again by default (issue #90)
0.3.11¶
Improvement: Added config option needs_extra_links to define additional link types like blocks, tested by and more. Supports also style configuration and custom presentation names for links.
Improvement: Added export_id option for filter directives to export results of filters to
needs.json.Improvement: Added config option needs_flow_show_links and related needflow option show_link_names.
Improvement: Added config option needs_flow_link_types and related needflow option link_types.
Bugfix: Unicode handling for Python 2.7 fixed. (issue #86)
0.3.10¶
Bugfix: type was missing in output of builder needs (issue #79)
Bugfix: needs_functions parameter in conf.py created a sphinx error, if containing python methods. Internal workaround added, so that usage of own Dynamic functions stays the same as in prior versions (issue #78)
0.3.9¶
Bugfix: Grubby tag/link strings in needs, which define empty links/tags, produce a warning now.
Bugfix: Better logging of document location, if a filter string is not valid.
Bugfix: Replaced all print-statements with sphinx warnings.
0.3.8¶
Improvement: need_part / np has now attributes
id_parentandid_complete, which can be referenced in Filter string.Improvement: needtable supports presentation of filtered need_part / np (without showing parent need).
0.3.7¶
Improvement: Filter string now supports the filtering of need_part / np.
Improvement: The ID of a need is now printed as link, which can easily be used for sharing. (issue #75)
Bugfix: Filter functionality in different directives are now using the same internal filter function.
Bugfix: Reused IDs for a need_part / np are now detected and a warning gets printed. (issue #74)
0.3.6¶
Improvement: Added needtable option show_parts.
Improvement: Added configuration option needs_part_prefix.
Improvement: Added docname to output file of builder needs
Bugfix: Added missing needs_import template to MANIFEST.ini.
0.3.5¶
Bugfix: A need_part / np without a given ID gets a random id based on its content now.
Bugfix: Calculation of outgoing links does not crash, if need_parts are involved.
0.3.4¶
Bugfix: Need representation in PDFs were broken (e.g. all meta data on one line).
0.3.3¶
Bugfix: Latex and Latexpdf are working again.
0.3.2¶
Bugfix: Links to parts of needs (need_part / np) are now stored and presented as links incoming of target link.
0.3.1¶
Improvement: Added dynamic function check_linked_values.
Improvement: Added dynamic function calc_sum.
Improvement: Added role need_count, which shows the amount of found needs for a given filter-string.
- Bugfix: Links to need_part / np in needflow are now shown correctly as extra line between
need_parts containing needs.
Bugfix: Links to need_part / np in needtable are now shown and linked correctly in tables.
0.3.0¶
Improvement: Dynamic functions are now available to support calculation of need values.
Improvement: needs_functions can be used to register and use own dynamic functions.
Improvement: Added needs_global_options to set need values globally for all needs.
Improvement: Added needs_hide_options to hide specific options of all needs.
Bugfix: Removed needs are now deleted from existing needs.json (issue #68)
Removed: needs_template and needs_template_collapse are no longer supported.
0.2.5¶
Bugfix: Fix for changes made in 0.2.5.
0.2.4¶
Bugfix: Fixed performance issue (issue #63)
0.2.3¶
Improvement: Titles can now be made optional. See needs_title_optional. (issue #49)
Improvement: Titles be auto-generated from the first sentence of a requirement. See needs_title_from_content and title_from_content. (issue #49)
Improvement: Titles can have a maximum length. See needs_max_title_length. (issue #49)
0.2.2¶
Improvement: The sections, to which a need belongs, are now stored, filterable and exported in
needs.json. See updated filter. (PR #53 )Improvement: Project specific options for needs are supported now. See needs_extra_options. (PR #48 )
Bugfix: Logging fixed (issue #50 )
Bugfix: Tests for custom styles are now working when executed with all other tests (PR #47)
0.2.1¶
Bugfix: Sphinx warnings fixed, if need-collapse was used. (issue #46)
Bugfix: dark.css, blank.css and common.css used wrong need-container selector. Fixed.
0.2.0¶
Deprecated:
needfilteris replaced by needlist, needtable or needflow. Which support additional options for related layout.Improvement: Added needtable directive.
Improvement: Added DataTables support for needtable (including table search, excel/pdf export and dynamic column selection).
Improvement: Added needs_id_regex, which takes a regular expression and which is used to validate given IDs of needs.
Improvement: Added meta information shields on documentation page
Improvement: Added more examples to documentation
Bugfix: Care about unneeded separator characters in tags (issue #36)
Bugfix: Avoiding multiple registration of resource files (js, css), if sphinx gets called several times (e.g. during tests)
Bugfix: Needs with no status shows up on filters (issue #45)
Bugfix: Supporting Sphinx 1.7 (issue #41)
0.1.49¶
0.1.48¶
Improvement: Added configuration option needs_role_need_template.
Bugfix: Referencing not existing needs will result in build warnings instead of a build crash.
- Refactoring: needs development files are stored internally under sphinxcontrib/needs, which is in sync with
most other sphinxcontrib-packages.
0.1.47¶
Bugfix: dark.css was missing in MANIFEST.in.
Improvement: Better output, if configured needs_css file can not be found during build.
0.1.46¶
Bugfix: Added python2/3 compatibility for needs_import.
0.1.45¶
Bugfix: needs with no status are handled the correct way now.
0.1.44¶
Bugfix: Import statements are checked, if Python 2 or 3 is used.
0.1.43¶
Improvement: Added “dark.css” as style
Bugfix: Removed “,” as as separator of links in need presentation.
0.1.42¶
Improvement: Added config parameter needs_css, which allows to set a css file.
Improvement: Most need-elements (title, id, tags, status, …) got their own html class attribute to support custom styles.
Improvement: Set default style “modern.css” for all projects without configured needs_css parameter.
0.1.41¶
Improvement: Added config parameters needs_statuses and needs_tags to allow only configured statuses/tags inside documentation.
Bugfix: Added LICENSE file (MIT)
0.1.40¶
Bugfix: Removed jinja activation
0.1.39¶
Bugfix: Added missing needimport_template.rst to package
Bugfix: Corrected version param of needimport
0.1.38¶
- Improvement: :links:, :tags: and other list-based options can handle “,” as delimiter
(beside documented “;”). No spooky errors are thrown any more if “,” is used accidentally.
0.1.37¶
Bugfix: Implemented 0.1.36 bugfix also for
needfilterand needimport.
0.1.36¶
Bugfix: Empty :links: and :tags: options for need items raise no error during build.
0.1.35¶
Improvement/Bug: Updated default node_template to use less space for node parameter representation
Improvement: Added :filter: option to needimport directive
Bugfix: Set correct default value for need_list option. So no more warnings should be thrown during build.
Bugfix: Imported needs gets sorted by id before adding them to the related document.
0.1.34¶
Improvement: New option tags for needimport directive
Bugfix: Handling of relative paths in needs builder
0.1.33¶
New feature: Directive needimport implemented
Improvement: needs-builder stores needs.json for all cases in the build directory (like _build/needs/needs.json) (See issue)
Bugfix: Wrong version in needs.json, if an existing needs.json got imported
Bugfix: Wrong need amount in initial needs.json fixed
0.1.32¶
Bugfix: Setting correct working directory during conf.py import
Bugfix: Better config handling, if Sphinx builds gets called multiple times during one single python process. (Configs from prio sphinx builds may still be active.)
Bugifx: Some clean ups for using Sphinx >= 1.6
0.1.31¶
Bugfix: Added missing dependency to setup.py: Sphinx>=1.6
0.1.30¶
Improvement: Builder needs added, which exports all needs to a json file.
0.1.29¶
Bugfix: Build has crashed, if sphinx-needs was loaded but not a single need was defined.
0.1.28¶
- Bugfix: Added support for multiple sphinx projects initialisations/builds during a single python process call.
(Reliable sphinx-needs configuration separation)
0.1.27¶
New config: needs_show_link_type
New config: needs_show_link_title
0.1.26¶
- Bugfix: Working placement of “,” for links list produced by roles need_outgoing
and need_incoming.
0.1.25¶
Restructured code
Restructured documentation
Improvement: Role need_outgoing was added to print outgoing links from a given need
Improvement: Role need_incoming was added to print incoming links to a given need
0.1.24¶
Bugfix: Reactivated jinja execution for documentation.
0.1.23¶
Improvement: complex filter for needfilter directive supports regex searches.
Improvement: complex filter has access to nearly all need variables (id, title, content, …)`.
Bugfix: If a duplicated ID is detected an error gets thrown.
0.1.22¶
Improvement: needfilter directives supports complex filter-logic by using parameter Filtering needs.
0.1.21¶
Improvement: Added word highlighting of need titles in linked pages of svg diagram boxes.
0.1.20¶
Bugfix for custom needs_types: Parameter in conf.py was not taken into account.
0.1.19¶
Added configuration parameter needs_id_required.
Backwards compatibility changes:
Reimplemented needlist as alias for
needfilterAdded need directive/need as part of the default needs_types configuration.
0.1.18¶
Initial start for the changelog
Free definable need types (Requirements, Bugs, Tests, Employees, …)
Allowing configuration of needs with a
directive name
meaningful title
prefix for generated IDs
color
Added needfilter directive
Added layouts for needfilter:
list (default)
table
diagram (based on plantuml)
Integrated interaction with the activated plantuml sphinx extension
Added role need to create a reference to a need by giving the id