ReqIF¶
The ReqIF (Requirements Interchange Format) is a standard XML format to exchange requirements between different tools.
ubConnect supports two directions of ReqIF exchange with Sphinx-Needs:
Exporting Sphinx-Needs to ReqIF using command
reqif to-reqifImporting ReqIF to Sphinx-Needs using command
reqif from-reqif
Details for these commands can be found under Usage.
Exchanges needs with a tool through |
Round-Trip Conversion¶
ubConnect aims to support round-trip conversion between Sphinx-Needs and ReqIF. This means that requirements can be exported from Sphinx-Needs to ReqIF format
and then imported back to Sphinx-Needs without losing any information. To achieve this, it is essential to configure both export and import processes correctly,
especially the field mappings.
Caution
The main purpose of the round-trip conversion is to link the requirements managed in Sphinx-Needs with external ALM tools that support ReqIF instead of modifying the requirements on both sides.
The modification of requirements shall be done in their corresponding tools, either Sphinx-Needs or the ALM tool, depending on the defined single source of truth.
To achieve this, ubConnect provides the configuration origin_field to track requirement’s source of the truth in a dedicated field during both export and import processes.
For example, a typical scenario could be:
System requirements are defined and managed in an ALM tool that supports ReqIF import/export and the ALM tool is the single source of truth for System requirements.
Software requirements are defined and managed in Sphinx-Needs within the project’s documentation and Sphinx-Needs is the single source of truth for Software requirements.
Users want to link Software requirements in Sphinx-Needs to System requirements in the ALM tool in the Sphinx-Needs project.
In this case, users can export the existing System requirements from the ALM tool to ReqIF format,
then convert them into needs.json using the reqif from-reqif command to import into the Sphinx-Needs project.
During this conversion, ubConnect records each requirement’s single source of truth in a dedicated field (e.g., origin).
This allows ubConnect to identify which requirements originated from the ALM tool when exporting back to ReqIF later,
ensuring that only Software requirements (managed in Sphinx-Needs) are exported while preserving the System requirements as reference links.
After that, users can define Software requirements in Sphinx-Needs and create links to the imported System requirements.
Finally, users can export all Software requirements from Sphinx-Needs to ReqIF format using reqif to-reqif command,
which can then be imported back into the ALM tool, preserving the links between Software and System requirements.
Round-trip fidelity¶
Tip
For a lossless round trip of an export (unchanged needs give a byte-identical
ReqIF, changed needs exactly their changes), use the update mode of
to-reqif: Updating the original export (update mode). The keys below build a new ReqIF file
instead.
The default round-trip (ReqIF → from-reqif → needs.json → to-reqif → ReqIF')
preserves content but loses three structural properties: original
SPEC-OBJECT-TYPE typing, original SPEC-HIERARCHY nesting, and
heading-versus-content distinctions.
Five opt-in TOML keys plus one cross-cutting flag let you preserve them. All default off — pre-existing configurations produce unchanged output.
Step 1 — make from-reqif emit identity fields:
[ubconnect.from_reqif]
preserve_source_type = true # adds `source_type` to every need
preserve_hierarchy = true # adds `parents` (JSON ancestor ID list)
These flags also cause from-reqif to emit needs_schema in
needs.json (matching doors_ng2needs and github2needs),
which downstream to-reqif requires.
Step 2 — make to-reqif consume them:
[ubconnect.to_reqif]
type_field = "source_type" # discriminate by this need field
hierarchy_field = "parents" # build SPEC-HIERARCHY from this list
section_types = ["Heading"] # these source-types are sections,
# not separate spec-objects
export_external_needs = true # re-emit External-origin needs
Step 3 — define per-source-type SPEC-OBJECT-TYPE structure:
[[ubconnect.to_reqif.object_types]]
filter_value = "Requirement" # matches need.source_type
name = "Requirement" # optional LONG-NAME override
[ubconnect.to_reqif.object_types.mapping.id]
source_field = "id"
target_attribute = "ReqIF.ForeignID"
datatype = "string"
# ...repeat for each Requirement attribute
[[ubconnect.to_reqif.object_types]]
filter_value = "Heading"
[ubconnect.to_reqif.object_types.mapping.title]
source_field = "title"
target_attribute = "ReqIF.ChapterName"
datatype = "xhtml"
Per-type mapping blocks replace (not extend) the global
[ubconnect.to_reqif.mapping]: a field they do not list uses its field
name. An explicit mapping = {} means “no overrides — use field names
verbatim”. A per-type entry without target_attribute (e.g. one that only
sets is_editable) keeps the global entry’s target and overrides only the
keys it sets.
Validation:
object_typesandsection_typesboth requiretype_field.group_typesandtype_fieldare mutually exclusive.Every need must carry a value for the configured
type_field; otherwiseto-reqifexits with a clear error.A non-section need linking to a section-type need fails the run (silent loss of cross-references is a data hazard).
Updating the original export (update mode)¶
When the needs came from a ReqIF export (from-reqif) and the changes have to go back
to the tool that exported it, to-reqif can update that export instead of building a
new ReqIF file. The original file (the base) stays the source of everything the needs do
not show: identifiers, header, TOOL-EXTENSIONS, datatypes and object types, attributes
the import left out, DOORS table objects, picture natives and relation groups.
[ubconnect.from_reqif] # the import configuration, unchanged
reqif_path = "export.reqifz"
# ...
[ubconnect.to_reqif]
base = "export.reqifz" # switches to-reqif to the update mode
removed_needs = "keep" # "keep" (default) or "delete"
ubconnect reqif to-reqif _build/html/needs.json --config ubproject.toml \
--outpath export_updated.reqifz --reqifz
to-reqif runs the [ubconnect.from_reqif] pipeline on the base, compares the result
with the needs and writes back only the differences. When nothing changed, the output is
a byte-identical copy of the base. The way back is derived from [ubconnect.from_reqif];
[ubconnect.to_reqif] keys such as mapping, type_field or section_types are not
used in this mode.
What is written back:
Change in the needs |
Change in the ReqIF |
|---|---|
Text of a need (RST, also the |
|
A picture the RST shows for the first time |
Added to the |
The caption of a |
The |
A cell of a DOORS table ( |
The |
A prose paragraph inside a need’s text ( |
The prose object. ubConnect writes such paragraphs as
|
Mapped and pass-through fields |
The attribute the field came from, with its datatype (enumeration values by name). |
|
The |
Link fields |
|
Parent need |
The object moves in the |
A need without ReqIF identifier |
A new |
A need that is missing |
Kept and reported ( |
Never written back: the ID and fields that come from the ID attribute, bookkeeping fields
(uuid_target, origin_field, source_type, parents, the section path), static
fields, fields computed by Sphinx-Needs / ubc, generated titles
([ubconnect.from_reqif.title]), and a text that mixes a .. raw:: html block with
other text (write it all as RST, or all inside the block). Each skipped change is reported. Settings of a
[[ubconnect.from_reqif.specifications]] entry (mapping, content, title, links, static
fields) apply to the objects of that specification on the way back as well.
Options:
base/--base: the export. A command-line path is relative to the current directory.--id-prefix: the--id-prefixthe import used, if it was given on the command line. When the IDs of the needs do not match what[ubconnect.from_reqif]gives the base,to-reqifstops with an error instead of treating every need as new.--check: write nothing; exit with1when the needs differ from the base, when a change could not be written back or when needs of the base are missing. Use it in CI after the documentation build to prove that the RST is a lossless image of the export.Several
needs.jsonfiles are accepted, e.g. one per specification of the JSON output. A specification without any need in them (e.g. afterfrom-reqif --spec) is left unchanged.ubc’s
needs.json(no top-levelcreated, nullable field types, nested needs both separate and inside their parent’s content) and ubConnect’s ownneeds.jsonare both read as they are.
Not written back (documented limits):
Free-standing DOORS tables and prose paragraphs (directly in a chapter, not inside a need) are not needs, so changes to them are not detectable in
needs.json.Moving a need to another chapter without changing its parent need, renaming a chapter, the order among siblings, and new or removed table rows and columns; prose paragraphs added to or removed from a need’s text. Chapter moves and renames are reported, so
--checkfails.:need:references to needs that were no link in the export become plain text (reported).
Sphinx-Needs to ReqIF¶
Configuration Overview¶
The reqif to-reqif command uses a flexible configuration system to map Sphinx-Needs fields
to ReqIF attributes. This allows adapting generated ReqIF files to different ALM tools.
The configuration consists of three main components:
Path Settings: Where to find and store files
Field Mappings: How Sphinx-Needs fields map to ReqIF attributes
Configurations can be provided in two ways:
TOML Configuration File: Define settings in a
TOMLfile under the section[ubconnect.to_reqif]. Relative paths in the TOML file are resolved relative to the TOML file’s location.CLI Arguments and Options: Specify settings via CLI arguments and options. Note that mapping-related configurations can only be defined in the TOML file. Relative paths given as CLI arguments are resolved relative to the current working directory.
Basic Configuration¶
[ubconnect.to_reqif]
# --- Input/Output Paths ---
needsjson_path = "./relative/path/to/need.json" # Path to needs.json (relative to this TOML file)
outpath = "." # Output .reqif(z) file path (optional)
# --- Specification Metadata ---
name = "Custom Specification Name" # ReqIFSpecification name (default: "Needs")
prefix = "all" # Specification prefix (default: "all")
group_types = false # Group by need types (default: false)
reqifz = false # Export as .reqifz (default: false)
# --- Identification & Origin ---
uuid_source = "reqif_uuid" # Source for the UUID of ReqIF Spec-Object (default: "reqif_uuid")
origin_field = "origin" # Field to track the origin of the requirement (default: "origin")
alm_tool = "codebeamer" # Target ALM tool: "doors" or "codebeamer" (default: "codebeamer")
# --- Advanced Features ---
weblink_pattern = "https://docs.example.com/{docname}.html#{id}"
# Generates a weblink template variable AND a dedicated weblink XHTML attribute on each SPEC-OBJECT
editlink_pattern = "https://github.com/org/repo/edit/main/{docname}.rst#L{lineno}"
# Pattern for generating an editlink attribute for each need
import_date = true # Add an import_date field to each exported requirement (default: false)
hierarchy_is_editable = true # IS-EDITABLE="true" on every SPEC-HIERARCHY entry (default: false)
# --- Rendered HTML content export (optional) ---
html_dir = "./_build/html" # Root dir of Sphinx HTML build output; enables HTML content extraction
target_image_dir = "images" # Directory name inside ReqIFz for embedded images (requires reqifz=true)
needsjson_path: Path to theneeds.jsonfile to consume as the input.
Note
needsjson_path must be provided either through the CLI argument or in the TOML configuration file.
outpath: The path to the output.reqifor.reqifzfile (optional, defaults toneeds.reqif(z)in the same directory as the TOML configuration file).name: The long name of theReqIFSpecification(optional, defaults to “Needs”).prefix: The prefix for theReqIfSpecification(default: “all”). Ifgroup_typesis enabled, the value will be the Sphinx-Needs type name.group_types: Group needs by their types into multipleReqIfSpecificationsif set to true; otherwise, all needs are grouped into a singleReqIfSpecification(default: false).
Note
prefix and group_types are related. If group_types is enabled, the prefix will be set to the Sphinx-Needs type name automatically.
If group_types is disabled, the prefix can be specified to the preferred string.
reqifz: Export as.reqifz(zipped) if set to true; otherwise, export as plain XML file.reqif(default: false).uuid_source: The source of the UUID for the ReqIF Spec-Object. It can be set to any Sphinx-Needs field name. If the specified field exists in a need, its value will be used as the UUID; otherwise, the need’s ID will be used as the identifier. This is useful to apply the preserved UUIDs to the generated ReqIF Spec-Object, as the requirements in the ReqIF file can be consistently identified across multiple import/export cycles.origin_field: The field to track the origin of the requirement. It can be set to any Sphinx-Needs field name (default: “origin”). During conversion, if a need has this field defined and its value isExternal, the need will be considered as originating from an external source (e.g., an ALM tool such codebeamer or IBM Doors). If a need does not have this field at all, it will be added and set toSphinx-Needsautomatically during the conversion.Note
The value of this field is either
Sphinx-NeedsorExternal(case-insensitive) set by ubConnect. By default, needs withExternalare treated as references from upstream systems and skipped on export. Set[ubconnect.to_reqif] export_external_needs = trueto re-emit them — required for round-trip pipelines that re-export the same ReqIF after import.alm_tool: The target ALM (Application Lifecycle Management) tool (default: “codebeamer”). Accepts either “doors” or “codebeamer”. Different ALM tools may require different field mappings and section configurations. This setting determines:Default attribute mappings (e.g., title field mapping)
Default section configuration (section type and attributes)
See ALM Tool Configuration for details on ALM-specific defaults.
weblink_pattern: (Optional) A URL pattern that produces two independent outputs for each exported need. The placeholders{docname}and{id}must be used.A
{weblink}MiniJinja template variable available to alltemplate-mapped fields on the same connector. Reference it asweblinkinside any MiniJinja template string on the sameto-reqifconnector.A dedicated
weblinkReqIF attribute (XHTML datatype, rendered as a clickable<a href>link) that is auto-added to every SPEC-OBJECT whose need has adocname. Needs without adocnameare skipped and logged as a warning. No mapping entry is required for this attribute.
The two outputs are independent: a template can use
{weblink}while the dedicated attribute is still injected, and the dedicated attribute is injected even when no template references{weblink}.Do not also configure a mapping whose
target_attributeisweblink. The auto-injected attribute and a manually mapped one share the same name, which produces two attributes withlong_name="weblink"in the output and may be rejected by ReqIF importers.editlink_pattern: (Optional) A URL pattern for generating aneditlinkfield for each exported need. The placeholders{docname},{lineno}must be used.import_date: (Optional, default: false) If set to true, adds animport_datefield to each exported requirement, containing the UTC timestamp of export.hierarchy_is_editable: (Optional, default: false) Value ofIS-EDITABLEon every SPEC-HIERARCHY entry (the specification’s document tree).falseis written explicitly, which tools such as ReqIF Manager and DOORS Classic read as a locked structure; settrueso recipients can restructure or comment in place. Independent of the per-attributeis_editablemapping option (see Mapping Configuration). Not used in update mode (base), which keeps the hierarchy of the base file.html_dir: (Optional) Path to the Sphinx HTML build output directory. If set, ubConnect extracts the rendered HTML for each need’scontentfrom<html_dir>/<docname>.htmland exports it as ReqIF XHTML. This improves fidelity compared to plain text conversion.Note
html_dirrequires thecontentmapping datatype to bexhtml.html_dircannot be used together with atemplateon thecontentfield mapping.
target_image_dir: (Optional) Directory name for images inside the generated.reqifzarchive. If set, ubConnect rewrites relative<img src>references in the extracted HTML and embeds the image files into the ReqIFz.Note
target_image_dirrequires bothhtml_dirto be set andreqifz = true.type_field(string, default “”): name of the need field used as the SPEC-OBJECT-TYPE discriminator. When empty, falls back togroup_types(or the single-bucket default).hierarchy_field(string, default “”): name of the need field carrying the JSON ancestor ID list. When set, drives SPEC-HIERARCHY construction independently of thesectionsfield.section_types(list of strings, default []): values oftype_fieldwhose needs become section nodes only — not duplicated as separate spec-objects.export_external_needs(bool, default false): re-emit needs whoseoriginfield equalsExternal. Required for round-trip pipelines.[[object_types]](array of tables): per-source-type SPEC-OBJECT-TYPE definitions with optionalnameandmappingoverriding the global mapping for matching needs. See the Round-trip fidelity sub-section above.
HTML Content Extraction (Sphinx HTML)¶
If you want to preserve rich formatting and images for the need content field, configure ubConnect to extract the already-rendered HTML from a Sphinx HTML build.
This is controlled by html_dir and (optionally) target_image_dir.
How it works¶
For each exported need, ubConnect reads
<html_dir>/<docname>.htmland looks up the need table<table id="{need_id}">.It extracts the content cell HTML (the row with class
need content) and converts it to ReqIF-compliant XHTML.If
target_image_diris set, relative<img src>paths are rewritten and the referenced image files are added as attachments to the.reqifz.
Limitations and fallbacks¶
Only the field mapped by the
contentmapping entry is extracted from HTML. Other XHTML fields (e.g.,title) use the normal plain-text-to-XHTML conversion.If a need has no
docnameor the rendered HTML cannot be found/parsed, ubConnect falls back to plain text conversion for that need’s content.Image embedding requires
reqifz = true. Plain.reqiffiles cannot contain attachments.
Example configuration¶
[ubconnect.to_reqif]
needsjson_path = "needs.json"
reqifz = true
# Extract rendered HTML content for the "content" field
html_dir = "./docs/_build/html"
# Embed referenced images into the ReqIFz under this directory
target_image_dir = "images"
ALM Tool Configuration¶
The alm_tool parameter allows you to specify the target Application Lifecycle Management (ALM) tool
for the exported ReqIF file. Different ALM tools have different conventions for attribute names and
hierarchical structures. ubConnect provides optimized defaults for each supported tool.
Supported ALM Tools¶
- Codebeamer (
alm_tool = "codebeamer") Default configuration for Codebeamer ALM tool:
Title attribute:
ReqIF.NameSection type:
FolderSection attribute:
ReqIF.Name(xhtml)
- IBM DOORS (
alm_tool = "doors") Default configuration for IBM DOORS Classic/Next Generation:
Title attribute:
ReqIF.ChapterNameSection type:
HeadingSection attribute:
ReqIF.ChapterName(xhtml)
Examples¶
For Codebeamer:
[ubconnect.to_reqif]
needsjson_path = "needs.json"
alm_tool = "codebeamer" # Uses Codebeamer defaults
For IBM DOORS:
[ubconnect.to_reqif]
needsjson_path = "needs.json"
alm_tool = "doors" # Uses DOORS defaults
The ALM tool setting affects both the default attribute mappings (see Mapping Configuration) and the default section configuration (see Section Configuration).
Mapping Configuration¶
When using the command reqif to-reqif, ubConnect converts Sphinx-Needs fields to ReqIF attribute names directly by default.
However, some fields cannot be directly translated to ReqIF attributes for several reasons.
- Data Type Compatibility Issues
Sphinx-Needs field data types are derived from JSON, such as
boolean,string,int, andlist. While ReqIF attributes support JSON-compatible data types, ReqIF also defines its own specific data types such asXHTMLandEnum, which cannot be directly mapped from Sphinx-Needs fields.- ALM Tool Templates
ALM tools may require specific ReqIF attribute names to represent their internal fields. For example, CodeBeamer requires specific ReqIF attribute names to represent their internal fields such as
IDandTypein their template calledRequirement. If these fields are mapped directly, they may conflict with the ALM tool’s template.- Solution: Custom Mapping Configuration
Therefore, the
mappingsection defines how Sphinx-Needs fields are mapped to ReqIF attributes. Each mapping must be 1:1 (one Sphinx-Needs field maps to one ReqIF attribute). For convenience, some commonly used fields have been pre-defined by ubConnect. Those pre-defined mappings can be overridden by users as needed.
Configuration Structure¶
The following example shows how to customise mapping between Sphinx-Needs fields and ReqIF attributes:
[ubconnect.to_reqif.mapping.priority]
source_field = "priority" # Sphinx-Needs field to read from
target_attribute = "need_priority" # ReqIF attribute to write to
datatype = "enum" # Data type in ReqIF
is_editable = true # Optional: IS-EDITABLE="true" on the attribute definition
[ubconnect.to_reqif.mapping.result]
# source_field = "result" # Optional: Sphinx-Needs field to read from (defaults to the mapping key "result" if not provided)
target_attribute = "need_result" # ReqIF attribute to write to
# datatype = "string" # Optional: Defaults to "string" if not provided
## pre-defined mappings by ubConnect ##
# [ubconnect.to_reqif.mapping.id]
# source_field = "id"
# target_attribute = "need_id"
# datatype = "string"
# [ubconnect.to_reqif.mapping.title]
# source_field = "title"
# target_attribute = "ReqIF.Name"
# datatype = "xhtml"
# [ubconnect.to_reqif.mapping.content]
# source_field = "content"
# target_attribute = "ReqIF.Text"
# datatype = "xhtml"
# [ubconnect.to_reqif.mapping.status]
# source_field = "status"
# target_attribute = "need_status"
# datatype = "enum"
# [ubconnect.to_reqif.mapping.type]
# source_field = "type"
# target_attribute = "need_type"
# datatype = "enum"
# [ubconnect.to_reqif.mapping.prefix]
# source_field = "prefix"
# target_attribute = "ReqIF.Prefix"
# datatype = "string"
## pre-defined mappings by ubConnect ##
Configuration Parameters¶
Each mapping configuration consists of three parameters:
source_field: Sphinx-Needs field name to read from (optional, defaults to the mapping key if not provided)
target_attribute: ReqIF attribute name to write to
datatype: Data type in ReqIF (optional, defaults to “string” if not provided)
template: (Optional) A MiniJinja template string for rendering the value of this attribute. The template can ONLY reference the
source_fieldand the special variableweblink(available whenweblink_patternis set). Only supported for attributes with datatypexhtml. Please refer to the Example 5: Advanced Features – Template, Weblink/Editlink Pattern, and import_date for an example of how to use this parameter. Note: when a template references{weblink}, the dedicatedweblinkReqIF attribute (auto-injected byweblink_pattern) is still written to the SPEC-OBJECT separately. The two are independent.value_map: (Optional) A table that translates Sphinx-Needs field values to ReqIF attribute values before export. Only supported for
datatype = "enum"ordatatype = "string". Cannot be combined withtemplate. See Value Map (Explicit Value Translation) for details and examples.is_editable: (Optional) Boolean. When
true, the attribute definition is written withIS-EDITABLE="true"so the receiving ALM tool lets users edit it. Defaults tofalse: the flag is omitted, which ReqIF treats as not editable. Also honored inside[[ubconnect.to_reqif.object_types]]per-typemappingoverrides. A per-type entry with its owntarget_attributereplaces the global entry, so repeatis_editablethere; an entry with onlyis_editablekeeps the global target.
Supported Data Types¶
The datatype parameter can be one of the following ReqIF data types:
string: Plain text values (converts from Sphinx-Needsstringorarraytypes)xhtml: Rich text with HTML formatting (converts from Sphinx-Needsstringtype)enum: Enumerated values with automatic discovery (converts from Sphinx-Needsstringtype)integer: Integer numeric values (converts from Sphinx-Needsintegertype)boolean: Boolean true/false values (converts from Sphinx-Needsbooleantype)real: Floating-point numeric values (converts from Sphinx-Needsnumbertype)date: Date values (converts from Sphinx-Needsstringtype)
Note
Automatic Enum Discovery: When using enum, ubConnect automatically discovers all unique values
from the specified Sphinx-Needs field and creates corresponding SpecType and SpecEnumeration
entries in the generated ReqIF file. When value_map is provided, the mapped values (the right-hand
side of the table) become the ReqIF enum long-names instead, and auto-discovery is skipped entirely.
Note
Data Type Conversion: The mapping between ReqIF data types and Sphinx-Needs data types is validated
during conversion. For example, when exporting from Sphinx-Needs to ReqIF, a field with number type
will be converted to a ReqIF attribute with real datatype, preserving the numeric value.
Value Map (Explicit Value Translation)¶
The value_map table translates Sphinx-Needs field values to the values written into the ReqIF
attribute. This is useful when:
The vocabulary used in Sphinx-Needs differs from what the target ALM tool expects.
You want to control exactly which enum values are defined in the generated ReqIF file and how they are named.
Supported datatypes: "enum" and "string" only. Using value_map with any other
datatype (e.g. "xhtml", "integer") is an error. Combining value_map with template
is also an error because template already composes the full value from scratch.
How it works¶
Keys are Sphinx-Needs field values (what appears in your
needs.json).Values are the strings written into the ReqIF attribute.
- For
datatype = "enum": The right-hand side values become the ReqIF enum
LONG-NAMEentries. Only the values listed invalue_mapare registered as valid enum entries. If a need’s field value is not a key invalue_map, that attribute is skipped for that need and a warning is emitted.When
value_mapis absent, ubConnect falls back to automatic discovery: all unique values present in the needs data are registered as enum entries, using the original value string as theLONG-NAME.- For
datatype = "string": If the need’s field value is found as a key in
value_map, the corresponding mapped string is written. If the value is not found in the map, the original value is written unchanged.
Configuration examples¶
Enum with explicit value mapping:
[ubconnect.to_reqif.mapping.priority]
source_field = "priority"
target_attribute = "Priority"
datatype = "enum"
[ubconnect.to_reqif.mapping.priority.value_map]
"high" = "High Priority"
"medium" = "Medium Priority"
"low" = "Low Priority"
Only high, medium, and low are registered as ReqIF enum values. Any need whose
priority field contains a different value will have that attribute skipped with a warning.
String with value translation:
[ubconnect.to_reqif.mapping.status]
source_field = "status"
target_attribute = "Status"
datatype = "string"
[ubconnect.to_reqif.mapping.status.value_map]
"open" = "In Progress"
"closed" = "Done"
"deferred" = "On Hold"
Needs whose status is not listed (e.g. "draft") will have the original value "draft"
written to the ReqIF attribute.
Enum without value_map (auto-discovery):
[ubconnect.to_reqif.mapping.priority]
source_field = "priority"
target_attribute = "Priority"
datatype = "enum"
# No value_map: ubConnect discovers all unique values from needs data
Validation rules¶
value_mapis only valid fordatatype = "enum"ordatatype = "string".value_mapandtemplatecannot be set on the same mapping entry.All keys and values must be strings (TOML string type). Boolean values (e.g.
true) are rejected at config parse time.
Pre-defined Mappings¶
ubConnect provides pre-defined mappings for commonly used fields that can be overridden as needed.
The default mappings vary based on the selected alm_tool.
Source Field |
Target Attribute |
Data Type |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Source Field |
Target Attribute |
Data Type |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note
The main difference between Codebeamer and DOORS mappings is the title field:
Codebeamer uses ReqIF.Name while DOORS uses ReqIF.ChapterName.
Section Configuration¶
ReqIF supports hierarchical structures through section objects (folders or headings). ubConnect can
generate section spec-objects from the hierarchy information in your Sphinx-Needs data, using the
sections and section_name fields.
Configuration Structure¶
The section configuration has two sub-fields:
[ubconnect.to_reqif.section]
type = "Folder" # The ReqIF spec-object-type name for sections
[[ubconnect.to_reqif.section.mappings]]
target_attribute = "ReqIF.Name" # ReqIF attribute for section title
datatype = "xhtml" # Data type: "string" or "xhtml"
Configuration Parameters:
type: The name of the ReqIF spec-object-type used for section objects (e.g., “Heading”, “Folder”)mappings: A list of attribute mappings for section objects. Each mapping contains:target_attribute: The ReqIF attribute name to store the section title (required)datatype: The data type for the attribute - only"string"or"xhtml"are supported (optional, defaults to “xhtml”)
Note
Section mappings only support "string" and "xhtml" datatypes. Other ReqIF datatypes
(enum, integer, boolean, date, real) are not supported for section attributes.
ALM-Specific Defaults¶
If you don’t provide a section configuration, ubConnect uses ALM-specific defaults based on the
alm_tool setting:
Codebeamer (alm_tool = "codebeamer")
[ubconnect.to_reqif.section]
type = "Folder"
[[ubconnect.to_reqif.section.mappings]]
target_attribute = "ReqIF.Name"
datatype = "xhtml"
IBM DOORS (alm_tool = "doors")
[ubconnect.to_reqif.section]
type = "Heading"
[[ubconnect.to_reqif.section.mappings]]
target_attribute = "ReqIF.ChapterName"
datatype = "xhtml"
How Sections Are Created¶
Sections are built from the sections and section_name fields in your needs data:
The
sectionsfield is an array of section names representing the hierarchy pathThe last element of the
sectionsarray (sections[-1]) represents the top level of the hierarchyThe first element (
sections[0]) represents the section closest to the needThe
section_namefield (if present) represents the need’s own section
Example Hierarchy:
{
"REQ_001": {
"id": "REQ_001",
"title": "User Authentication",
"sections": ["Security", "Requirements", "System"],
"section_name": "Authentication"
}
}
This creates the following hierarchy in ReqIF:
System # sections[-1] - Top level
└── Requirements # sections[-2]
└── Security # sections[-3] or sections[0]
└── Authentication # section_name (if present)
└── REQ_001 # The actual requirement
Custom Section Configuration¶
You can override the default section configuration:
[ubconnect.to_reqif]
needsjson_path = "needs.json"
alm_tool = "codebeamer"
# Custom section configuration
[ubconnect.to_reqif.section]
type = "CustomSection" # Custom section type name
[[ubconnect.to_reqif.section.mappings]]
target_attribute = "custom_section_attr" # Custom attribute for section title
datatype = "string" # Use plain string instead of xhtml
Minimal Configuration¶
If you want to use ALM-specific defaults, you can omit the section configuration entirely:
[ubconnect.to_reqif]
needsjson_path = "needs.json"
alm_tool = "doors" # Will automatically use DOORS section defaults
Partial Configuration¶
You can provide only the fields you want to customize, and ubConnect will use ALM-specific defaults for the rest:
[ubconnect.to_reqif]
alm_tool = "codebeamer"
# Only customize the section type, use ALM defaults for mappings
[ubconnect.to_reqif.section]
type = "CustomFolder"
# mappings will default to Codebeamer's: ReqIF.Name (xhtml)
Complete Export Configuration Examples¶
Example 1: Exporting to DOORS with Default Settings¶
[ubconnect.to_reqif]
needsjson_path = "needs.json"
outpath = "requirements.reqif"
name = "System Requirements"
alm_tool = "doors"
# DOORS-specific defaults are automatically applied:
# - Title maps to ReqIF.ChapterName
# - Sections use "Heading" type with ReqIF.ChapterName attribute
Example 2: Exporting to Codebeamer with Custom Mappings¶
[ubconnect.to_reqif]
needsjson_path = "needs.json"
outpath = "requirements.reqifz"
reqifz = true
alm_tool = "codebeamer"
# Custom field mappings (override defaults)
[ubconnect.to_reqif.mapping.priority]
source_field = "priority"
target_attribute = "CB_Priority"
datatype = "enum"
[ubconnect.to_reqif.mapping.assignee]
source_field = "assignee"
target_attribute = "CB_Assignee"
datatype = "string"
Example 3: Custom Section Configuration with DOORS¶
[ubconnect.to_reqif]
needsjson_path = "needs.json"
alm_tool = "doors"
# Override default DOORS section configuration
[ubconnect.to_reqif.section]
type = "CustomHeading"
[[ubconnect.to_reqif.section.mappings]]
target_attribute = "ReqIF.ChapterName"
datatype = "xhtml"
[[ubconnect.to_reqif.section.mappings]]
target_attribute = "Section_Description"
datatype = "string"
Example 4: Full Configuration with All Options¶
[ubconnect.to_reqif]
needsjson_path = "./data/needs.json"
outpath = "./output/requirements.reqifz"
name = "Software Requirements Specification"
prefix = "SW"
group_types = false
reqifz = true
uuid_source = "reqif_uuid"
origin_field = "origin"
alm_tool = "codebeamer"
# Section configuration
[ubconnect.to_reqif.section]
type = "Folder"
[[ubconnect.to_reqif.section.mappings]]
target_attribute = "ReqIF.Name"
datatype = "xhtml"
# Custom field mappings
[ubconnect.to_reqif.mapping.priority]
source_field = "priority"
target_attribute = "need_priority"
datatype = "enum"
[ubconnect.to_reqif.mapping.version]
source_field = "version"
target_attribute = "need_version"
datatype = "string"
[ubconnect.to_reqif.mapping.verified]
source_field = "verified"
target_attribute = "need_verified"
datatype = "boolean"
Example 5: Advanced Features – Template, Weblink/Editlink Pattern, and import_date¶
This example demonstrates how to use advanced features such as MiniJinja templates, the weblink_pattern and editlink_pattern options, and the import_date field.
[ubconnect.to_reqif]
needsjson_path = "needs.json"
outpath = "needs.reqif"
name = "Advanced Features Test"
weblink_pattern = "https://docs.example.com/{docname}.html#{id}"
editlink_pattern = "https://github.com/org/repo/edit/main/{docname}.rst#L{lineno}"
import_date = true
[ubconnect.to_reqif.mapping.content]
source_field = "content"
target_attribute = "ReqIF.Text"
datatype = "xhtml"
template = "{{'The original need is from' ~ weblink ~ 'Its content is the following:' ~ content }}"
How it works:
weblink_patternrenders a URL for each need using placeholders{docname}and{id}. It produces two independent outputs: aweblinkMiniJinja template variable (used in thetemplatebelow) AND a dedicatedweblinkReqIF attribute (XHTML, rendered as a clickable link) that is auto-added to every SPEC-OBJECT.editlink_patternrenders a URL for each need using placeholders{docname}and{lineno}, and adds aneditlinkReqIF attribute to every SPEC-OBJECT.The
import_date = trueoption adds a timestamp field to each exported requirement, indicating when it was imported.The
templatefield in the mapping uses MiniJinja syntax to combine static text, the generatedweblink, and the need’s content. The dedicatedweblinkattribute is still injected separately regardless of whether a template references it.
Example needs.json input:
{
"created": "2026-02-02T22:28:59.019642",
"current_version": "1.0",
"versions": {
"1.0": {
"needs": {
"REQ_001": {
"id": "REQ_001",
"title": "Advanced Feature Requirement",
"type": "req",
"status": "open",
"content": "The system shall support advanced features.",
"docname": "requirements/advanced",
"lineno": 42
}
},
"needs_schema": {
"properties": {
"id": {"field_type": "core", "type": "string"},
"title": {"field_type": "core", "type": "string"},
"type": {"field_type": "core", "type": "string"},
"status": {"field_type": "core", "type": "string"},
"content": {"field_type": "core", "type": "string"},
"docname": {"field_type": "core", "type": ["string", "null"]},
"lineno": {"field_type": "core", "type": ["integer", "null"]}
}
}
}
}
}
Result:
Each exported requirement will have a
weblinkandeditlinkfield generated from the patterns.The
contentattribute in ReqIF will be rendered using the MiniJinja template, combining the weblink and the original content.An
import_datefield will be present, showing the UTC timestamp of import.
This approach enables traceability, direct linking to documentation and source, and rich content generation for ReqIF export.
Example 6: Weblink Attribute with html_dir (No Template Required)¶
This example covers a Sphinx-Needs to Codebeamer (or similar tool) export where the HTML content
is sourced from a Sphinx build (html_dir), and every SPEC-OBJECT must carry a clickable
weblink back to the documentation page, without writing a MiniJinja template.
Because weblink_pattern auto-injects a dedicated weblink ReqIF attribute on every
SPEC-OBJECT, no template entry is needed. The html_dir-sourced content and the weblink
attribute are written independently.
[ubconnect.to_reqif]
needsjson_path = "needs.json"
outpath = "needs.reqif"
html_dir = "./_build/html"
weblink_pattern = "https://docs.example.com/{docname}.html#{id}"
[ubconnect.to_reqif.mapping.content]
source_field = "content"
target_attribute = "ReqIF.Text"
datatype = "xhtml"
# No template here: html_dir and template cannot be combined.
# The weblink attribute is injected automatically by weblink_pattern.
What this produces:
The
ReqIF.Textattribute contains the rendered HTML extracted from the Sphinx build output.A separate
weblinkReqIF attribute (XHTML, clickable<a href>link) is added to every SPEC-OBJECT byweblink_pattern. It does not require a mapping entry and does not conflict with thehtml_dir-sourced content field.
ReqIF to Sphinx-Needs¶
Configuration Overview¶
The reqif from-reqif command uses a flexible configuration system to map ReqIF attributes
to Sphinx-Needs fields. This allows adapting to ReqIF files from different ALM tools.
The configuration consists of these main components:
Path Settings: Where to find and store files
Output Format: Choose between JSON or RST output
Field Values: Applied values for all imported needs
Attribute Mappings: How ReqIF attributes map to need fields
Section Detection (optional): How headings/folders are detected and converted into hierarchy
All configuration can be defined in a TOML file under the section [ubconnect.from_reqif].
Attention
When using reqif from-reqif, make sure the id field is exported to ReqIF as defined in the to-reqif mapping configuration.
Basic Configuration¶
The basic configuration requires only one mandatory field:
Attention
Paths in the TOML file are relative to the location of the
TOML configuration file. Paths given on the command line (the
positional ReqIF path, --outdir, --images-target-dir, …) are
relative to the current working directory.
[ubconnect.from_reqif]
reqif_path = "./relative/path/to/your.reqif" # Optional: Relative to the location of this TOML file
reqifz = false
outdir = "./output" # Optional: Output directory for generated files
id_prefix = "REQ_" # Prefix for need IDs (default: "REQ_")
back_links = false # Optional: Enable/disable backlink generation (default: false)
uuid_target = "reqif_uuid" # Optional: The target field for the UUID of ReqIF Spec-Object (default: "reqif_uuid")
origin_field = "origin" # Optional: The field to track the origin of the requirement (default: "origin")
images_target_dir = "./_static/reqif_attachments" # Optional: Export ReqIFZ attachments (e.g., images) to this directory
images_ref_dir = "_static/reqif_attachments" # Optional: Prefix used to rewrite XHTML <object data="..."> / <img src="..."> references
output_format = "json" # Optional: Output format "json" or "rst" (default: "json")
reqif_path: Path to the ReqIFZ/ReqIF file to import
Note
reqif_path must be provided either through the CLI argument or in the TOML configuration file.
reqifz: Set to true if the provided file is a ReqIFZ (zipped) file; otherwise, set to false for plain XML ReqIF files (default: false).outdir: Output directory for generated files (optional, defaults to the directory where theTOMLconfiguration file is located). When a ReqIF file contains multiple specifications, ubConnect converts every one of them (see DOORS Exports with Several Modules): JSON output and RSTsingle_fileoutput write one file per specification,per_section/per_needoutput one sub-folder per specification, and a top-levelindex.rstlinks the indexes of all specifications.For example, if the ReqIF file contains two specifications named
Spec_AandSpec_B, ubConnect generates two files (or two sub-folders) in the specified output directory.id_prefix: Prefix used for need IDs (defaults toREQ_). If a need ID already starts with the specified prefix, no additional prefix will be added. This helps avoid concatenation of the prefix multiple times when importing the same ReqIF file repeatedly.back_links: Enable or disable backlinks generation (defaults to false). See Links Configuration for details. This option creates backward links automatically for each forward link defined in the ReqIF file. As Sphinx-Needs does not take backward links into account when importingneeds.json, it is mainly for the user’s convenience.uuid_target: The target field for the UUID of ReqIF Spec-Object. It can be set to any unused Sphinx-Needs field name (defaults toreqif_uuid). When importing, the UUID from the ReqIF Spec-Object will be preserved in the specified need field. This can be later used as the source for the UUID when exporting back to ReqIF using Configuration Overview. By doing so, the requirements in the ReqIF file can be consistently identified across multiple import/export cycles.origin_field: The field to track the origin of the requirement. It can be set to any Sphinx-Needs field name (default: “origin”). During the conversion, if a requirement from the ReqIF file has this attribute defined and its value isSphinx-Needs, the requirement will be considered as originating fromSphinx-Needs. In this case, the requirement with this field set toSphinx-Needswill be ignored when exporting toneeds.json. If a requirement does not have this attribute at all, it will be added and set toExternalautomatically during the conversion.Note
The value of this field is either
Sphinx-NeedsorExternal(case-insensitive) set by ubConnect.output_format: The output format for the converted requirements (defaults tojson). Supported values are:json: Exports toneeds.jsonfiles that can be imported using Sphinx-Needsneedimportdirective.rst: Exports to RST files containing native Sphinx-Needs directives, eliminating the need forneedimport.
preserve_source_type(bool, default false): emitsource_typefield on every need carrying the LONG-NAME of the originating ReqIF SPEC-OBJECT-TYPE. DOORS writes its object types without LONG-NAME; then the value of themapping.typeattribute (e.g.ObjectType) is used, and as a last resort the SPEC-OBJECT-TYPE IDENTIFIER, so the field is never empty (also in RST output). Pair with[ubconnect.to_reqif] type_fieldfor round-trip.preserve_hierarchy(bool, default false): emitparentsfield (JSON list of ancestor need IDs, root-first). Pair with[ubconnect.to_reqif] hierarchy_fieldfor round-trip.
RST Output Format¶
When output_format = "rst" is set, ubConnect generates RST files containing native Sphinx-Needs directives
instead of JSON files. This provides several benefits:
Git-friendly reviews: Each need can be in its own file, enabling clean diffs when requirements change.
Build simplicity: Native RST without
needimportindirection.Toctree integration: Generated files can be integrated into the Sphinx documentation tree.
[ubconnect.from_reqif]
reqif_path = "./requirements.reqif"
output_format = "rst"
[ubconnect.from_reqif.rst]
mode = "per_need" # "single_file" | "per_section" | "per_need"
filename_pattern = "{id}.rst" # {id}, {type}, {title_slug}, {uuid}, {section}
index_style = "toctree" # "toctree" | "include"
[ubconnect.from_reqif.mapping.type]
source_attribute = "Type"
[ubconnect.from_reqif.mapping.type.value_map]
req = "Functional Requirement"
spec = "SPECIFICATION"
RST Configuration Options:
mode: Controls how requirements are organized into files.single_file: All requirements in a single RST file (default).per_section: One RST file per root-level ReqIF section, with the full section hierarchy preserved as nested RST headings inside each file. Parent-only sections (sections that contain sub-sections but no direct needs) are retained as RST headings rather than being silently dropped. Needs that have no section ancestry are collected in_orphans.rst.per_need: One file per requirement (best for git history/reviews).
filename_pattern: Pattern for generating filenames when usingper_needmode. Supports placeholders:{id},{type},{title_slug},{uuid},{section}, and the specification placeholders{spec}(LONG-NAME),{spec_slug}and{prefix}(the ID prefix of the specification).Note
The
filename_patternapplies toper_needmode, and toper_sectionmode when it contains{section}(the root chapter).The
{section}placeholder is derived from the need item’ssection_namefield (if available) elserootis used as the default value.
index_style: How to generate the index file when usingper_sectionorper_needmodes.toctree: Generate atoctreedirective (default).include: Generateincludedirectives.
RST Per-Section Hierarchy¶
When mode = "per_section" is configured, ubConnect groups all imported needs by their
root ancestor section and writes one RST file per root section. The full depth of the
ReqIF section tree is preserved inside each file using standard RST heading underline
characters:
Depth |
Character |
Example |
|---|---|---|
0 (root) |
|
Top-level section title |
1 |
|
First sub-section |
2 |
|
Second sub-section |
3 |
|
Third sub-section |
4 |
|
Fourth sub-section |
5–8 |
|
Deeper nesting levels |
Key behaviours:
Parent-only sections (sections that contain child sections but have no direct needs attached) are preserved as RST headings. They are not silently dropped.
Orphan needs (needs with no section ancestry) are written to
_orphans.rst.Chapters with the same name stay separate chapters (and files:
interface_descriptions.rst,interface_descriptions_2.rst); trailing and repeated blanks in chapter names are removed.The generated
index.rsttoctreelists only the root-level section files — not every leaf section — keeping the index clean.
Example output for a two-level hierarchy:
.. _coffee_machine_example:
Coffee Machine Example
======================
*Source: Coffee Machine Requirements*
.. _software_architecture:
Software Architecture
---------------------
.. req:: Architecture Overview
:id: REQ_SO_002
...
.. _implementation:
Implementation
--------------
.. _rust_interface_implementations:
Rust Interface Implementations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. req:: Rust Binding
:id: REQ_SO_005
...
In this example Implementation is a parent-only section — it has no direct needs
but is still rendered as a - heading so the hierarchy is visible. Its child section
Rust Interface Implementations is rendered at depth 2 (~).
The corresponding index.rst lists only root-level files:
.. _coffee_machine_requirements_index:
Coffee Machine Requirements Index
=================================
.. toctree::
:maxdepth: 2
coffee_machine_example
external_data
Mapping with Value Translation¶
To translate ReqIF attribute values to Sphinx-Needs field values during import, use a
structured mapping entry with source_attribute and value_map:
[ubconnect.from_reqif.mapping.type]
source_attribute = "Type" # ReqIF attribute whose value is read
[ubconnect.from_reqif.mapping.type.value_map]
req = "Functional Requirement" # sn_value = reqif_value
spec = "SPECIFICATION"
The value_map table uses Sphinx-Needs values as keys and ReqIF values as values.
At runtime, ubConnect looks up the incoming ReqIF value and writes the corresponding
Sphinx-Needs value to the need field. A list maps several ReqIF values to one
Sphinx-Needs value (info = ["Text", "Change Log"]).
Values not found in the map follow unmapped (one warning per specification lists every
such value with its count):
|
Effect |
|---|---|
|
Default. The value is written as-is. For |
|
Every unmapped value becomes a lower-case slug ( |
|
The value of |
|
The import stops and lists every object (specification, absolute number, value). |
default also gives objects that do not carry the attribute at all a value. For type
it replaces the built-in fallback req, which JSON and RST output now share (0.18 aborted
the JSON export on the first object without a type):
[ubconnect.from_reqif.mapping.type]
source_attribute = "ObjectType"
default = "info" # objects without ObjectType (e.g. DOORS table objects)
unmapped = "slug"
[ubconnect.from_reqif.mapping.type.value_map]
func = "Requirement"
info = ["Text", "Change Log"]
When the mapped field is type, the Sphinx-Needs directive (e.g. .. req:: or .. spec::)
is also updated accordingly.
Types by chapter. DOORS projects often tell non-functional requirements apart by their
chapter, not by ObjectType. value_map lists a ReqIF value only once, so
Requirement cannot become both func and nonfunc there. rules give the
objects of a chapter a type of their own:
[ubconnect.from_reqif.mapping.type]
source_attribute = "ObjectType"
value_map = { func = "Requirement" }
[[ubconnect.from_reqif.mapping.type.rules]]
section = "Specified requirements > Non-functional requirements"
value = "Requirement" # optional: only objects with this value (string or list)
type = "nonfunc"
sectionis a glob on the chapter path, the same path assection.path_field("Chapter > Sub-chapter"). Blanks are normalised and the match is case-sensitive. A rule for a chapter also covers its sub-chapters."*"matches every object.valuelimits a rule to objects whose type attribute has one of the values. Without it, every object of the chapter matches, also objects without the attribute.Rules are checked in order before
value_map, and the first matching rule wins. Objects that match no rule are typed as before (value_map,unmapped,default).A
[[specifications]]entry can bring rules of its own (mapping = { type = { rules = [...] } }). Its mapping entries are merged key by key into the global ones, and its rules are checked before the global rules.The summary at the end of the run lists, per specification, how many objects each rule typed. A rule that types no object is a warning, so a renamed chapter does not silently turn its requirements back into
func.--ubproject-snippetdeclares every rule type.On the way back (Updating the original export (update mode)) a rule type maps to the object’s
ObjectType, so an unchanged import stays lossless.funcandnonfuncboth come fromRequirement, so changing one into the other in the RST changes no attribute. When the chapter would give the object the old type again on the next import, the change is reported as not written back. A need moved into or out of the chapter gets its type from the rule on the next import.
Deprecated since version rst.type_mapping: The [ubconnect.from_reqif.rst.type_mapping] table is deprecated and will be removed
in a future release. Use structured mapping entries with value_map instead
(see above).
CLI Override:
The output format can also be specified via CLI:
ubconnect reqif from-reqif requirements.reqif --output-format rst --outdir ./docs/source/requirements
The following two options handle attachments (e.g., images) embedded in ReqIFZ files:
Note
Attachment export and XHTML rewriting only apply when importing a .reqifz (reqifz = true). Plain .reqif files do not contain attachments.
images_target_dir: If set andreqifz = true, ubConnect exports all ReqIFZ attachments (e.g., PNG files referenced via<object data=...>in XHTML) into this directory. The directory is created if it does not exist. If not set, attachments are not exported.images_ref_dir: If set and ReqIFZ attachments are available, ubConnect rewrites XHTML references in imported rich-text fields. For example<object data="14973639-1.png">becomes<object data="_static/reqif_attachments/14973639-1.png">.
CLI Override (image options):
Both images_target_dir and images_ref_dir can be overridden on the CLI when the target directory is computed dynamically (e.g. in CI pipelines):
ubconnect reqif from-reqif requirements.reqifz \
--images-target-dir ./build/_static/reqif_attachments \
--images-ref-dir _static/reqif_attachments
The CLI value beats the TOML value for that field; the other field falls back to TOML. If only one of the two ends up set (whether via CLI or TOML), ubConnect emits its usual configuration warning — see the notes below.
Attachments and Images (ReqIFZ)¶
Some ALM tools embed images (and other binary assets) into .reqifz files as attachments and reference them inside rich-text fields
via HTML/XHTML tags such as <object data="...">.
ubConnect supports this workflow with two separate configuration options:
images_target_dir(filesystem path): Where ubConnect writes the attachment files to disk. This is resolved relative to the TOML file location.images_ref_dir(HTML path prefix): The prefix that ubConnect injects into rich-text HTML when rewriting references. This must match how your final rendered HTML can reach the exported files.
Example for a Sphinx documentation project¶
If your configuration file lives under docs/ within a Sphinx documentation project (or you otherwise want the attachments to be shipped with your docs), a common setup is:
html_static_path = ['_static']
[ubconnect.from_reqif]
reqif_path = "./requirements.reqifz"
reqifz = true
# Write images into the Sphinx "_static" folder (so they get copied into the built HTML)
images_target_dir = "./source/_static/reqif_attachments"
# Reference them the same way Sphinx serves static assets in HTML output
images_ref_dir = "_static/reqif_attachments"
Notes¶
Rewriting only happens if the referenced filename matches an attachment name (exact match).
If you set
images_ref_dirbut notimages_target_dir, ubConnect can rewrite references but will not export any files.If you set
images_target_dirbut notimages_ref_dir, ubConnect will export files but will keep the originaldata=.../src=...references unchanged.
Mapping Configuration¶
The mapping section defines how ReqIF attributes are mapped to Sphinx-Needs fields.
The 1:N mapping model is supported: a single ReqIF attribute can be mapped to multiple Sphinx-Needs fields simultaneously, but each Sphinx-Needs field can only receive values from one ReqIF attribute. With 1:N mapping, users can leverage needs_string_links to achieve Linking Back to the Original Source
Note
If multiple mapping entries target the same Sphinx-Needs field (case-insensitive), ubConnect raises an error during configuration validation.
Warning
Field names in the mapping must match the regex [A-Za-z0-9_-]+. Defining the same field
in both mapping and static_fields is not allowed.
Configuration Structure¶
The following example shows a typical mapping configuration:
[ubconnect.from_reqif.mapping]
id = "ReqIF.ForeignID" # Maps to need ID (default: "ReqIF.ForeignID")
title = "ReqIF.Name" # Maps to need title (default: "ReqIF.Name")
content = "ReqIF.Text" # Maps to need content (default: "ReqIF.Text")
reqif_type = "Type" # Preserves the ReqIF item type (default: "Type")
# additional mappings
reqif_status = "Status" # Custom field example
reqif_resolution = "Resolution" # Custom field example
Note
Some ALM tools export attributes under names that differ from the original field names.
For example, CodeBeamer exports the item ID as ReqIF.ForeignID rather than ID.
Always use the attribute name exactly as it appears in the ReqIF file.
Configuration Parameters¶
- Mandatory mappings
The following fields are required for ubConnect to construct needs from the ReqIF file. All of them have default values and can be omitted if the defaults are appropriate.
id: ReqIF attribute name for the need ID (default:"ReqIF.ForeignID")title: ReqIF attribute name for the need title (default:"ReqIF.Name")content: ReqIF attribute name for the need content (default:"ReqIF.Text")reqif_type: ReqIF attribute whose value is stored as the ReqIF item type in Sphinx-Needs (default:"Type")
- Additional mappings
Any other key–value pairs in the
mappingsection are treated as additional mappings. They are not type-validated, giving full flexibility for project-specific custom fields.
Linking Back to the Original Source¶
A common use case is to preserve a clickable reference back to the original item in the source ALM tool so that readers of the Sphinx-Needs documentation can navigate to it directly.
Because needs.json stores plain data values, it cannot encode a rendered hyperlink on its
own. Instead, the hyperlink must be constructed at documentation build time by Sphinx-Needs,
using the
needs_string_links
configuration option. This option instructs Sphinx-Needs to match a stored field value against a
regular expression and render the result as a clickable link.
The recommended approach is:
Use the 1:N mapping capability to map the ReqIF attribute that carries the item identifier (e.g.,
ReqIF.ForeignID) to a dedicated Sphinx-Needs field (e.g.,origin_link) in addition to theidfield.Configure
needs_string_linksinconf.pyto convert the stored identifier into a hyperlink pointing to the ALM tool.
The field name (origin_link in the examples below) is fully customisable – choose any name
that is meaningful in your project.
conf.py
needs_string_links = {
# Render a clickable link back to the originating Codebeamer item
"origin_link": {
"regex": r"^(?P<value>\w+)$",
"link_url": "<your_codebeamer_url>/{{value}}",
"link_name": "CodeBeamer item #{{value}}",
"options": ["origin_link"],
}
}
ubConnect TOML configuration
[ubconnect.from_reqif.mapping]
id = "ReqIF.ForeignID" # Populates the need ID
origin_link = "ReqIF.ForeignID" # Also stores the raw ID for hyperlink rendering
With this setup, the same ReqIF.ForeignID value is written to both the id field and the
origin_link field. Sphinx-Needs then uses needs_string_links to render origin_link
as a hyperlink in the generated documentation, pointing back to the original item in the ALM
tool.
Static Fields Configuration¶
For need fields not mapped in Mapping Protocol, the static_fields section allows you to add fields and their values that will be applied
to all needs created from the ReqIF file:
[ubconnect.from_reqif.static_fields]
type = "req" # Type of needs (default: "req")
# additional static_fields
priority = "high" # Another additional field example
Fields under static_fields:
- Mandatory Fields
The following static fields are mandatory for ubConnect to apply the value for each need created from the ReqIF file. The type of these fields are validated by ubConnect.
Note
These static fields have default values if not provided
type: Sphinx-Needs Type assigned to all imported needs (defaults to “req”)
- additional
Apart from the above-mentioned static fields, any others defined in the
static_fieldssection are considered asadditionalstatic fields.Note
The
additionalstatic field accepts any key-value pairs without type validation. This flexibility allows adding custom static fields, but users should ensure the values are appropriate for their use case.
Mapping vs. Static Fields — Precedence¶
When the same Sphinx-Needs field name appears in both mapping and static_fields,
ubConnect raises a configuration validation error:
# ERROR: 'type' is defined in both mapping and static_fields
[ubconnect.from_reqif.mapping.type]
source_attribute = "Type"
[ubconnect.from_reqif.mapping.type.value_map]
req = "Functional Requirement"
[ubconnect.from_reqif.static_fields]
type = "req" # conflict — validation error
The rule is: a field can only have one source. If it is in mapping, it is populated
per-object from the ReqIF attribute (with optional value_map translation). If it is in
static_fields, the same value is applied to every imported need.
Note
When you configure mapping.type, ubConnect automatically removes the default
static_fields["type"] = "req" entry to avoid a conflict. You do not need to
remove static_fields.type manually — it is only an error if you explicitly set it
in the config alongside a mapping.type entry.
Section Detection (Hierarchy)¶
ReqIF specifications often contain hierarchical structures (sections/headings) represented by heading-like Spec-Objects.
ubConnect can preserve this hierarchy when importing to Sphinx-Needs.
To control how section nodes are detected (and to support parent items that have children),
configure the optional section block under [ubconnect.from_reqif.section].
When enabled, ubConnect:
Detects section nodes while processing the ReqIF
SPEC-HIERARCHY.Stores hierarchy metadata in the resulting
needs.jsonusing the fieldssections(list of ancestor section names) andsection_name(name of the immediate section).Renders nested RST directives for child needs into the parent’s
contentfield.
Note
If [ubconnect.from_reqif.section] is not configured,
ubConnect falls back to Mode 0:
No section detection is performed.
All relevant ReqIF spec-objects are imported as needs (requirement items), regardless of hierarchy or whether they have children.
The ReqIF
SPEC-HIERARCHYis ignored entirely; no section metadata (sections,section_name) is computed or stored.A warning is logged to indicate that no section configuration is present.
This means all spec-objects are emitted as flat needs, and any parent/child relationships or hierarchy information is lost. This is a change from previous versions, which would consider nodes with the children as parent nodes and only emit leaf nodes as needs.
If you want hierarchy from ReqIF and present them in nested needs without detecting headings/sections, use Mode 1 by configuring the section block appropriately. See Operating Modes for details.
In Mode 2, all non-section nodes are emitted as needs, including non-section nodes that have children (i.e., non-section parent nodes). These parent nodes are preserved and can contain nested requirements.
sections and section_name are stored in the exported JSON only when section detection is enabled. They are not emitted as directive options in the nested RST content.
If you want the section hierarchy to be visible in the generated RST (for example when importing via needimport), configure path_field. This adds an additional need field that is rendered as a directive option.
Configuration Parameters¶
The section configuration supports two detection modes:
Type-name-based detection
(default): Match the Spec-Object-Type LONG-NAME against
type_value.Attribute-value-based detection
Some ReqIF exports use a shared Spec-Object-Type for both headings and requirements, and encode the distinction in a dedicated attribute (for example
Type). In that case, settype_attribute.[ubconnect.from_reqif.section] type_value = "Folder" # Required (together with name_attribute) name_attribute = "ReqIF.Name" # Required (together with type_value) # Optional: enable attribute-value-based detection # type_attribute = "Type"
type_value: The discriminator value that identifies a Spec-Object as a section node.- If
type_attributeis empty, ubConnect comparestype_valueagainst the Spec-Object-Type LONG-NAME.
- If
- If
type_attributeis set, ubConnect comparestype_valueagainst the value of the attribute named by
type_attribute.
- If
type_attribute: Optional. LONG-NAME of the ReqIF attribute whose value is used to detectsection nodes (for example
"Type").
name_attribute: LONG-NAME of the ReqIF attribute whose value becomes the section name.path_field: Optional. Name of the need field to populate with the ancestor hierarchy path.Format: outermost to innermost ancestor names, joined by
" > "(space,>, space), for example"System > Subsystem A".For needs that have no ancestors, the value is an empty string
"".Can be used standalone (without
type_valueorcontainer_as_need). In Mode 0, the path is built from ancestor node titles in the ReqIF hierarchy tree — each spec-object is still emitted flat but carries its ancestor path inpath_field.When used with section detection (Modes 2/3), the path is built from detected section names.
The name used for each path segment follows this priority:
name_attribute— if set in[section]mapping.title— fallback whenname_attributeis not configured, or absent/empty on this nodeuntitled-<spec-object-identifier>— fallback when both attributes above are absent/empty
Note
Choose a field name that does not conflict with other configured fields (for example
origin_field,uuid_target, any keys inmapping/static_fields, or the internal hierarchy fieldssectionsandsection_name).container_as_need: Optional boolean (default:false). Whentrue, section/container nodes are emitted as needs rather than being discarded. This enables two new operating modes (see Operating Modes below).When
container_as_need = true:The need
typeof each container node is overridden to the value oftype_for_needafterstatic_fieldshave been applied.For nodes that lack the configured mapping
idattribute, the ReqIF Spec-ObjectIDENTIFIER(UUID) is used as a fallback for the need ID (prefixed withid_prefix).
type_for_need: Required whencontainer_as_need = true. The Sphinx-Needstypeassigned to emitted container needs (for example"req"). Must be a non-empty string and must not be set withoutcontainer_as_need = true.
Operating Modes¶
The combination of type_value and container_as_need selects one of four operating
modes:
Mode |
|
|
Behaviour |
|---|---|---|---|
0 |
not set |
|
All nodes emitted flat; no hierarchy metadata. A warning is logged. |
1 |
not set |
|
Nodes with children become container needs (structural detection). Leaf nodes are nested inside the nearest container. |
2 |
set |
|
Section nodes are detected by type and discarded. Only non-section leaf nodes are emitted, with their nesting preserved. |
3 |
set |
|
Section nodes are detected by type and emitted as container needs. |
Note
Mode 0 (no section config) is a legacy fallback. In previous releases, nodes with children were silently considered as sections/headings and discarded. Now all nodes are emitted flat and a warning is logged. Configure one of the other modes explicitly for predictable behaviour.
Setting path_field in Mode 0 populates each need with its ancestor path from the ReqIF hierarchy tree.
Examples¶
Type-name-based detection (Mode 2 — sections discarded)¶
Use this when headings/folders use a dedicated Spec-Object-Type (for example Spec-Object-Type LONG-NAME equals "Folder"):
[ubconnect.from_reqif.section]
type_value = "Folder"
name_attribute = "ReqIF.Name"
Attribute-value-based detection (Mode 2 — sections discarded)¶
Use this when headings and requirements share the same Spec-Object-Type and are distinguished by
an attribute value (for example attribute Type equals "Folder" for headings):
[ubconnect.from_reqif.section]
type_value = "Folder"
type_attribute = "Type"
name_attribute = "ReqIF.Name"
Structural container detection (Mode 1)¶
Use this when every node that has children in the hierarchy should become a container need, regardless of its spec-object type. Section nodes do not need a dedicated type or attribute.
[ubconnect.from_reqif.section]
container_as_need = true
type_for_need = "req"
For nodes that lack the configured id mapping attribute (e.g. heading objects in tools
that only give an ID to leaf requirements), ubConnect falls back to the ReqIF
Spec-Object IDENTIFIER (UUID) prefixed with id_prefix.
Typed container detection (Mode 3)¶
Use this when section nodes should be emitted as needs and can be identified by type:
[ubconnect.from_reqif.section]
type_value = "Heading"
name_attribute = "ReqIF.Name"
container_as_need = true
type_for_need = "req"
# Alternatively, use attribute-based detection:
# type_attribute = "ItemType"
Section hierarchy path as a field (Modes 2/3)¶
To store the section hierarchy as a single string field on each need when using section
detection, set path_field:
[ubconnect.from_reqif.section]
type_value = "Folder"
name_attribute = "ReqIF.Name"
path_field = "hierarchy_path"
For a requirement located under Root → SubFolder, ubConnect sets:
hierarchy_path = "Root > SubFolder"
Hierarchy path without section detection (Mode 0)¶
To track each node’s position in the ReqIF hierarchy without section detection,
set only path_field:
[ubconnect.from_reqif.section]
path_field = "hierarchy_path"
In this mode, every spec-object is emitted as a flat need. The hierarchy_path
field records the ancestor path derived from node titles in the ReqIF tree.
For a hierarchy Root → SubFolder → Requirement, ubConnect sets:
Root:hierarchy_path = ""(no ancestors)SubFolder:hierarchy_path = "Root"Requirement:hierarchy_path = "Root > SubFolder"
The name used for each path segment follows this priority:
name_attribute— if set in[section]mapping.title— fallback whenname_attributeis not configured, or absent/empty on this nodeuntitled-<spec-object-identifier>— fallback when both attributes above are absent/empty
You can override the attribute used for path segment names without enabling section detection:
[ubconnect.from_reqif.section]
path_field = "hierarchy_path"
name_attribute = "ReqIF.ChapterName"
Note
When name_attribute differs from mapping.title, path segment names will differ
from the need’s title field.
Links Configuration¶
In ReqIF, the links between requirements are represented as SpecRelations.
There are no direct ReqIF attributes that could serve as link field names in Sphinx-Needs.
Therefore, ubConnect maps Sphinx-Needs link fields to SpecRelationTypes, given by
IDENTIFIER or by LONG-NAME. By doing so, the corresponding Sphinx-Needs link fields are
populated based on the SpecRelations defined in the ReqIF file.
[ubconnect.from_reqif.links]
tests = ["SpecRelationType1_ID"] # by IDENTIFIER
depends_on = ["Depends On"] # by LONG-NAME
satisfies = { relation_type = "Satisfies" } # the same, as a table
- Link Field Mappings
Each key in the
linkssection represents a Sphinx-Needs link field name, and the value is a list ofSpecRelationTypeIDENTIFIERs or LONG-NAMEs. When aSpecRelationwith one of these types is found, a link will be created in the corresponding Sphinx-Needs field.- Links across specifications
A link to an object of another specification gets that specification’s ID prefix, also when the target specification is not converted in the same run:
external_targets = "keep"(default) writes the ID the target gets,"drop"leaves the link out with a warning. A link field is only written when it has a target; links that cannot be resolved are listed with source and target (specification and absolute number).- Links onto headings and prose
Headings and prose paragraphs are not needs. With
rst.label_patternset, a link onto one becomes a reference to its label in the text of the source need (Traces To: :ref:`dpc-arch-212`); otherwise it is reported as not converted.- Back Links Generation
When
back_links = trueis set in the main configuration,ubConnectautomatically generates backward links for each forward link. The backward link field name is created by appending_backto the original field name.For example: - If a forward link is created in the
depends_onfield from Requirement A to Requirement B - A backward link will be automatically created in thedepends_on_backfield from Requirement B to Requirement A
Note
IDs of SpecRelationType: These IDs can be found in the ReqIF file’s SpecRelationType elements.
Different ALM tools may use different naming conventions for these IDs.
Complete Configuration Example¶
Here’s a complete configuration example showing all available options:
[ubconnect.from_reqif]
reqif_path = "./requirements.reqifz"
reqifz = true
outdir = "./docs/source"
id_prefix = "SYS_"
back_links = true
output_format = "rst"
[ubconnect.from_reqif.static_fields]
type = "requirement"
status = "new"
[ubconnect.from_reqif.section]
type_value = "Folder"
type_attribute = "Type" # Optional; omit for type-name-based detection
name_attribute = "ReqIF.Name"
container_as_need = false # Set to true to emit section nodes as needs (Mode 3)
# type_for_need = "req" # Required when container_as_need = true
[ubconnect.from_reqif.mapping]
id = "ReqIF.ForeignID"
title = "ReqIF.Name"
content = "ReqIF.Text"
reqif_type = "Type"
reqif_status = "Status"
[ubconnect.from_reqif.mapping.type]
source_attribute = "Type"
[ubconnect.from_reqif.mapping.type.value_map]
req = "Functional Requirement"
[ubconnect.from_reqif.links]
links = ["<SpecRelationType1_ID>"]
[ubconnect.from_reqif.rst]
mode = "per_need"
filename_pattern = "{id}.rst"
index_style = "toctree"
DOORS Exports with Several Modules¶
IBM DOORS 9 exports a project into one ReqIFZ. Every DOORS module is a ReqIF
SPECIFICATION; its objects are those its SPEC-HIERARCHY references. Every module brings
its own object type (without LONG-NAME) and its own copy of the datatypes under the same names,
and absolute numbers (ReqIF.ForeignID) are unique only within a module. The options of
this section make such an export a clean docs-as-code source — and keep it convertible back
into the same ReqIF (Updating the original export (update mode)).
All of them are opt-in, except where noted; without them the output stays as in 0.18.
A configuration that uses most of them:
[ubconnect.from_reqif]
reqif_path = "export.reqifz"
reqifz = true
output_format = "rst"
uuid_target = "reqif_uuid"
preserve_source_type = true
preserve_hierarchy = true
id_prefix_from = "ReqIF.Prefix" # "DPC -- SRS-" -> "DPC-SRS-"
images_target_dir = "_images"
attachments = "used" # only the pictures the RST shows
[ubconnect.from_reqif.attributes]
names = "normalize" # ReqIF.ForeignCreatedBy -> foreign_created_by
typed_values = true
[ubconnect.from_reqif.content]
format = "rst" # native RST instead of .. raw:: html
[ubconnect.from_reqif.tables]
doors = "rst" # one list-table per DOORS table
[ubconnect.from_reqif.mapping]
id = "ReqIF.ForeignID"
title = "ReqIF.ForeignID"
content = "ReqIF.Text"
[ubconnect.from_reqif.mapping.type]
source_attribute = "ObjectType"
unmapped = "slug" # Design Element -> design_element
value_map = { func = "Requirement" }
[ubconnect.from_reqif.section]
type_attribute = "ObjectType"
type_value = "Heading"
name_attribute = "ReqIF.ChapterName"
[ubconnect.from_reqif.rst]
mode = "per_section"
label_pattern = "{prefix}{absno}" # .. _dpc-srs-152:
ascii_file_names = true
index_title = "{ReqIF.Name}"
[ubconnect.from_reqif.links]
satisfies = ["Satisfies"] # SPEC-RELATION-TYPE by LONG-NAME
traces_to = ["Traces To"]
[[ubconnect.from_reqif.specifications]]
match = "DEMO-0003 *" # this module has no ReqIF.Prefix
id_prefix = "DPC-ICD-"
[ubconnect.to_reqif]
base = "export.reqifz" # the way back: update mode
Specifications¶
Every SPECIFICATION of the file is converted. per_section and per_need output of
several specifications goes to one sub-folder each (rst.spec_dir, default
"{spec_slug}"), and a top-level index.rst links their indexes; single_file and JSON
output write one file per specification. A single specification keeps the flat 0.18 layout.
select = ["DEMO-0001 *"]/--spec "DEMO-0001 *"(repeatable): convert only the specifications whose LONG-NAME matches a glob or whose IDENTIFIER is given.--list-specs: print every specification with IDENTIFIER, object count,ReqIF.Prefixand the values of the type attribute, then exit.Skipped specifications are named in a warning.
A file with several specifications always gets one folder per specification, also when
--specconverts only one of them; such a run leaves the top-levelindex.rstalone.
ID prefixes. Absolute numbers repeat across modules, so every module needs its own prefix. The prefix of a specification is, in this order:
id_prefixof its[[specifications]]entry,the value of the specification attribute
id_prefix_from(e.g.ReqIF.Prefix), normalised to a valid prefix: runs of other characters than[A-Za-z0-9_]become-("DPC -- SRS-"->"DPC-SRS-"),--id-prefix, elseid_prefix(defaultREQ_).
Two needs that would get the same ID are both named in a warning (module and absolute number);
the second one gets -2.
ID fallback chain. When only some objects carry a display ID, id takes a list; the
first entry that gives a value wins. An entry is an attribute name (its value as it is) or a
template:
[ubconnect.from_reqif.mapping]
id = ["ReqID", "{prefix}{ReqIF.ForeignID}"]
Per-specification settings. [[ubconnect.from_reqif.specifications]] entries apply to
the specifications they match (the first matching entry wins):
Key |
Meaning |
|---|---|
|
Glob on the LONG-NAME, or the IDENTIFIER (one of both is required). |
|
|
|
The ID prefix (wins over |
|
Output folder, relative to the global |
|
Title of the specification’s index page (as |
|
Merged key by key into the global table, e.g. a module-specific |
Attributes¶
[ubconnect.from_reqif.attributes] decides how attributes without an explicit mapping
become need fields.
names = "lower"(default, 0.18): valid option names are lower-cased; other names (Safety Relevance,ReqIF.ForeignCreatedBy) are dropped with a warning.names = "normalize": every attribute becomes a field. AReqIF.prefix is removed, CamelCase is split and other characters become_:ReqIF.ForeignCreatedBy->foreign_created_by,Safety Relevance->safety_relevance,TableCellWidth->table_cell_width. Two attributes that would get the same name stop the import with both names.include/exclude: glob patterns on the attribute LONG-NAME. Withnames = "normalize"the DOORS layout attributes (TableType,TableCell*,Table*Border,TableChangeBars,TableLinkIndicators,TableShow*,Picture,PictureName,PictureNum) are excluded by default. Excluded attributes are still read (tables, pictures and filters use them) and listed once.typed_values = true: INTEGER values become integers, REAL numbers, BOOLEAN booleans and multi-valued enumerations lists.
--ubproject-snippet FILE (or ubproject_snippet) writes a ubproject.toml fragment
with every need type ([[needs.types]]), link ([needs.links.*]) and field
([needs.fields.*] with a JSON schema type and the enumeration values) of the import, so a
ubc build validates without hand-written declarations.
Text: native RST¶
[ubconnect.from_reqif.content] format = "rst" converts the text attribute (the content
mapping) into native RST, which PDF builders render and search, linting and diffs can read.
format = "raw_html" (default) keeps the 0.18 .. raw:: html blocks; format = "text"
keeps only the words.
XHTML (as DOORS writes it) |
RST |
|---|---|
root |
paragraphs, no empty paragraphs |
literal newlines inside a |
a line block ( |
|
|
|
|
one |
one bullet list, nested by depth |
|
|
|
anonymous link `` text `` |
|
|
|
|
|
|
|
the characters ( |
Text that RST would read as markup is escaped: *, _ at the end of a word, backticks,
|, a trailing ::, backslashes, @ and the colon after a URI scheme
(https\://, mailto\:; no automatic links), and lines that start like a list, a
field, a comment or a transition. Leading blanks are dropped. Pictures inside text are
substitutions named after the object (|img-262-1|), so names stay unique when several
needs share a file; blanks in image paths are escaped.
An object whose XHTML cannot be converted gets fallback = "raw_html" (or "text") and
a warning naming its module and absolute number. The conversion is the exact inverse of the
way back (Updating the original export (update mode)): the RST turns into XHTML with the same meaning.
Note
With JSON output and Sphinx needimport, define the roles in conf.py, e.g.
rst_prolog = ".. role:: u\n.. role:: del\n".
DOORS tables¶
A DOORS table is a TableBase object (its text holds the rendered table) with TableRow
and TableCell objects below, all IS-TABLE-INTERNAL. [ubconnect.from_reqif.tables]:
doors = "cells"(default, 0.18): every table object is a need.doors = "rst": onelist-tablein place — inside the text of the parent need, or as a free-standing block in its chapter. No row or cell needs, no layout options. The cells’TableCellWidthbecome:widths:; the table carries:class: doors-tableand a:name:that identifies theTableBaseobject for the way back.doors = "need": one need ofneed_type(defaulttable) holding the RST table;doors = "raw": one need holding the rendered HTML.header_row = "auto"(a first row with only bold cells is the header),"always"or"never".
Pictures and attachments¶
DOORS writes the native file (OLE labelled text/rtf, BMP or WMF) around a PNG rendition.
With content.format = "rst":
The RST references the best rendition by
image_preference(default["png", "jpg", "jpeg", "gif", "svg", "bmp"]); OLE, RTF and WMF are never referenced.A picture object (
Picture = true, only a picture as text) becomes.. figure::with:alt:and the caption fromfigure_caption(defaultPictureName).Picture = truewithout image data is reported.Image paths are relative to each generated file, so no
images_ref_diris needed and the output can be split into folders.image_names = "need_id"names the extracted files after their need (DPC-SRS-262.png).
attachments = "used" extracts only the files that converted objects display; the natives
stay in the ReqIFZ for the way back (extract_natives = true extracts them as well).
attachments = "all" (default) extracts every attachment.
Filters and prose¶
[ubconnect.from_reqif.filter] decides which objects become needs. Every skipped object is
reported with module, absolute number and reason; its children move up one level.
skip_deleted = true(default): objects whosedeleted_attribute(defaultReqIF.ForeignDeleted) is true are skipped.skip_empty = true: objects without text and without children are skipped.include = { ObjectType = ["Requirement", "Text"] }/exclude = { "Safety Relevance" = ["none"] }: by attribute value.
[ubconnect.from_reqif.prose] object_types = ["Text"] writes objects of these types as
document text instead of needs, each with a label (.. _dpc-srs-205:, label = true) so
links onto them still resolve as references.
Labels, file names and titles¶
[ubconnect.from_reqif.rst]:
label_pattern = "{prefix}{absno}": heading labels from the heading object (.. _dpc-srs-152:), unique across modules and stable when a chapter is renamed; the heading’s IDENTIFIER is written as a comment above the label. Placeholders:{prefix},{absno},{uuid},{title_slug},{spec_slug}. Default: labels from the chapter name (0.18).ascii_file_names = true: ASCII file names (messgrößen->messgroessen).index_title = "{ReqIF.Name}": the title of each specification’s index ({spec}and every SPECIFICATION attribute are placeholders).numbered = true::numbered:toctrees, which restore DOORS-like heading numbers.
[ubconnect.from_reqif.title] generates titles for objects without a name:
template = "{prefix}{ReqIF.ForeignID}" and/or from_content = "first_sentence"
("first_line"), cut at a word boundary after max_length (default 80) characters;
fallback sets the order of the sources tried after the first one (template, else
from_content): "template", "from_content", "mapping"; the others follow.
Generated titles are never written back to ReqIF.
Large documents¶
rst.split_depth = 2:per_sectionwrites one file per level-2 chapter into a sub-folder of its root chapter, linked by a toctree.rst.max_lines = 3000: a chapter file that would be longer is split into one file per sub-chapter.nesting = "flatten": objects below an object are written after it as siblings and name their parent inparent_field(defaultparent; declare it as a link type), instead of nested directives. DOORS tables stay inside their parent’s text.
Re-import workflow¶
The output is deterministic: the same export and configuration give byte-identical files
(ordering, file names, labels; the JSON created timestamp is the export’s creation time).
rst.generated_header = truestarts every file with.. Generated by ubConnect from <file>; the next from-reqif run overwrites this file.--check: write nothing; exit with1when the output would change. A CI gate that tells when the DOORS export changed.--report FILE: write a JSON report of the needs the import adds, removes, moves (other chapter or parent) or changes (fields and a text diff), keyed by the ReqIF identifier; with--checknothing else is written.
Keep project-owned information (links to code and tests, review status) out of the generated
files, e.g. in needextend directives in a file of your own, so a re-import does not
overwrite it.
At the end of every run a summary lists, per specification, the objects read, the needs per type, the tables and paragraphs, the skipped objects, and the links and attachments.
Performance Diagnostics¶
For large datasets (10K+ needs), the to-reqif export may take several seconds.
Use --verbose to see a per-phase timing breakdown:
ubconnect reqif to-reqif --config ubproject.toml --verbose
The output includes timing for each internal phase:
create_reqif_bundle timing:
parse_need_items: 0.023s
create_spec_objects: 0.821s
build_hierarchy: 0.232s
TOTAL: 1.175s
XML serialization: 0.223s
This helps identify which phase dominates the export time for your specific dataset.