Skip to content

Commit

Permalink
Merge pull request #222 from melexis/item_list_content
Browse files Browse the repository at this point in the history
Add flag to item-list to show contents of items
  • Loading branch information
Letme authored Jun 18, 2021
2 parents 490b36b + 0117942 commit e7e96db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
5 changes: 3 additions & 2 deletions doc/integration_test_report.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ List all items
:nocaptions:


List all items beginning with ``r00``
-------------------------------------
List all items beginning with ``r00`` (show contents)
-----------------------------------------------------

.. item-list::
:filter: ^r00
:showcontents:

List system requirements (beginning with SYS)
---------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,20 @@ A flat list of documentation items can be generated using a Python regular expre
:filter: SWRQT
:status: Appr
:nocaptions:
:showcontents:
where *SWRQT* (*filter* argument) can be replaced by any Python regular expression. Documentation items matching
their ID to the given regular expression end up in the list.

where *status* can be replaced by any configured attribute, and *Appr* can be replaced by any Python regular
expression. Documentation items where the *status* attribute matches the given regular expression end up in the list.

By default, the caption for every item in the list is shown. By providing the *nocaptions* flag, the
By default, the caption of every item in the list is shown. By providing the *nocaptions* flag, the
caption can be omitted. This gives a smaller list, but also less details.

By default, the contents of every item in the list is hidden. By providing the *showcontents* flag, the
contents can be shown. This can significantly lengthen the list.

.. _traceability_usage_item_attributes_matrix:

---------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions mlx/assets/traceability.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ $(document).ready(function () {
);
});

// style item contents in item-list by rendering newlines and adding indent
$('.item-contents').each(function (i) {
$(this).css('white-space', 'pre-wrap');
$(this).css('padding-left', '1em');
});

$('p.admonition-title').each(function (i) {
$(this).children('a').first().denyPermalinkStyling($(this));
});
Expand Down
10 changes: 10 additions & 0 deletions mlx/directives/item_list_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def perform_replacement(self, app, collection):
for i in item_ids:
bullet_list_item = nodes.list_item()
bullet_list_item.append(self.make_internal_item_ref(app, i))
if self['showcontents']:
contents = collection.get_item(i).get_content()
if contents:
p_node = nodes.paragraph(text=contents)
p_node['classes'].append('item-contents')
bullet_list_item.append(p_node)
ul_node.append(bullet_list_item)
top_node += ul_node
self.replace_self(top_node)
Expand All @@ -37,6 +43,7 @@ class ItemListDirective(TraceableBaseDirective):
:filter: regexp
:<<attribute>>: regexp
:nocaptions:
:showcontents:
"""
# Optional argument: title (whitespace allowed)
Expand All @@ -46,6 +53,7 @@ class ItemListDirective(TraceableBaseDirective):
'class': directives.class_option,
'filter': directives.unchanged,
'nocaptions': directives.flag,
'showcontents': directives.flag,
}
# Content disallowed
has_content = False
Expand All @@ -71,6 +79,8 @@ def run(self):

self.add_found_attributes(item_list_node)

self.check_option_presence(item_list_node, 'showcontents')

self.check_caption_flags(item_list_node, app.config.traceability_list_no_captions)

return [item_list_node]

0 comments on commit e7e96db

Please sign in to comment.