A Sphinx extension providing reports and summaries embedded in documentation pages.
Project description
Sphinx Reports
The Sphinx extension sphinx_reports
offers a set of directives to integrate reports and summaries into the
documentation generated by Sphinx.
Supported format reports are:
- ✅ Documentation coverage (by docstr_coverage (or
interrogate
?)) - 🚧 Code coverage (by Coverage.py)
- ✅ Summary page (displaying
coverage.json
) - 🚧 Highlighted source code
- ✅ Summary page (displaying
- ✅🚧 Unit Test summaries (by pytest)
- ✅ Summary page (displaying
unittest.xml
) - 🚧 Show logging, output and error messages.
- ✅ Summary page (displaying
- 🚧 Dependencies (reading
requirements.txt
files)
Extension Configuration
This README demonstrates a quick and minimal configuration for the Sphinx extension and it's provided directives. See the sphinx-reports documentation for more details.
At first, add the extension name to the list of extensions in conf.py
, so the extension is loaded by Sphinx.
# Sphinx extensions
extensions = [
# ...
"sphinx_reports",
]
Each report directive might require an individual configuration, therefore see the next sections for details.
Documentation Coverage
Documentation Coverage counts how many publicly accessible members are documented using a Python doc-string. Based on the count of possibly documented public members and the actual number of non-empty doc-strings, a percentage of documentation coverage can be computed.
Documentation coverage is a measure of code quality, which expresses how well documented (completeness or documentation, but not necessarily quality/helpfulness of documentation) source code is. Well documented code helps to use and maintain the existing code base. It also allows for automated documentation generation.
Quick Configuration
This is a quick and minimal configuration for the documentation coverage directives. See documentation coverage documentation for more details.
-
Configure one or more Python packages for documentation coverage analysis in
conf.py
by adding a new 'section' defining some configuration variables. Each package is identified by an ID, which is later referred to by the report directive. Here, the ID is calledsrc
(dictionary key). Each package needs 4 configuration entries:name
- Name of the Python package[^1].directory
- The directory of the package to analyze.fail_below
- An integer value in range 0..100, for when a documentation coverage is considered FAILED.levels
- A dictionary of coverage limits, their description and CSS style classes.
# ============================================================================== # Sphinx-reports - DocCov # ============================================================================== report_doccov_packages = { "src": { "name": "myPackage", "directory": "../myPackage", "fail_below": 80, "levels": { 30: {"class": "report-cov-below30", "desc": "almost undocumented"}, 50: {"class": "report-cov-below50", "desc": "poorly documented"}, 80: {"class": "report-cov-below80", "desc": "roughly documented"}, 90: {"class": "report-cov-below90", "desc": "well documented"}, 100: {"class": "report-cov-below100", "desc": "excellent documented"}, "error": {"class": "report-cov-error", "desc": "internal error"}, }, } }
-
Add the
doc-coverage
directive into your Restructured Text (ReST) document.packageid
- The ID used inconf.py
to describe a Python package.legend
(optional) - Position of the legend (no_legend
,top
,bottom
,both
)
.. report:doc-coverage:: :packageid: src
Code Coverage
Code Coverage checks if a source code was used during execution. Usually, testcases are run by a testcase execution
framework like pytest, which also offers to instrument the code for code
coverage collection using the pytest-cov
plugin. For Python, coverage collection is usually based on
Coverage.py, which supports statement and branch coverage collection.
Quick Configuration
This is a quick and minimal configuration for the code coverage directives. See code coverage documentation for more details.
-
Configure one or more coverage analysis reports in
conf.py
by adding a new 'section' defining some configuration variables. Each analysis report is identified by an ID, which is later referred to by the report directive. Here, the ID is calledsrc
(dictionary key). Each analysis report needs 4 configuration entries:name
- Name of the Python package[^1].json_report
- The code coverage report as JSON file as generated by Coverage.py.fail_below
- An integer value in range 0..100, for when a code coverage is considered FAILED.levels
- A dictionary of coverage limits, their description and CSS style classes.
# ============================================================================== # Sphinx-reports - CodeCov # ============================================================================== report_codecov_packages = { "src": { "name": "myPackage", "json_report": "../report/coverage/coverage.json", "fail_below": 80, "levels": { 30: {"class": "report-cov-below30", "desc": "almost unused"}, 50: {"class": "report-cov-below50", "desc": "poorly used"}, 80: {"class": "report-cov-below80", "desc": "medium used"}, 90: {"class": "report-cov-below90", "desc": "well well"}, 100: {"class": "report-cov-below100", "desc": "excellent used"}, "error": {"class": "report-cov-error", "desc": "internal error"}, }, } }
-
Add the
code-coverage
directive into your Restructured Text (ReST) document.packageid
- The ID used inconf.py
to describe a Python package.legend
(optional) - Position of the legend (no_legend
,top
,bottom
,both
)
.. report:code-coverage:: :packageid: src
Unit Test Summary
UnitTest: write introduction
Dependencies
Dep: write introduction
Contributors
- Patrick Lehmann (Maintainer)
- and more...
License
This Python package (source code) is licensed under Apache License 2.0.
The accompanying documentation is licensed under Creative Commons - Attribution-4.0 (CC-BY 4.0).
SPDX-License-Identifier: Apache-2.0
[^1]: Toplevel Python packages can reside in a directory not matching the package name. This is possible because the
toplevel package name is set in the package installation description. This is not good practice, but possible and
unfortunately widely used. E.g. src
as directory name.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sphinx_reports-0.7.5.tar.gz
.
File metadata
- Download URL: sphinx_reports-0.7.5.tar.gz
- Upload date:
- Size: 31.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4a16b234a2f9ee1ceb073e052efdbf467084046a055deeb811433f7c4732605 |
|
MD5 | 3a8600258f36cd911f71a2ebf2d8f273 |
|
BLAKE2b-256 | ef5750effe71406d3d6ac0783f2050140facce934bba6bd8e6ae7decb9c5dbcf |
File details
Details for the file sphinx_reports-0.7.5-py3-none-any.whl
.
File metadata
- Download URL: sphinx_reports-0.7.5-py3-none-any.whl
- Upload date:
- Size: 40.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dae7b64da77a10547d14d0b78829f7c7a4a444dfc91281c86f539af36c22767a |
|
MD5 | 4dd1806c898da915297dc06aca74b487 |
|
BLAKE2b-256 | 6f180b888891f28d3b7e9a314441ab4bea8785439cb1437edd59a44c0183e82d |