|
| 1 | +.. _ubCode: https://ubcode.useblocks.com/ |
| 2 | + |
1 | 3 | .. _changelog: |
2 | 4 |
|
3 | 5 | Changelog |
4 | 6 | ========= |
5 | 7 |
|
| 8 | +6.0.0 |
| 9 | +----- |
| 10 | + |
| 11 | +:Released: 28.09.2025 |
| 12 | +:Full Changelog: `v5.1.0...v6.0.0 <https://github.com/useblocks/sphinx-needs/compare/5.1.0...fc765b4ea6fdf79ad146cf2ce66e084178de3a9f>`__ |
| 13 | + |
| 14 | +This release introduces strong typing for extra option fields to the Sphinx-Needs codebase. |
| 15 | +This affects needs read from RST sources (or others like .md), but also imported/exported needs |
| 16 | +of needs.json files. |
| 17 | + |
| 18 | +The default type for extra options is still ``string``, so existing configuration should work |
| 19 | +as before. Type errors are detected early once each need is fully resolved, i.e. after |
| 20 | +reading in the sources and evaluating :ref:`needs_global_options` (defaults), |
| 21 | +:ref:`needextend`, :ref:`variants <needs_variant_support>` and :ref:`dynamic_functions`. |
| 22 | +Errors in the typing system lead to needs not being created. |
| 23 | + |
| 24 | +The release also introduces a new :ref:`schema_validation` system that integrates |
| 25 | +into the strong typing. It is JSON schema compliant in large parts with custom extensions |
| 26 | +to support network validation. |
| 27 | + |
| 28 | +The core of Sphinx-Needs had to be refactored in large parts to enable these changes. |
| 29 | +The following are the main user-facing changes: |
| 30 | + |
| 31 | +- β»οΈ Allow for typed ``needs_extra_options`` fields :pr:`1516` |
| 32 | + |
| 33 | + The ``needs_extra_options`` configuration option was extended to support schema information. |
| 34 | + The field ``schema.type`` globally sets the type for the field. Users can select between |
| 35 | + ``string``, ``number`` (float), ``integer``, ``boolean`` and ``array``. For the ``array`` type |
| 36 | + another keyword ``schema.items.type`` defines the list items type. |
| 37 | + |
| 38 | + Examples in TOML configuration: |
| 39 | + |
| 40 | + .. code-block:: toml |
| 41 | +
|
| 42 | + [[needs.extra_options]] |
| 43 | + name = "priority" |
| 44 | + description = "Priority level, 1-5 where 1 is highest and 5 is lowest" |
| 45 | + schema.type = "integer" |
| 46 | + schema.minimum = 1 |
| 47 | + schema.maximum = 5 |
| 48 | +
|
| 49 | + [[needs.extra_options]] |
| 50 | + name = "asil" |
| 51 | + description = "Automotive Safety Integrity Level" |
| 52 | + schema.type = "string" |
| 53 | + schema.enum = ["QM", "A", "B", "C", "D"] |
| 54 | +
|
| 55 | + **Key Changes:** |
| 56 | + |
| 57 | + - Strong typing for ``needs_extra_options`` with JSON schema validation |
| 58 | + - Delayed resolution for dynamic functions, needextend, defaults, and variants |
| 59 | + - Automatic type coercion from string inputs (directive options) to proper types |
| 60 | + - Missing fields are set to ``None`` (null in JSON) |
| 61 | + - needs.json import/export with type validation and coercion; empty ``""`` field values |
| 62 | + of existing needs.json files of type ``integer`` are coerced to ``0``, and for |
| 63 | + type ``number`` to ``0.0`` for backwards compatibility. Empty strings for ``boolean`` |
| 64 | + fields are coerced to ``True`` as this is often used as a flag. |
| 65 | + - Integration with schema validation system. The same fields for :ref:`supported_data_types` |
| 66 | + can be set in the definition, so they are set globally for that field. |
| 67 | + |
| 68 | + The implementation strives to be as backwards compatible as possible. See below for details. |
| 69 | + |
| 70 | +- β¨ Schema validation :pr:`1467` |
| 71 | + |
| 72 | + The PR adds a fast, declarative and versatile JSON schema based need validation. |
| 73 | + The schema is defined in the :ref:`needs_schema_definitions` configuration option or |
| 74 | + as JSON format passed via :ref:`needs_schema_definitions_from_json`. |
| 75 | + |
| 76 | + **Key Features:** |
| 77 | + |
| 78 | + - JSON Schema standard compliance using ``$defs`` and ``$ref`` for reusable sub-schemas |
| 79 | + - Fully typed implementation with runtime validation of schema definitions |
| 80 | + - Auto-injection of default string type when not specified |
| 81 | + - Select mechanism, comparable to database queries to select need nodes for validation. |
| 82 | + - Root ``validate`` key with ``local`` and ``network`` sub-sections for validation types. |
| 83 | + The split enables IDE extensions such as `ubCode`_ to validate-on-type for need-local |
| 84 | + changes and also run network validation once the index is fully built. |
| 85 | + - Debug mechanism using :ref:`needs_schema_debug_active` to check why validations pass or fail. |
| 86 | + 4 files are written per validation: original need, reduced need, applied schema and |
| 87 | + a result file with user and validation message. File naming pattern is |
| 88 | + ``<need_id>__<schema_path>__<validation_rule>.<json|txt>``. Nested graph-validations are also |
| 89 | + dumped. |
| 90 | + - String regex pattern constraints with cross-engine compatibility |
| 91 | + - Semantic equivalence to JSON Schema spec for array ``items``, ``minItems``, ``maxItems``, |
| 92 | + ``contains``, ``minContains``, and ``maxContains`` |
| 93 | + |
| 94 | + The new validation can replace :ref:`needs_warnings`, :ref:`needs_constraints`, |
| 95 | + :ref:`needs_id_regex`, :ref:`needs_statuses`, and :ref:`needs_tags` in the future. |
| 96 | + |
| 97 | + The implementation of the new strong typing and schema validation into `ubCode`_ is on the |
| 98 | + immediate roadmap. |
| 99 | + |
| 100 | +- π Write schema violations into a JSON file :pr:`1503` |
| 101 | + |
| 102 | + Schema validation violations are now exported to a JSON file (``schema_violations.json``) |
| 103 | + for external tooling integration and automated quality assurance workflows. This enables |
| 104 | + CI/CD systems and external analysis tools to programmatically process validation results. |
| 105 | + |
| 106 | +- Always generate schema violations.json report file :pr:`1511` |
| 107 | + |
| 108 | +**These PRs were part of the internal changes:** |
| 109 | + |
| 110 | +- π§ͺ Move to snapshot testing for test_schema :pr:`1519` |
| 111 | +- π§ Add ``VariantFunctionParsed`` dataclass :pr:`1515` |
| 112 | +- π§ Add ``DynamicFunctionParsed`` dataclass :pr:`1514` |
| 113 | +- β»οΈ Auto-compute certain need fields :pr:`1496` |
| 114 | +- β»οΈ Set some core need fields to nullable :pr:`1488` |
| 115 | +- π§ Split import item filtering to separate function :pr:`1484` |
| 116 | +- β»οΈ Lazily assess directive options :pr:`1482` |
| 117 | +- π§ͺ Improve test for need parts :pr:`1507` |
| 118 | +- π Improve need part processing :pr:`1469` |
| 119 | +- π§ Centralise allowed variant core need fields :pr:`1424` |
| 120 | +- β¨ Add ``is_import`` need field :pr:`1429` |
| 121 | + |
| 122 | + New field to identify needs that were imported from external sources. |
| 123 | + |
| 124 | +**Breaking Changes** |
| 125 | + |
| 126 | +- :ref:`Variants <needs_variant_support>` have to be wrapped with ``<< >>``. This allows |
| 127 | + for a safer parsing strategy and support for usage in array elements. |
| 128 | +- The variant delimiter has changed to only allow ``,``. Formerly also ``;`` was possible. |
| 129 | +- π Fix: disallow need variants for list type fields :pr:`1489` |
| 130 | + |
| 131 | + Variants no longer supported in list-type fields due to parsing instability. |
| 132 | + This feature might be re-introduced in future. |
| 133 | + The new syntax ``<< >>`` would make this much easier. |
| 134 | + |
| 135 | +- βΌοΈ remove parsing of deprecated ``needs_global_options`` format :pr:`1517` |
| 136 | + |
| 137 | + Removes support for the deprecated legacy format of |
| 138 | + ``needs_global_options``. The system now only accepts the dictionary format |
| 139 | + introduced in version 5.1.0. Projects using the old format will receive a warning |
| 140 | + that the configuration is not a ``dict`` and the parsing will be skipped entirely. |
| 141 | + Users must migrate to the new explicit format for global options to continue working. |
| 142 | + |
| 143 | +- βΌοΈ Improve needs default field application (via needs_global_options) :pr:`1478` |
| 144 | + |
| 145 | + Previously defaults would be applied to any fields of a need with a "falsy" value, |
| 146 | + e.g. ``None``, ``False``, ``0``, ``""``, ``[]``. This is an issue if the user wants to |
| 147 | + specifically set fields to these values, without them being overridden by defaults. |
| 148 | + Therefore, now defaults are only applied to fields with a missing or None value. |
| 149 | + |
| 150 | +- βΌοΈ Disallow ``add_extra_option`` overriding an internal field :pr:`1477` |
| 151 | + |
| 152 | + Needs are stored in a flat dictionary as of now, so they cannot overlap. |
| 153 | + |
| 154 | +- β»οΈ Store needs as ``NeedItem`` / ``NeedPartItem``, rather than standard ``dict`` :pr:`1485` |
| 155 | + |
| 156 | + Replaces standard dictionary storage with specialized ``NeedItem`` and ``NeedPartItem`` classes. |
| 157 | + This allows better encapsulation and control over data mutation. |
| 158 | + |
| 159 | + This is breaking for any users doing "non-API" modifications or additions to the needs data, |
| 160 | + i.e. directly adding dict items. |
| 161 | + It should not change interactions with standard APIs like ``add_need`` or filter strings. |
| 162 | + |
| 163 | + These PRs are also related: |
| 164 | + |
| 165 | + - β»οΈ Improve storage of part data on NeedItem :pr:`1509` |
| 166 | + - π§ Improve storage of content generation on ``NeedItem`` :pr:`1506` |
| 167 | + - π§ Improve storage of constraint results on ``NeedItem`` :pr:`1504` |
| 168 | + - π Capture more information about modifications on ``NeedItem`` :pr:`1502` |
| 169 | + - β»οΈ split off ``source`` fields in ``NeedItem`` internal data :pr:`1491` |
| 170 | + - β»οΈ split ``NeedItem`` internal data into core, extras, links and backlinks :pr:`1490` |
| 171 | + |
| 172 | +- β¬οΈ Drop Python 3.9 :pr:`1468` |
| 173 | +- β¬οΈ Drop Sphinx<7.4, test against Python 3.13 :pr:`1447` |
| 174 | + |
| 175 | +**Further improvements and fixes** |
| 176 | + |
| 177 | +- π§ Improve plantuml check + add tests :pr:`1521` |
| 178 | + |
| 179 | + PlantUML extension detection now uses ``app.extensions`` for better compatibility with dynamic |
| 180 | + registration. Thanks to @AlexanderLanin for the initial implementation. |
| 181 | + |
| 182 | +- β»οΈ Warn for missing needimport files :pr:`1510` |
| 183 | + |
| 184 | + Missing :ref:`needimport` files now emit warnings instead of throwing exceptions, making |
| 185 | + it possible to ignore the problem for specific use cases. |
| 186 | + |
| 187 | +- π Avoid leaking auth credentials for ext. need warnings :pr:`1512` |
| 188 | +- β»οΈ Exclude ``is_need`` / ``is_part`` from ``needs.json`` output :pr:`1505` |
| 189 | + |
| 190 | + It doesn't make sense to have these, since only needs are written, not parts. |
| 191 | + Also, these fields are "thrown away" when passing in external/import needs.json. |
| 192 | + |
| 193 | + These fields are only really used during processing, within filter contexts, when filtering |
| 194 | + across both needs and parts. |
| 195 | + |
| 196 | +- π Reset directive option specs at start of build :pr:`1448` |
| 197 | + |
| 198 | + Internal fix to reset directive options for consistent builds & testing. |
| 199 | + |
| 200 | +- π Warn on dynamic function with surrounding text :pr:`1426` |
| 201 | + |
| 202 | + Added warning when dynamic functions are used for a list type with surrounding text |
| 203 | + as the surrounding text will be silently ignored. |
| 204 | + |
| 205 | +- Allow ``collapse`` and ``hide`` in ``needs_global_options`` :pr:`1456` |
| 206 | +- π§ Allow template global_options :pr:`1454` |
| 207 | +- π Re-allow dynamic functions for ``layout`` field :pr:`1423` |
| 208 | +- π§ Allow pre/post template ``global_options`` :pr:`1428` |
| 209 | + |
| 210 | +**Minor documentation updates** |
| 211 | + |
| 212 | +- π Clarify c.this_doc() for needextend :pr:`1475` |
| 213 | +- π Fix needs_extra_links name :pr:`1501` |
| 214 | +- π Format configuration.rst :pr:`1473` |
| 215 | +- π Fix escape sequences :pr:`1470` |
| 216 | + |
| 217 | +**Infrastructure** |
| 218 | + |
| 219 | +- π§ benchmark group non win32 :pr:`1450` |
| 220 | +- π Fix cyclic imports :pr:`1443` |
| 221 | +- π§ Added yamlfmt pre-commit :pr:`1446` |
| 222 | +- π§ Use ubuntu-latest in CI :pr:`1439` |
| 223 | +- π update tox version to py39 :pr:`1438` |
| 224 | + |
6 | 225 | 5.1.0 |
7 | 226 | ----- |
8 | 227 |
|
|
0 commit comments