Features

🔍 Features

ID

Title

SI

Faults

FE_SN_CONTENT_RENDER

Display Traceability objects content in Sphinx-Needs

yes

ER_SN_CONTENT_SYNTAX

FE_SN_DOCTREE

Generate object representation in Sphinx-Needs

yes

ER_SN_LAY_META_MIS; ER_SN_LAY_META_WRONG

FE_SN_DYN_FUNC

Apply dynamic functions for meta-data computation

yes

ER_SN_DYN_NO_EXEC; ER_SN_DYN_INVALID2; ER_SN_DYN_WRONG_CALC; ER_SN_DYN_NO_VALUE

FE_SN_JSON

Export needs.json file using Sphinx-Needs

yes

ER_SN_JSON_MIS; ER_SN_JSON_COR; ER_SN_JSON_LINKS_COR; ER_SN_JSON_CONTENT_COR

FE_SN_JSON_LINK_CONDITIONS

Link conditions exported to needs.json

yes

ER_SN_JSON_LINK_COND_MISSING; ER_SN_JSON_LINK_COND_DRIFT

FE_SN_LINK

Establish links between Traceability objects in Sphinx-Needs

yes

ER_SN_LINKS_NO_BACK; ER_SN_LINKS_NO_TARGET; ER_SN_LINKS_NO_EXT; ER_SN_LINKS_EXT_COR; ER_SN_LINKS_MISSING

FE_SN_LINK_CONDITIONS

Conditional link evaluation (NeedLink, parse_conditions)

yes

ER_SN_LINK_COND_PARSE; ER_SN_LINK_COND_EVAL_WRONG; ER_SN_LINK_COND_HIDES_SAFE; ER_SN_LINK_COND_NOT_PARSED

FE_SN_READ

Read Traceability objects in Sphinx-Needs

yes

ER_SN_SYN_ER; ER_SN_JSON_NOT_FOUND; ER_SN_JSON_CORRUPTED; ER_SN_SER_AUTH; ER_SN_DATA_INVALID; ER_SN_CODE_ERR; ER_SN_JSON_FILTER; ER_SN_SER_DOWN; ER_SN_SER_INVALID

FE_SN_SCHEMA_VALIDATION

Declarative schema validation of needs

yes

ER_SN_SCHEMA_DISABLED; ER_SN_SCHEMA_INVALID; ER_SN_SCHEMA_SELECT_WRONG; ER_SN_SCHEMA_NOT_REPORTED; ER_SN_SCHEMA_WRONG_SEVERITY; ER_SN_SCHEMA_NETWORK_MISS

FE_SN_SET_META

Assign meta-data to Traceability objects in Sphinx-Needs

yes

ER_SN_DYN_INVALID; ER_SN_DYN_WRONG; ER_SN_META_INVALID; ER_SN_META_NOT_COMPLIANT

FE_SN_TEMPLATE_NEED

Enhance Need content using templates in Sphinx-Needs

yes

ER_SN_TEMPLATE_NEED_FILE_NOT_FOUND; ER_SN_TEMPLATE_NEED_FILE_INVALID; ER_SN_TEMPLATE_NEED_FILE_SYNTAX

FE_SN_TEMPLATE_PAGE

Extend page content with templates in Sphinx-Needs

yes

ER_SN_TEMPLATE_FILE_NOT_FOUND; ER_SN_TEMPLATE_FILE_INVALID; ER_SN_TEMPLATE_FILE_SYNTAX

FE_SN_TYPED_FIELDS

Typed need fields with JSON-Schema validation

yes

ER_SN_TYPED_FIELD_TYPE_MISS; ER_SN_TYPED_FIELD_ENUM_MISS; ER_SN_TYPED_FIELD_RANGE_MISS

FE_SN_TYPED_LINK_SCHEMA

Typed link schemas (cardinality and targeting)

yes

ER_SN_TYPED_LINK_CARD_MISS; ER_SN_TYPED_LINK_TARGET_WRONG

FE_SPHINX_NEEDS_AUTO_ID

Automatic ID generation

yes

ER_SN_ID_GENERATION_FAILED; ER_SN_ID_ALREADY_EXISTS; ER_SN_ID_FORMAT_INVALID; ER_SN_ID_LENGTH_INVALID

FE_SPHINX_NEEDS_CONFIG_FILES

