Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to item-directive to hide specific relation-types #389

Merged
merged 12 commits into from
Dec 18, 2024
4 changes: 4 additions & 0 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ Documentation items can be defined using the *item* directive, specifying:
:validated_by: ITEST-MY_FIRST_INTEGRATION_TEST
:ext_polarion_reference: project_x:workitem_y
:nocaptions:
:hidelinks: validated_by
JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved

According to the Polarion reference, the software **shall** implement my first requirement.

Attributes can be added to the item, using the configured attribute keys in :ref:`traceability_default_config`
(e.g. *value* in the above example). The content of the attribute is treated as a single string and should
match_ the regular expression in configuration.

The *hidelinks* is a space-seperated list of relation types. The relations to other items will not be shown for the
mentioned relation types below the item. The links will still be used and displayed in traceability matrixes and other directives.

JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved
The relations to other documentation items can be specified as:

- a space-separated list of item ID's, or
Expand Down
10 changes: 9 additions & 1 deletion mlx/traceability/directives/item_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def _process_relationships(self, *args):
All targets get naturally sorted per relationship.
"""
for rel, targets in self._item.all_relations:
self._list_targets_for_relation(rel, targets, *args)
if rel not in self['hidelinks']:
self._list_targets_for_relation(rel, targets, *args)
JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved

def _list_targets_for_relation(self, relation, targets, dl_node, app):
""" Add a list with all targets for a specific relation to the given definition list.
Expand Down Expand Up @@ -129,6 +130,7 @@ class ItemDirective(TraceableBaseDirective):
option_spec = {
'class': directives.class_option,
'nocaptions': directives.flag,
'hidelinks': directives.unchanged,
}
# Content allowed
has_content = True
Expand All @@ -149,6 +151,12 @@ def run(self):
item_node['classes'].append('collapse')
if 'class' in self.options:
item_node['classes'].extend(self.options.get('class'))
self.process_options(
item_node,
{
'hidelinks': {'default': []},
},
)
item = self._store_item_info(target_id, env)
if item is None:
return []
Expand Down
1 change: 1 addition & 0 deletions tests/directives/test_item_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def setUp(self):
self.node['document'] = 'some_doc'
self.node['id'] = 'some_id'
self.node['line'] = 1
self.node['hidelinks'] = []
self.item = TraceableItem(self.node['id'])
self.item.set_location(self.node['document'], self.node['line'])
self.item.node = self.node
Expand Down
Loading