Skip to content

Commit

Permalink
Merge pull request #384 from melexis/expand-row-hint
Browse files Browse the repository at this point in the history
Improve usability of #382
  • Loading branch information
Letme authored Aug 2, 2024
2 parents 19d2e78 + 74b0dce commit 5caa1e4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ doc/_images

# Custom hyperlink colors
mlx/traceability/assets/hyperlink_colors.css

# Minified JS file
mlx/traceability/assets/traceability-*.min.js
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion mlx/traceability/assets/traceability.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = $('<div>', { class: 'content' });
Expand All @@ -76,6 +89,7 @@ $(document).ready(function () {
container.find('*').css("width", "inherit");
paragraph.append(container);
});
row.attr('title', titleOnVisible);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion mlx/traceability/traceability.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -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',
Expand Down Expand Up @@ -65,5 +71,5 @@
'ISO26262',
'ASIL',
],
package_data={'mlx.traceability': ['assets/*.js']},
package_data={'mlx.traceability': ['assets/traceability-*.js']},
)

0 comments on commit 5caa1e4

Please sign in to comment.