Configuration via conf.py or an external TOML file

no

FE_SPHINX_NEEDS_CONFIG_LAYOUTS

Customizable layouts for need presentation

yes

ER_SN_LAYOUT_INCORRECT_RENDERING; ER_SN_LAYOUT_MISSING_INFO; ER_SN_LAYOUT_INCORRECT_INFO

FE_SPHINX_NEEDS_CUSTOMIZABLE_LINKS

Customizable link types

yes

ER_SN_INVALID_LINK_TYPE; ER_SN_INVALID_LINK_TYPE_VALUE

FE_SPHINX_NEEDS_CUSTOMIZABLE_OPTIONS

Customizable need fields

yes

ER_SN_INVALID_OPTION; ER_SN_INVALID_OPTION_VALUE; ER_SN_OPTION_NOT_ALLOWED

FE_SPHINX_NEEDS_DEFINABLE_TYPES

Definable need types

yes

FE_SPHINX_NEEDS_DIRECTIVE_NEEDBAR

Create a bar chart based on need statistics (needbar)

no

FE_SPHINX_NEEDS_DIRECTIVE_NEEDEXTEND

Modify existing needs in bulk (needextend)

yes

ER_SN_EXTEND_NOT_COMPLETED; ER_SN_EXTEND_FAIL_SILENTLY; ER_SN_EXTEND_NOT_VALID

FE_SPHINX_NEEDS_DIRECTIVE_NEEDFLOW

Render a PlantUML flow diagram of needs (needflow)

no

FE_SPHINX_NEEDS_DIRECTIVE_NEEDIMPORT

Import needs from an external JSON file (needimport)

yes

ER_SN_IMPORT_NOT_COMPLETED; ER_SN_IMPORT_NOT_VALID; ER_SN_IMPORT_NOT_ACCESSIBLE

FE_SPHINX_NEEDS_DIRECTIVE_NEEDPIE

Create a pie chart based on need statistics (needpie)

no

FE_SPHINX_NEEDS_DIRECTIVE_NEEDTABLE

Display needs in a filterable table (needtable)

no

FE_SPHINX_NEEDS_DYNAMIC_CONSTRAINTS

Legacy constraint checking (needs_constraints)

yes

ER_SN_CONSTRAINT_NOT_CHECKED; ER_SN_CONSTRAINT_FAIL_SILENTLY; ER_SN_CONSTRAINT_WRONG_DATA; ER_SN_CONSTRAINT_INCOMPLETE_DATA; ER_SN_CONSTRAINT_INVALID_DATA

FE_SPHINX_NEEDS_EXPORT_JSON

JSON builder to export all need data

yes

ER_SN_EXPORT_JSON_FAIL_SILENTLY; ER_SN_EXPORT_JSON_NOT_VALID; ER_SN_EXPORT_JSON_CORRUPTED

FE_SPHINX_NEEDS_EXPORT_PERMALINKS

Permalink generation to specific need objects

yes

ER_SN_PERMALINK_FAIL_SILENTLY; ER_SN_PERMALINK_NOT_VALID; ER_SN_PERMALINK_NON_EXISTING; ER_SN_PERMALINK_WRONG_NEED

FE_SPHINX_NEEDS_LINKING_BIDIRECTIONAL

Bidirectional link tracking

yes

FE_SPHINX_NEEDS_LINKING_DEAD_LINK_DETECTION

Dead link detection and warnings

yes

ER_SN_DEAD_LINK_NOT_DETECTED; ER_SN_DEAD_LINK_FALSE_POSITIVE

FE_SPHINX_NEEDS_LINKING_DIRECT

Direct linking between needs using IDs

yes

ER_SN_LINK_TARGET_NOT_FOUND; ER_SN_LINK_TARGET_NOT_VALID

FE_SPHINX_NEEDS_MANUAL_ID

Manual ID assignment

yes

ER_SN_MANUAL_ID_EXISTS; ER_SN_MANUAL_ID_FORMAT_INVALID; ER_SN_MANUAL_ID_LENGTH_INVALID

FE_SPHINX_NEEDS_NEED_PARTS

In-content need parts for granular references

yes

FE_SPHINX_NEEDS_STATUS_ENFORCEMENT

Need status enforcement

yes

ER_SN_INVALID_STATUS

FE_SPHINX_NEEDS_TAGGING

