Skip to content

Commit

Permalink
Add noshow option to selectively show relations on items
Browse files Browse the repository at this point in the history
  • Loading branch information
Stein Heselmans authored and Stein Heselmans committed Dec 12, 2024
1 parent e513981 commit ef4c85d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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:
:noshow: validated_by
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 *noshow* is a space-seperated list of relation types. The relations to other items will not be shown for the
mentioned relation types.

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['noshow']:
self._list_targets_for_relation(rel, targets, *args)

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,
'noshow': 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,
{
'noshow': {'default': []},
},
)
item = self._store_item_info(target_id, env)
if item is None:
return []
Expand Down

0 comments on commit ef4c85d

Please sign in to comment.