From 505c95bc38863cb8842cee8e65697e20ae3e55e7 Mon Sep 17 00:00:00 2001 From: JokeWaumans Date: Thu, 11 Jan 2024 11:31:20 +0100 Subject: [PATCH 1/8] Add documentation color test results to README --- README.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.rst b/README.rst index ea3ccd2..f6f0aa5 100644 --- a/README.rst +++ b/README.rst @@ -212,3 +212,16 @@ This requires you to configure the relationship `ext_robotframeworklog` in your .. _Free test suite metadata: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#free-test-suite-metadata .. _html_extra_path: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_extra_path .. _external relationship: https://melexis.github.io/sphinx-traceability-extension/configuration.html#external-relationship-to-url-translation + +Color Test Results +================== + +Use the [stylesheet](doc/source/_static/xunit2rst.css) get a background color for the test results (pass, fail and skip) +in the generated HTML documentation of the test case. +This feature is used in the `test reports`_. + +You can use the [stylesheet](doc/source/_static/xunit2rst.css) by adding it with `add_css_file`_ or by adding it +manually in you own stylesheet. + +.. _test reports: https://melexis.github.io/xunit2rst/generated/itest_report.html#test-reports +.. _add_css_file: https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_css_file From 7961729a2675b5e92a2e7163ed2b00539726d645 Mon Sep 17 00:00:00 2001 From: JokeWaumans Date: Thu, 11 Jan 2024 11:44:27 +0100 Subject: [PATCH 2/8] Change link to stylesheet --- README.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index f6f0aa5..ada9162 100644 --- a/README.rst +++ b/README.rst @@ -216,7 +216,7 @@ This requires you to configure the relationship `ext_robotframeworklog` in your Color Test Results ================== -Use the [stylesheet](doc/source/_static/xunit2rst.css) get a background color for the test results (pass, fail and skip) +Use the stylesheet_ get a background color for the test results (pass, fail and skip) in the generated HTML documentation of the test case. This feature is used in the `test reports`_. @@ -225,3 +225,4 @@ manually in you own stylesheet. .. _test reports: https://melexis.github.io/xunit2rst/generated/itest_report.html#test-reports .. _add_css_file: https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_css_file +.. _stylesheet: doc/source/_static/xunit2rst.css From c8797076e7029c7f946047a998d21811db771113 Mon Sep 17 00:00:00 2001 From: JokeWaumans Date: Thu, 11 Jan 2024 11:45:39 +0100 Subject: [PATCH 3/8] Use stylesheet link in other paragraph --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ada9162..f33a503 100644 --- a/README.rst +++ b/README.rst @@ -220,7 +220,7 @@ Use the stylesheet_ get a background color for the test results (pass, fail and in the generated HTML documentation of the test case. This feature is used in the `test reports`_. -You can use the [stylesheet](doc/source/_static/xunit2rst.css) by adding it with `add_css_file`_ or by adding it +You can use the stylesheet_ by adding it with `add_css_file`_ or by adding it manually in you own stylesheet. .. _test reports: https://melexis.github.io/xunit2rst/generated/itest_report.html#test-reports From 749032242915757890e7946bcb8752b1ab277dea Mon Sep 17 00:00:00 2001 From: jce Date: Thu, 11 Jan 2024 14:33:53 +0100 Subject: [PATCH 4/8] Move CSS file to mlx/assets; address deprecation warnings of pkg_resources --- MANIFEST.in | 3 +-- doc/source/_static/xunit2rst.css | 21 --------------------- doc/source/conf.py | 29 ++++++++++++++++------------- mlx/xunit2rst.py | 6 +++--- setup.py | 2 +- 5 files changed, 21 insertions(+), 40 deletions(-) delete mode 100644 doc/source/_static/xunit2rst.css diff --git a/MANIFEST.in b/MANIFEST.in index 1e8aedc..c798d16 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,6 +7,7 @@ recursive-include doc *.yml recursive-include doc Makefile include tox.ini recursive-include mlx *.mako +recursive-include mlx *.css exclude mlx/__xunit2rst_version__.py exclude .pylintrc @@ -16,5 +17,3 @@ recursive-include tests *.py recursive-include tests *.rst recursive-include tests *.xml exclude tests/test_out/* - -include doc/source/_static/xunit2rst.css diff --git a/doc/source/_static/xunit2rst.css b/doc/source/_static/xunit2rst.css deleted file mode 100644 index bb93389..0000000 --- a/doc/source/_static/xunit2rst.css +++ /dev/null @@ -1,21 +0,0 @@ -.xunit2rst { - padding: 2px 5px; - letter-spacing: 1px; - white-space: nowrap; - border-radius: 3px; -} - -.xunit2rst.skip { - color: black; - background-color: #fed84f; -} - -.xunit2rst.pass { - color: black; - background-color: #97bd61; -} - -.xunit2rst.fail { - color: white; - background-color: #ce3e01; -} diff --git a/doc/source/conf.py b/doc/source/conf.py index 9a30a37..2f751f7 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -5,9 +5,11 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html import os -import mlx.traceability -from pkg_resources import get_distribution +from importlib.metadata import distribution +from pathlib import Path +import mlx.traceability +import mlx.xunit2rst # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -21,16 +23,16 @@ authors = ['Bavo Van Achte', 'Jasper Craeghs'] # The full version, including alpha/beta/rc tags -release = get_distribution('mlx.xunit2rst').version +release = distribution('mlx.xunit2rst').version version = '.'.join(release.split('.')[:2]) latex_documents = [ - ('index', 'xunit2rst.tex', 'Script to convert .robot files to .rst files with traceable items', + ('index', 'xunit2rst.tex', 'Script to convert xUnit files to .rst files with traceable items', ' \\and '.join(authors), 'manual', True), ] man_pages = [ - ('index', 'xunit2rst', 'Script to convert .robot files to .rst files with traceable items', + ('index', 'xunit2rst', 'Script to convert xUnit files to .rst files with traceable items', authors, 1) ] @@ -41,7 +43,7 @@ # dir menu entry, description, category) texinfo_documents = [ ('index', 'xunit2rst', 'xunit2rst conversion script', '@*'.join(authors), 'xunit2rst', - 'Script to convert .robot files to .rst files with traceable items.', 'Miscellaneous'), + 'Script to convert xUnit files to .rst files with traceable items.', 'Miscellaneous'), ] # -- General configuration --------------------------------------------------- @@ -114,17 +116,18 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = [os.path.join(os.path.dirname(mlx.traceability.__file__), 'assets'), - '_static'] - -# These paths are either relative to html_static_path -# or fully qualified paths (eg. https://...) -html_css_files = [ - 'xunit2rst.css', +html_static_path = [ + str(Path(mlx.traceability.__file__).parent / 'assets'), + str(Path(mlx.xunit2rst.__file__).parent / 'assets'), ] traceability_render_relationship_per_item = True + def setup(app): + # Color Test Results + app.add_css_file('xunit2rst.css') + + # To demo --only input argument if os.environ.get('LAYER', 'FLASH') == 'FLASH': tags.add('FLASH') diff --git a/mlx/xunit2rst.py b/mlx/xunit2rst.py index 75acfb2..0e5d0fc 100644 --- a/mlx/xunit2rst.py +++ b/mlx/xunit2rst.py @@ -3,12 +3,12 @@ import logging import xml.etree.ElementTree as ET from collections import namedtuple +from importlib.metadata import distribution, PackageNotFoundError from pathlib import Path from textwrap import indent from mako.exceptions import RichTraceback from mako.template import Template -from pkg_resources import DistributionNotFound, require from ruamel.yaml import YAML TraceableInfo = namedtuple("TraceableInfo", ['matrix_prefix', 'type', 'header_prefix']) @@ -229,8 +229,8 @@ def verify_prefix_set(prefix_set, prefix, type_): def create_parser(): """ Creates and returns the ArgumentParser instance to be used """ try: - version = require('mlx.xunit2rst')[0].version - except DistributionNotFound: + version = distribution('mlx.xunitrst').version + except PackageNotFoundError: version = '0.0.0.dev' arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-i', '--input', diff --git a/setup.py b/setup.py index dd10d6d..e82fc06 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ ], platforms='any', packages=find_packages(exclude=['tests', 'doc']), - package_data={'mlx.xunit2rst': ['mlx/*.mako']}, + package_data={'mlx.xunit2rst': ['mlx/*.mako', 'mlx/assets/*']}, include_package_data=True, install_requires=requires, python_requires='>=3.7', From 649793b31ebdb1a8291d08a3d536c294f973f8f3 Mon Sep 17 00:00:00 2001 From: jce Date: Thu, 11 Jan 2024 14:56:34 +0100 Subject: [PATCH 5/8] Add moved CSS file --- mlx/assets/xunit2rst.css | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 mlx/assets/xunit2rst.css diff --git a/mlx/assets/xunit2rst.css b/mlx/assets/xunit2rst.css new file mode 100644 index 0000000..bb93389 --- /dev/null +++ b/mlx/assets/xunit2rst.css @@ -0,0 +1,21 @@ +.xunit2rst { + padding: 2px 5px; + letter-spacing: 1px; + white-space: nowrap; + border-radius: 3px; +} + +.xunit2rst.skip { + color: black; + background-color: #fed84f; +} + +.xunit2rst.pass { + color: black; + background-color: #97bd61; +} + +.xunit2rst.fail { + color: white; + background-color: #ce3e01; +} From 7b590be045dfecb55e0117cb6c995e50f021b92c Mon Sep 17 00:00:00 2001 From: jce Date: Thu, 11 Jan 2024 15:00:45 +0100 Subject: [PATCH 6/8] Deprecate Python 3.8 and test 3.12 --- .github/workflows/python-package.yml | 4 ++-- setup.py | 4 ++-- tox.ini | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b49dbd7..cfbb066 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -59,7 +59,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.7' + python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/setup.py b/setup.py index e82fc06..7448bbb 100644 --- a/setup.py +++ b/setup.py @@ -27,11 +27,11 @@ 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Documentation', 'Topic :: Documentation :: Sphinx', 'Topic :: Utilities', @@ -41,7 +41,7 @@ package_data={'mlx.xunit2rst': ['mlx/*.mako', 'mlx/assets/*']}, include_package_data=True, install_requires=requires, - python_requires='>=3.7', + python_requires='>=3.8', namespace_packages=['mlx'], keywords=['xUnit', 'JUnit', 'XML', 'reStructuredText', 'sphinx', 'rst', 'testing', 'traceability', 'documentation'], entry_points={ diff --git a/tox.ini b/tox.ini index 79b287a..caa31aa 100644 --- a/tox.ini +++ b/tox.ini @@ -2,25 +2,25 @@ envlist = clean, check, - py37, py38, py39, py310, py311 + py38, py39, py310, py311, py312 doc, [gh-actions] python = - 3.7: py37 3.8: py38 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] basepython = py: python3 - py37: {env:TOXPYTHON:python3.7} py38: {env:TOXPYTHON:python3.8} py39: {env:TOXPYTHON:python3.9} py310: {env:TOXPYTHON:python3.10} py311: {env:TOXPYTHON:python3.11} + py312: {env:TOXPYTHON:python3.12} {clean,check,codecov,doc}: python3 passenv = * From a0226df61fd30fb4cb04b206f4042b49ef8af664 Mon Sep 17 00:00:00 2001 From: JWM <62558419+JokeWaumans@users.noreply.github.com> Date: Thu, 11 Jan 2024 15:05:05 +0100 Subject: [PATCH 7/8] Rephrase documentation Co-authored-by: Jasper Craeghs <28319872+JasperCraeghs@users.noreply.github.com> --- README.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index f33a503..1870cd8 100644 --- a/README.rst +++ b/README.rst @@ -216,12 +216,13 @@ This requires you to configure the relationship `ext_robotframeworklog` in your Color Test Results ================== -Use the stylesheet_ get a background color for the test results (pass, fail and skip) -in the generated HTML documentation of the test case. -This feature is used in the `test reports`_. +You can highlight each test result (pass, fail and skip) in a different color so that they stand out +more from the rest of the report. +The element with the test result text contains two classes: `xunit2rst` and the test result itself. +For HTML documentation, you can use the CSS stylesheet_, provided with the Python package, +by passing it to Sphinx with `add_css_file`_, or by adding its contents manually to your own stylesheet. -You can use the stylesheet_ by adding it with `add_css_file`_ or by adding it -manually in you own stylesheet. +This feature is demonstrated in the `test reports`_ of the example documentation. .. _test reports: https://melexis.github.io/xunit2rst/generated/itest_report.html#test-reports .. _add_css_file: https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_css_file From 2b886cfe7e586c72f28e17652fd9b705424e902e Mon Sep 17 00:00:00 2001 From: Jasper Craeghs <28319872+JasperCraeghs@users.noreply.github.com> Date: Fri, 12 Jan 2024 23:04:06 +0100 Subject: [PATCH 8/8] Update path to CSS file --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 1870cd8..2123882 100644 --- a/README.rst +++ b/README.rst @@ -226,4 +226,4 @@ This feature is demonstrated in the `test reports`_ of the example documentation .. _test reports: https://melexis.github.io/xunit2rst/generated/itest_report.html#test-reports .. _add_css_file: https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_css_file -.. _stylesheet: doc/source/_static/xunit2rst.css +.. _stylesheet: mlx/xunit2rst/assets/xunit2rst.css