Tagging support

yes

FE_SPHINX_NEEDS_UNIQUE_ID_ENFORCEMENT

Unique ID enforcement and checks

yes

ER_SN_DUPLICATE_ID

../../_images/need_pie_54381.svg
Feature: Read Traceability objects in Sphinx-Needs FE_SN_READ

Read Traceability objects from rst/md files into the internal storage.

Fault: Syntax errors in rst/md files cause Traceability objects to be ignored ER_SN_SYN_ER
style: red_bar
parent needs: FE_SN_READ
Fault: Missing external needs.json file ER_SN_JSON_NOT_FOUND
style: red_bar
parent needs: FE_SN_READ
Fault: Corrupted external needs.json file ER_SN_JSON_CORRUPTED
style: red_bar
parent needs: FE_SN_READ
Fault: Authentication issues with needsservice ER_SN_SER_AUTH
style: red_bar
parent needs: FE_SN_READ
Fault: Invalid meta-data in rst/md files leads to ignored Traceability objects ER_SN_DATA_INVALID
style: red_bar
avoided by: RE_SN_WARNINGS
parent needs: FE_SN_READ
Fault: Programmatic errors in rst/md files result in ignored Traceability objects ER_SN_CODE_ERR
style: red_bar
parent needs: FE_SN_READ
Fault: Invalid or incorrect filters used for external needs.json ER_SN_JSON_FILTER
style: red_bar
parent needs: FE_SN_READ
Fault: External service unreachable by needsservice ER_SN_SER_DOWN
style: red_bar
parent needs: FE_SN_READ
Fault: needsservice unable to process data from external service ER_SN_SER_INVALID
style: red_bar
parent needs: FE_SN_READ
Feature: Display Traceability objects content in Sphinx-Needs FE_SN_CONTENT_RENDER
style: green_bar
si: yes
featured by: UC_SW_REQ
tools: TOOL_SN
Fault: Content contains syntax errors ER_SN_CONTENT_SYNTAX
style: red_bar
parent needs: FE_SN_CONTENT_RENDER
Feature: Assign meta-data to Traceability objects in Sphinx-Needs FE_SN_SET_META
style: green_bar
si: yes
Fault: Dynamic functions return invalid meta-data ER_SN_DYN_INVALID
style: red_bar
avoided by: CHECK_SN_NO_DYN
parent needs: FE_SN_SET_META
Fault: Dynamic functions return wrong meta-data ER_SN_DYN_WRONG
style: red_bar
avoided by: CHECK_SN_NO_DYN
parent needs: FE_SN_SET_META

Internal dynamic functions are checked by test-cases in Sphinx-Needs itself.

But self-written dynamic functions can do whatever they want, as long as the returned data ist still valid (but may be wrong).

So self-written dynamic functions need test cases as well!

Fault: Sphinx-Needs data not valid ER_SN_META_INVALID
style: red_bar
parent needs: FE_SN_SET_META
Fault: Sphinx-Needs data is not process-compliant ER_SN_META_NOT_COMPLIANT
style: red_bar
parent needs: FE_SN_SET_META
Feature: Generate object representation in Sphinx-Needs FE_SN_DOCTREE
style: green_bar
si: yes
Fault: Meta-data missing ER_SN_LAY_META_MIS
style: red_bar
parent needs: FE_SN_DOCTREE

Needed meta-data is not part of the final representation in the doctree and so later HTML/PDF build

Fault: Wrong meta-data is used ER_SN_LAY_META_WRONG
style: red_bar
parent needs: FE_SN_DOCTREE

Sphinx-Needs is adding wrong Meta-Data to the final doctree-layout

Feature: Export needs.json file using Sphinx-Needs FE_SN_JSON
style: green_bar
si: yes
Fault: Objects missing in needs.json ER_SN_JSON_MIS
style: red_bar
parent needs: FE_SN_JSON
Fault: Traceability objects meta-data corrupted ER_SN_JSON_COR
style: red_bar
parent needs: FE_SN_JSON
Fault: Traceability objects content corrupted ER_SN_JSON_CONTENT_COR
style: red_bar
parent needs: FE_SN_JSON

Dynamic Content

Feature: Apply dynamic functions for meta-data computation FE_SN_DYN_FUNC
style: green_bar
si: yes
Fault: Function gets not executed ER_SN_DYN_NO_EXEC
style: red_bar
parent needs: FE_SN_DYN_FUNC

