diff --git a/.gitignore b/.gitignore
index 1906f64f..36f94781 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,6 @@ doc/_images
# Custom hyperlink colors
mlx/traceability/assets/hyperlink_colors.css
+
+# Minified JS file
+mlx/traceability/assets/traceability-*.min.js
diff --git a/MANIFEST.in b/MANIFEST.in
index f4b4acb9..a3857dc0 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -2,7 +2,8 @@
include *.md
# Include the assets - javascript
-include mlx/traceability/assets/*.js
+include mlx/traceability/assets/traceability.js
+exclude mlx/traceability/assets/traceability-*.min.js
exclude mlx/traceability/__traceability_version__.py
diff --git a/mlx/traceability/assets/traceability.js b/mlx/traceability/assets/traceability.js
index e17252f1..73a55c48 100644
--- a/mlx/traceability/assets/traceability.js
+++ b/mlx/traceability/assets/traceability.js
@@ -57,8 +57,15 @@ $(document).ready(function () {
});
$('table > tbody > tr[class^=item-group-]').each(function (i) {
+ var row = $(this);
+ const titleOnHidden = 'Ctrl+RMB to expand';
+ const titleOnVisible = 'Ctrl+RMB to collapse';
+ row.attr('title', titleOnHidden);
$(this).on("contextmenu",
function (event) {
+ if (!event.ctrlKey) {
+ return;
+ }
event.preventDefault()
var groupName = /item-group-\d+/.exec($(this).attr('class'))[0];
$(this).parent().find(`tr.${groupName} > td > p.item-link`).each(function (j) {
@@ -67,7 +74,13 @@ $(document).ready(function () {
cell.css("maxWidth", maxWidth);
const content = $(this).children('div.content').first();
if (content.length) {
- content.toggle();
+ if (content.is(":visible")) {
+ content.hide();
+ row.attr('title', titleOnHidden);
+ } else {
+ row.attr('title', titleOnVisible);
+ content.show();
+ }
} else {
var link = $(this).children('a').first();
var container = $('
', { class: 'content' });
@@ -76,6 +89,7 @@ $(document).ready(function () {
container.find('*').css("width", "inherit");
paragraph.append(container);
});
+ row.attr('title', titleOnVisible);
}
});
}
diff --git a/mlx/traceability/traceability.py b/mlx/traceability/traceability.py
index 2f6f3bcc..e4ebdafb 100644
--- a/mlx/traceability/traceability.py
+++ b/mlx/traceability/traceability.py
@@ -479,7 +479,7 @@ def setup(app):
# Javascript and stylesheet for the tree-view
app.add_js_file('https://cdn.rawgit.com/aexmachina/jquery-bonsai/master/jquery.bonsai.js')
app.add_css_file('https://cdn.rawgit.com/aexmachina/jquery-bonsai/master/jquery.bonsai.css')
- app.add_js_file('traceability.js')
+ app.add_js_file(f'traceability-{version}.min.js')
# Since Sphinx 6, jquery isn't bundled anymore and we need to ensure that
# the sphinxcontrib-jquery extension is enabled.
diff --git a/pyproject.toml b/pyproject.toml
index ba5cd66d..889a6227 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,5 @@
[build-system]
-requires = ["setuptools>=61", "setuptools_scm>=7.1.0"]
+requires = ["setuptools>=61", "setuptools_scm>=7.1.0", "css-html-js-minify>=2.5.5,<3"]
build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
diff --git a/setup.py b/setup.py
index 68758e89..98a63740 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-
+from css_html_js_minify import process_single_js_file
from setuptools import setup, find_namespace_packages
+from setuptools_scm import get_version
+version = get_version()
+
project_url = 'https://github.com/melexis/sphinx-traceability-extension'
requires = [
@@ -13,6 +17,8 @@
'python-decouple',
'requests',
]
+js_file_path = 'mlx/traceability/assets/traceability.js'
+process_single_js_file(js_file_path, output_path=js_file_path.replace('.js', f'-{version}.min.js'))
setup(
name='mlx.traceability',
@@ -65,5 +71,5 @@
'ISO26262',
'ASIL',
],
- package_data={'mlx.traceability': ['assets/*.js']},
+ package_data={'mlx.traceability': ['assets/traceability-*.js']},
)