The field names of a service object do not often map to option names of Sphinx-Needs.
So
mapping
defines where a Sphinx-Needs option shall get its value inside the service data.
mapping
must be a dictionary, where the
key
is the needs object name and the
value
is either
a Jinja string such as
is_{{status}}
or a list/tuple, which defines the location of the value in the retrieved
service data object.
Example using a Jinja string as value for the Excel service
Goal: The need option
author
shall be set to both the Last and First names.
The last and first names information are stored in the retrieved Excel data under
LAST_NAME
and
FIRST_NAME
.
When you use a Jinja string as value, you must ensure the field names of a service object,
set as values for the mapping option, does not contain spaces because that will raise a
Jinja Template Syntax Error
.
For example: Instead of the column name being
CREATED
AT
use
CREATED_AT
. Read more about the
mapping
configuration.
Example using a list/tuple as value for the Codebeamer service
Goal: The need option
author
shall be set to the Assignee name.
This information is stored in the retrieved Codebeamer json data under
assignedTo.0.name
.
So the final
mapping
entry looks like:
'mapping':{'author':['assignedTo',0,'name'],}
Note
Combining data from multiple locations in a mapping definition is currently not supported.
content
takes a string, which gets interpreted as rst-code for the need-content area.
Jinja support is also available, so that service data is available and can be accessed like
{{data.description}}
.
Example for a Codebeamer configuration:
my_content="""Content from Codebeamer Issue-----------------------------``{{data.description}}``.This is assigned to **{{data.assignedTo[0].name]}}**.`Link to source <http://my_server/issue/{{data.id}}>`_"""needs_services={'codebeamer':{# ... some other values'content':my_content}}
The set options for the
needservice
are available under
options
. Example:
There may be information stored inside a service’s data fields that can not be mapped to Sphinx-Needs options, but
shall be made available inside the needed object.
This can be done by using
extra_data
, which adds this kind of information to the end of the content of a
need object.
The logic and syntax are the same as used by
mapping
.
Outputs the needed content to a codeblock without any modifications.
For some services a content transformation (e.g. wiki-syntax to HTML or rst) is needed, to get a nice looking and
“working” representation of the content.