The function gets not executed and in the generated documentation the dynamic-function string can be found.

Fault: Function returns invalid value ER_SN_DYN_INVALID2
style: red_bar
parent needs: FE_SN_DYN_FUNC

Function returns a technically not allowed value.

Fault: Function returns wrong calculated values ER_SN_DYN_WRONG_CALC
style: red_bar
parent needs: FE_SN_DYN_FUNC

The dynamic functions calculates wrong values

Fault: Function returns no value ER_SN_DYN_NO_VALUE
style: red_bar
parent needs: FE_SN_DYN_FUNC

The dynamic function does not return a value, so the meta-data is not set.

Feature: Extend page content with templates in Sphinx-Needs FE_SN_TEMPLATE_PAGE
Fault: Template file not found ER_SN_TEMPLATE_FILE_NOT_FOUND
style: red_bar
parent needs: FE_SN_TEMPLATE_PAGE

The template file is not found in the Sphinx-Needs templates directory.

Fault: Template file is not a valid Jinja2 template ER_SN_TEMPLATE_FILE_INVALID
style: red_bar
parent needs: FE_SN_TEMPLATE_PAGE

The template file is not a valid Jinja2 template, so it cannot be processed by Sphinx-Needs.

Fault: Template file contains syntax errors ER_SN_TEMPLATE_FILE_SYNTAX
style: red_bar
parent needs: FE_SN_TEMPLATE_PAGE

The template file contains syntax errors and cannot be processed by Sphinx-Needs.

Feature: Enhance Need content using templates in Sphinx-Needs FE_SN_TEMPLATE_NEED
Fault: Template file not found ER_SN_TEMPLATE_NEED_FILE_NOT_FOUND
style: red_bar
parent needs: FE_SN_TEMPLATE_NEED

The template file is not found in the Sphinx-Needs templates directory.

Fault: Template file is not a valid Jinja2 template ER_SN_TEMPLATE_NEED_FILE_INVALID
style: red_bar
parent needs: FE_SN_TEMPLATE_NEED

The template file is not a valid Jinja2 template, so it cannot be processed by Sphinx-Needs.

Fault: Template file contains syntax errors ER_SN_TEMPLATE_NEED_FILE_SYNTAX
style: red_bar
parent needs: FE_SN_TEMPLATE_NEED

The template file contains syntax errors and cannot be processed by Sphinx-Needs.

Core Need Object

Feature: Definable need types FE_SPHINX_NEEDS_DEFINABLE_TYPES
style: green_bar
si: yes
tools: TOOL_SN

Allows the definition of custom need types beyond the built-in ones. Each type gets its own directive, title, and color for easy identification in diagrams.

# In conf.py
needs_types = [
    dict(directive="req", title="Requirement", prefix="R_", color="#BFD8D2"),
    dict(directive="spec", title="Specification", prefix="S_", color="#FEDCD2"),
    dict(directive="test", title,"Test Case", prefix="T_", color="#DCFED2"),
]
Feature: Customizable need fields FE_SPHINX_NEEDS_CUSTOMIZABLE_OPTIONS
style: green_bar
si: yes

Define extra fields that any need object can have, such as author or component. Custom fields can be displayed in tables, used for filtering, and (since Sphinx-Needs 7) validated by an attached JSON Schema.

The legacy list-style needs_extra_options configuration is deprecated; declarative needs_fields ([needs.fields.<name>] in ubproject.toml) is the supported form.

# In ubproject.toml
[needs.fields.author]
description = "Author of the need"
schema.type = "string"

[needs.fields.component]
description = "Logical sub-system the need belongs to"
schema.type = "string"
schema.enum = ["UI", "Backend", "Database"]
.. req:: A specific requirement
   :id: R_001
   :author: John Doe
   :component: UI
Fault: Invalid field used in a need ER_SN_INVALID_OPTION
style: red_bar

A field that is not defined in needs_fields is used in a directive. Sphinx-Needs raises a warning during the build.

Fault: Field value does not match declared schema ER_SN_INVALID_OPTION_VALUE
style: red_bar

A field value does not match the declared schema.type, schema.enum, schema.minimum / maximum or schema.pattern. Sphinx-Needs emits a sn_schema_violation during the build.

