Skip to content

Conversation

PierreEtienneJ
Copy link

@PierreEtienneJ PierreEtienneJ commented Apr 6, 2025

Close #1434, firstly only hot fix with step 3: update functions which used split_need_id to check need_id_main and need_id_full.

@PierreEtienneJ PierreEtienneJ force-pushed the fix-#1434-need-ref-with-dots branch from 773b662 to ff4264e Compare May 20, 2025 05:44
PierreEtienneJ and others added 7 commits May 21, 2025 07:34
The `need_part`/`np` role is not a reference and should not use an
`XRefRole` subclass (see useblocks#1437).

In addition, the processing now correctly handles and warns on need
parts that are not part of a need and `need` roles that reference an
unknown part.
This fixes the docs build warnings emitted by RST highlighting:
```
<unknown>:1: SyntaxWarning: invalid escape sequence '\.'
<string>:1: SyntaxWarning: invalid escape sequence '\.'
<unknown>:1: SyntaxWarning: invalid escape sequence '\w'
<string>:1: SyntaxWarning: invalid escape sequence '\w'
```
This is the implementation of the discussion
useblocks#1451
and a follow-up on useblocks#1441.

The PR adds schema validation to Sphinx-Needs that
supports local validation and network validation.
The Sphinx-Needs internal data type representation is not changed yet,
all types are still strings. This will come shortly after merge.
Users can already try out the new interface and provide feedback.

Differences to PR 1441:
- Aligning with standards in JSON schema for re-using subschemas via
`$defs` and `$ref`
- Fully typed implementation including runtime checks of valid schema
user input
- Auto inject the default string type if not given
- Replace `trigger_schema` with `select` which aligns with query
language terminology
- Replace `trigger_schema_id` with the mentioned `$ref` mechanism
- New schemas root key `validate` with sub-keys `local` and `network`
for the 2 validation types
- Network validation items does not allow the `select` key anymore as
the selection happens by linking target needs.
  This cleans up an ambiguity in the other PR.
- Network validation errors now bubble up to the root json schema and
are displayed to see exactly why the chain fails
- More network rule types for better control over debug schema output
- Rewrite test cases to use a declarative definition as yaml, so all
pieces can be given in one place:
  - conf.py
  - ubproject.toml
  - index.rst
  - schemas.json
  - expected ontology warnings
- Simplified the code logic
- String patterns (regex) are constrained to a basic subset that works
across engines
- Added docs
  - Examples and explanations
- Comparison with `needs_warnings` and `needs_constraints` and migration
path
- Many more test cases
- `items` with `minItems` and `maxItems` and `contains` with
`minContains` and `maxContains` are now semantically equivalent to JSON
schema spec

---------

Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to reference need IDs containing dots using :need: directive

3 participants