Skip to content

Commit

Permalink
Merge pull request #238 from melexis/hide_title
Browse files Browse the repository at this point in the history
Add flag to item-matrix to hide the title
  • Loading branch information
Letme authored Aug 2, 2021
2 parents 791a537 + b8a5737 commit 9b2e14f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions doc/integration_test_report.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ No relationships
:targettitle: nothing
:sourcetitle: more of nothing
:stats:
:hidetitle:
:coverage: == 0

All relationships
Expand Down
5 changes: 5 additions & 0 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ A traceability matrix of documentation items can be generated using:
:group: bottom
:nocaptions:
:stats:
:hidetitle:
:coverage: >= 99.5
Documentation items matching their ID to the given *source* regular expression end up in the leftmost column of the
Expand Down Expand Up @@ -373,6 +374,10 @@ limitations in doing so:
coverage/allocation percentage from these counts.
When omitted this percentage is not displayed.

:hidetitle: *optional*, *flag*

By providing the *hidetitle* flag, the title will be hidden.

:coverage: *optional*, *single argument*

The *coverage* option can be used to evaluate the coverage statistics. It expects an operator followed by
Expand Down
5 changes: 4 additions & 1 deletion mlx/directives/item_matrix_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def perform_replacement(self, app, collection):
targets_with_ids = []
for target_regex in self['target']:
targets_with_ids.append(collection.get_items(target_regex))
top_node = self.create_top_node(self['title'])
top_node = self.create_top_node(self['title'], hide_title=self['hidetitle'])
table = nodes.table()
if self.get('classes'):
table.get('classes').extend(self.get('classes'))
Expand Down Expand Up @@ -586,6 +586,7 @@ class ItemMatrixDirective(TraceableBaseDirective):
:coverage: Evaluation, e.g. >=95
:nocaptions:
:onlycaptions:
:hidetitle:
"""
# Optional argument: title (whitespace allowed)
optional_arguments = 1
Expand Down Expand Up @@ -613,6 +614,7 @@ class ItemMatrixDirective(TraceableBaseDirective):
'coverage': directives.unchanged,
'nocaptions': directives.flag,
'onlycaptions': directives.flag,
'hidetitle': directives.flag,
}
# Content disallowed
has_content = False
Expand Down Expand Up @@ -684,6 +686,7 @@ def run(self):
self.check_option_presence(node, 'onlycovered')
self.check_option_presence(node, 'coveredintermediates')
self.check_option_presence(node, 'stats')
self.check_option_presence(node, 'hidetitle')

if node['targetattributes']:
node['splittargets'] = True
Expand Down
28 changes: 16 additions & 12 deletions mlx/traceable_base_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,30 @@
class TraceableBaseNode(nodes.General, nodes.Element, ABC):
""" Base class for all Traceability node classes. """

def create_top_node(self, title, app=None):
''' Creates the top node for the Element node. An admonition object with given title is created and returns.
def create_top_node(self, title, app=None, hide_title=False):
''' Creates the top node for the Element node.
When the title should be shown, an admonition object with given title is added.
Args:
title (str): Title or item ID of the top node
app (sphinx.application.Sphinx): Optional application object, needed when item ID is given to create link
hide_title (bool): True to add the title in an admonition node; False to return an empty container node
Returns:
Top level replacement node to which other nodes can be appended
nodes.container: Top level replacement node to which other nodes can be appended
'''
top_node = nodes.container()
admon_node = nodes.admonition()
admon_node['classes'].append('item')
title_node = nodes.title()
if app:
title_node += self.make_internal_item_ref(app, title).children[0]
else:
title_node += nodes.Text(title)
admon_node += title_node
top_node += admon_node
if not hide_title:
admon_node = nodes.admonition()
admon_node['classes'].append('item')
title_node = nodes.title()
if app:
title_node += self.make_internal_item_ref(app, title).children[0]
else:
title_node += nodes.Text(title)
admon_node += title_node
top_node += admon_node
return top_node

@abstractmethod
Expand Down

0 comments on commit 9b2e14f

Please sign in to comment.