Fault: Field value is not allowed ER_SN_OPTION_NOT_ALLOWED
style: red_bar

A field value is not part of the allowed schema.enum list. Without schema validation the wrong value silently reaches the exported needs.json and downstream analysis.

Feature: Automatic ID generation FE_SPHINX_NEEDS_AUTO_ID

Sphinx-Needs can automatically generate a unique ID for any need that does not have one. The format of the ID can be configured using a prefix and a specific length.

.. req:: This requirement will get an ID automatically.
   :tags: auto_id
Fault: ID generation failed ER_SN_ID_GENERATION_FAILED
style: red_bar

If the automatic ID generation fails, Sphinx-Needs will raise an error during the build process.

Fault: ID already exists ER_SN_ID_ALREADY_EXISTS
style: red_bar

If the generated ID already exists in the project, Sphinx-Needs will raise an error during the build process.

Fault: ID format is invalid ER_SN_ID_FORMAT_INVALID
style: red_bar

If the generated ID does not match the expected format, Sphinx-Needs will raise an error during the build process.

Fault: ID length is invalid ER_SN_ID_LENGTH_INVALID
style: red_bar

If the generated ID does not match the expected length, Sphinx-Needs will raise an error during the build process.

Feature: Manual ID assignment FE_SPHINX_NEEDS_MANUAL_ID

Allows for setting a specific, human-readable ID for a need. This is useful for referencing important requirements easily.

.. req:: A requirement with a specific ID
   :id: R_IMPORTANT_FEATURE
Fault: Manual ID already exists ER_SN_MANUAL_ID_EXISTS
style: red_bar

If a manually set ID already exists in the project, Sphinx-Needs will raise an error during the build process.

Fault: Manual ID format is invalid ER_SN_MANUAL_ID_FORMAT_INVALID
style: red_bar

If a manually set ID does not match the expected format, Sphinx-Needs will raise an error during the build process.

Fault: Manual ID length is invalid ER_SN_MANUAL_ID_LENGTH_INVALID
style: red_bar

If a manually set ID does not match the expected length, Sphinx-Needs will raise an error during the build process.

Feature: Need status enforcement FE_SPHINX_NEEDS_STATUS_ENFORCEMENT
style: green_bar
si: yes
tools: TOOL_SN

You can define a list of allowed statuses for needs. If a need uses a status that is not on the list, Sphinx will raise a warning during the build.

# In conf.py
needs_statuses = [
    ('open', 'Is still open'),
    ('in_progress', 'Work in progress'),
    ('closed', 'Is closed'),
    ('rejected', 'Will not be implemented'),
]
Fault: Invalid status used in a need ER_SN_INVALID_STATUS
style: red_bar

If a need uses a status that is not defined in the configuration, Sphinx-Needs will raise an error during the build process.

Feature: Tagging support FE_SPHINX_NEEDS_TAGGING
style: green_bar
si: yes
tools: TOOL_SN

Assign one or more tags to a need for categorization and filtering. Tags help in organizing needs and creating specific views or reports.

.. spec:: A specification for the login system
   :id: S_LOGIN
   :tags: ui, security
Feature: In-content need parts for granular references FE_SPHINX_NEEDS_NEED_PARTS
style: green_bar
si: yes
tools: TOOL_SN

Create references to specific sentences or parts inside a need’s content. This allows for very precise linking and traceability.

.. req:: User Authentication
   :id: R_AUTH

   The user must be able to log in via a username and password.
   The password must be stored securely. :np:`secure_storage`

.. test:: Test secure password storage
   :id: T_SECURE_STORAGE
   :links: R_AUTH.secure_storage
Feature: Unique ID enforcement and checks FE_SPHINX_NEEDS_UNIQUE_ID_ENFORCEMENT
style: green_bar
si: yes
tools: TOOL_SN
child needs: ER_SN_DUPLICATE_ID

Sphinx-Needs automatically checks if all manually set IDs are unique across the project. The build will fail if a duplicate ID is found, ensuring data consistency.

Fault: Duplicate ID is not detected ER_SN_DUPLICATE_ID
style: red_bar

If a duplicate ID is not detected, it may lead to incorrect traceability and data integrity issues.

Directives for Creating & Displaying Needs

Feature: Display needs in a filterable table (needtable) FE_SPHINX_NEEDS_DIRECTIVE_NEEDTABLE
style: green_bar
si: no
tools: TOOL_SN

Renders a table of needs based on specified filters. The table columns can be customized to show different need options like status or outgoing links.

.. needtable::
   :tags: ui
   :status: open
   :columns: id, title, status, links
Feature: Render a PlantUML flow diagram of needs (needflow) FE_SPHINX_NEEDS_DIRECTIVE_NEEDFLOW
style: green_bar
si: no
tools: TOOL_SN

Generates a flowchart that visualizes the relationships between filtered needs. This is excellent for showing process flows or dependencies.

.. needflow::
   :tags: login_flow
   :show_legend:
Feature: Create a pie chart based on need statistics (needpie) FE_SPHINX_NEEDS_DIRECTIVE_NEEDPIE
style: green_bar
si: no
tools: TOOL_SN

Generates a pie chart from need data, for instance, to show the distribution of statuses. This provides a quick visual summary of the project’s state.

.. needpie:: Requirements Status
   :content: status
   :legend:
Feature: Create a bar chart based on need statistics (needbar) FE_SPHINX_NEEDS_DIRECTIVE_NEEDBAR
style: green_bar
si: no
tools: TOOL_SN

Generates a bar chart to visualize need data. This is useful for comparing counts across different categories, such as components.

.. needbar:: Needs per Component
   :x_option: component
   :x_labels: UI, Backend, Database
Feature: Import needs from an external JSON file (needimport) FE_SPHINX_NEEDS_DIRECTIVE_NEEDIMPORT

Import need objects from an external needs.json file. This allows for sharing and reusing requirements across different Sphinx projects.

.. needimport:: ../../shared/output/needs.json
Fault: Importing needs is not completed ER_SN_IMPORT_NOT_COMPLETED
style: red_bar

If the import process is not completed, it may lead to missing or incomplete data in the project.

Fault: Importing needs is not valid ER_SN_IMPORT_NOT_VALID
style: red_bar

If the imported data is not valid, it may lead to errors in the documentation or incorrect traceability.

Fault: Importing needs is not accessible ER_SN_IMPORT_NOT_ACCESSIBLE
style: red_bar

If the imported file is not accessible, it may lead to errors in the documentation or missing data.

Feature: Modify existing needs in bulk (needextend) FE_SPHINX_NEEDS_DIRECTIVE_NEEDEXTEND

Modifies multiple needs at once based on a filter. You can add tags, change the status, or set any other option for all filtered needs.

.. needextend:: status == 'in_progress'
   :add_tags: sprint_5
Fault: Bulk modification of needs is not completed ER_SN_EXTEND_NOT_COMPLETED
style: red_bar

If the bulk modification process is not completed, it may lead to missing or incomplete data in the project.

Fault: Bulk modification failes silently ER_SN_EXTEND_FAIL_SILENTLY
style: red_bar

If the bulk modification fails silently, it may lead to missing or incomplete data in the project without any error message.

Fault: Bulk modification of needs is not valid ER_SN_EXTEND_NOT_VALID
style: red_bar

If the bulk modification is not valid, it may lead to errors in the documentation or incorrect traceability.

Linking and Traceability

Feature: Direct linking between needs using IDs FE_SPHINX_NEEDS_LINKING_DIRECT
style: green_bar
si: yes

Create links between needs by referencing their unique IDs in link options. This forms the basis of all traceability in Sphinx-Needs.

.. spec:: Defines how the login button works.
   :id: S_LOGIN_BUTTON

.. req:: The login button must be blue.
   :id: R_LOGIN_COLOR
   :links: S_LOGIN_BUTTON
Feature: Bidirectional link tracking FE_SPHINX_NEEDS_LINKING_BIDIRECTIONAL
style: green_bar
si: yes
tools: TOOL_SN

When you link from need A to need B, Sphinx-Needs automatically knows about the incoming link on need B. This allows for full, bidirectional traceability without extra work.

Automated Features

Feature: Legacy constraint checking (needs_constraints) FE_SPHINX_NEEDS_DYNAMIC_CONSTRAINTS

Warning

needs_constraints is the legacy mechanism to validate need data through Python check-code strings. Since Sphinx-Needs 7 it is superseded by Declarative schema validati... (FE_SN_SCHEMA_VALIDATION) (JSON-Schema based) which is declarative, cacheable, and auditable. New classifications should not rely on needs_constraints.

Define rules about your need data that are checked during the build. For example, you can enforce that every requirement must be linked to a test case.

# Legacy form in conf.py (avoid for new projects)
needs_constraints = {
    "req_verified": {
        "check_code": "len(links_back['verifies']) > 0",
        "severity": "fault",
        "filter": "'req' in tags"
    }
}
Fault: Constraint not checked during build ER_SN_CONSTRAINT_NOT_CHECKED
style: red_bar

If a constraint is not checked during the build, it may lead to missing or incorrect traceability data.

Fault: Constraint check fails silently ER_SN_CONSTRAINT_FAIL_SILENTLY
style: red_bar

If a constraint check fails silently, it may lead to missing or incorrect traceability data without any error message.

Fault: Constraint check runs with wrong data ER_SN_CONSTRAINT_WRONG_DATA
style: red_bar

If a constraint check runs with wrong data, it may lead to incorrect traceability data and errors in the documentation.

Fault: Constraint check runs with incomplete data ER_SN_CONSTRAINT_INCOMPLETE_DATA
style: red_bar

If a constraint check runs with incomplete data, it may lead to missing or incorrect traceability data and errors in the documentation.

Fault: Constraint check runs with invalid data ER_SN_CONSTRAINT_INVALID_DATA
style: red_bar

If a constraint check runs with invalid data, it may lead to errors in the documentation or incorrect traceability.

Feature: Declarative schema validation of needs FE_SN_SCHEMA_VALIDATION

Introduced with Sphinx-Needs 7 and hardened in 8.0, schema validation expresses data rules declaratively using a JSON-Schema derived format. Rules are defined once, evaluated per build, and produce structured diagnostics that downstream tools (ubCode, ubc schema validate, CI) can consume.

A schema object consists of three parts:

  • select — which needs the rule applies to (types, fields, combinations).

  • validate.local — property constraints on a single need (type, enum, pattern, min / max, required).

  • validate.network — cross-need constraints along link types (contains, minContains, maxContains), enabling traceability completeness checks (e.g. “every safe feature must have at least one test”).

  • severityviolation (build fails), warning or info.

Safety-critical projects (ISO 26262, IEC 61508, EN 50716) use the violation severity to make an incomplete classification reject the build.

# In ubproject.toml
schema_definitions_from_json = "schemas.json"
schema_debug_active = true
{
  "$defs": {
    "type-feature": { "properties": { "type": { "const": "feature" } } },
    "safe-feature": {
      "allOf": [
        { "$ref": "#/$defs/type-feature" },
        { "properties": { "si": { "const": "yes" } },
          "required": ["si"] }
      ]
    }
  },
  "schemas": [
    {
      "id": "safe-feature-has-fault",
      "severity": "violation",
      "message": "A safety-impacting feature must raise at least one fault",
      "select": { "$ref": "#/$defs/safe-feature" },
      "validate": {
        "network": {
          "raises": { "contains": { "local": {} }, "minContains": 1 }
        }
      }
    }
  ]
}
Fault: Schema validation silently disabled ER_SN_SCHEMA_DISABLED
style: red_bar

needs_schema_validation_enabled is set to False (or implicitly disabled by a configuration error) without the project being aware. Safety-relevant rules are not enforced during the build.

Fault: Schema definition itself is invalid ER_SN_SCHEMA_INVALID
style: red_bar

The supplied needs_schema_definitions (or external schema_definitions_from_json) does not conform to the JSON-Schema dialect accepted by Sphinx-Needs. Rules are not evaluated and the project silently loses validation coverage.

Fault: Schema ``select`` does not match the intended needs ER_SN_SCHEMA_SELECT_WRONG
style: red_bar

The select filter of a rule is too narrow or too broad, so the rule either misses safety-relevant needs (false negative) or fires on unrelated needs (false positive).

Fault: Schema violation not surfaced in build ER_SN_SCHEMA_NOT_REPORTED
style: red_bar

A failing schema rule does not produce a user-visible warning or error (e.g. because the category is listed in suppress_warnings or -W is not used). The build appears green although safety rules are violated.

Fault: Schema violation wrongly suppressed via severity ER_SN_SCHEMA_WRONG_SEVERITY
style: red_bar

A rule is declared with severity = "info" or "warning" although it encodes a safety-relevant invariant. The violation does not fail the build.

Fault: Network validation misses indirect links ER_SN_SCHEMA_NETWORK_MISS
style: red_bar

A validate.network rule expects linkage via a specific needs.links.<name>, but the project uses a different link option for the same semantic relation, so the check silently passes with zero matches.

Feature: Typed need fields with JSON-Schema validation FE_SN_TYPED_FIELDS

Each custom field declared via [needs.fields.<name>] can carry a schema block (type, enum, minimum / maximum, pattern, format) and a nullable flag. Value mismatches are reported as sn_schema_violation warnings and written to schema_violations.json in the build output.

This is the type-safe successor to the untyped string list form of needs_extra_options.

[needs.fields.asil]
description = "Automotive Safety Integrity Level (ISO 26262)"
schema.type = "string"
schema.enum = ["QM", "A", "B", "C", "D"]

[needs.fields.efforts]
description = "FTE days"
schema.type = "integer"
schema.minimum = 0
schema.maximum = 100
Fault: Schema type mismatch not detected ER_SN_TYPED_FIELD_TYPE_MISS
style: red_bar
avoided by: RE_SN_TYPE_FIELDS
parent needs: FE_SN_TYPED_FIELDS

An integer-typed field receives a non-numeric value but the violation is not reported (e.g. schema validation disabled or category suppressed).

Fault: Enum constraint not enforced ER_SN_TYPED_FIELD_ENUM_MISS
style: red_bar
avoided by: RE_SN_TYPE_FIELDS
parent needs: FE_SN_TYPED_FIELDS

A value outside the declared schema.enum list is accepted silently, so an invalid ASIL / TCL value reaches the exported needs.json.

Fault: Range constraint not enforced ER_SN_TYPED_FIELD_RANGE_MISS
style: red_bar
avoided by: RE_SN_TYPE_FIELDS
parent needs: FE_SN_TYPED_FIELDS

A value violates schema.minimum / schema.maximum but is accepted. Safety metrics derived from this field are wrong.

Configuration & Customization

Feature: Configuration via conf.py or an external TOML file FE_SPHINX_NEEDS_CONFIG_FILES
style: green_bar
si: no
tools: TOOL_SN

All Sphinx-Needs options can be configured in the main conf.py file. For large configurations, you can also use an external needs.toml file to keep things organized.

Feature: Customizable layouts for need presentation FE_SPHINX_NEEDS_CONFIG_LAYOUTS

Change the visual presentation of needs by defining custom layouts. You can reorder options, use grids, and change how information is displayed.

# In conf.py
needs_layouts = {
    'my_layout': {
        'grid': 'simple_side_right',
        'layout': {
            'side': ['id', 'status', 'tags', 'links']
        }
    }
}
Fault: Layout leads to incorrect rendering ER_SN_LAYOUT_INCORRECT_RENDERING
style: red_bar

If a layout leads to incorrect rendering, it may cause confusion in the documentation and make it hard to read.

Fault: Layout leads to missing information ER_SN_LAYOUT_MISSING_INFO
style: red_bar

If a layout leads to missing information, it may cause confusion in the documentation and make it hard to read.

Fault: Layout leads to incorrect information ER_SN_LAYOUT_INCORRECT_INFO
style: red_bar

If a layout leads to incorrect information, it may cause confusion in the documentation and make it hard to read.

Exporting & Reporting

Feature: JSON builder to export all need data FE_SPHINX_NEEDS_EXPORT_JSON

Export all need objects and their relationships into a structured needs.json file. This file can be used for external analysis, reporting, or imported into other Sphinx projects.

sphinx-build -b needs . _build
Fault: Exporting needs.json fails silently ER_SN_EXPORT_JSON_FAIL_SILENTLY
style: red_bar

If the export fails silently, it may lead to missing or incomplete data in the project without any error message.

Fault: Exported needs.json file is not valid ER_SN_EXPORT_JSON_NOT_VALID
style: red_bar

If the exported needs.json file is not valid, it may lead to errors in the documentation or incorrect traceability.

Fault: Exported needs.json file is corrupted ER_SN_EXPORT_JSON_CORRUPTED
style: red_bar

If the exported needs.json file is corrupted, it may lead to errors in the documentation or incorrect traceability.