├── .editorconfig ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── AUTHORS.rst ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.rst ├── docs ├── Makefile ├── authors.rst ├── conf.py ├── contributing.rst ├── history.rst ├── index.rst ├── installation.rst ├── make.bat ├── readme.rst └── usage.rst ├── plot_coverage ├── __init__.py ├── cli.py ├── plot_coverage.py └── requirements.txt ├── requirements_dev.txt ├── setup.cfg ├── setup.py ├── sunburst.png ├── tests ├── __init__.py ├── mock_report.html └── test_plot_coverage.py ├── tox.ini └── treemap.png /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | * plot_coverage version: 2 | * Python version: 3 | * Operating System: 4 | 5 | ### Description 6 | 7 | Describe what you were trying to get done. 8 | Tell us what happened, what went wrong, and what you expected to happen. 9 | 10 | ### What I Did 11 | 12 | ``` 13 | Paste the command(s) you ran and the output. 14 | If there was a crash, please include the traceback here. 15 | ``` 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | 58 | # Flask stuff: 59 | instance/ 60 | .webassets-cache 61 | 62 | # Scrapy stuff: 63 | .scrapy 64 | 65 | # Sphinx documentation 66 | docs/_build/ 67 | 68 | # PyBuilder 69 | target/ 70 | 71 | # Jupyter Notebook 72 | .ipynb_checkpoints 73 | 74 | # pyenv 75 | .python-version 76 | 77 | # celery beat schedule file 78 | celerybeat-schedule 79 | 80 | # SageMath parsed files 81 | *.sage.py 82 | 83 | # dotenv 84 | .env 85 | 86 | # virtualenv 87 | .venv 88 | venv/ 89 | ENV/ 90 | 91 | # Spyder project settings 92 | .spyderproject 93 | .spyproject 94 | 95 | # Rope project settings 96 | .ropeproject 97 | 98 | # mkdocs documentation 99 | /site 100 | 101 | # mypy 102 | .mypy_cache/ 103 | 104 | # IDE settings 105 | .vscode/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - 3.8 4 | - 3.7 5 | - 3.6 6 | install: pip install -U tox-travis 7 | script: tox 8 | deploy: 9 | provider: pypi 10 | distributions: sdist bdist_wheel 11 | user: modasser 12 | password: 13 | secure: CthHm27DWnbv9t2Jn9+gqHWvXom/WywztPOuuin5GJj6R/fT66T0jBU8x6XIsKDqXFGZEPa2HhlvbH+pey9WkTwwu8E8ceDL94h7s1ZzH2hT/n5DoZ4cFYeI37P/IFTc60QnlEpod3X+igSqwmqbaBCq7OXY/EcMt1HcWKEKazBOZgns5/x/xRaJF8R17q3FQbQtjHg4nHrotStdxFJrBdkz24qKn/WLcmK1g2GdqP70O6uh7Wo2XhCS+60tYAcbD5ECbGLJfEwFylGALLveKNTTGqx4Qt5OaGshMXrZ1s5YC0FLkiwFEHzQl+yhMEa04/57Ef9ineQAQmLoEcCC3+rOysTjcZ1e0bzTQ+K5q8gg04Cex93oGqx16g5u3MrEt326Tjy0jKDluVvkibTmnMYbzEmgn8Y2lrzt4vq5mZl0bdRJm9TBHHHi7jfIOh2TUQ1lgQ3f6ByM08CLBvm1qn3bdbxS9Aqufl6LQfhFY7N3gzjEgT2CMP0l787waDlfl2Nx752Mx2i0qcJGRjpa8lAFNJAa6ZyKQAVbB9LScudVcZS/bGSNPm3+C/qhpZlQ4SwWmOKLjMXxOCDjj+I2SCuBE4ZcvbgWdA2IbAKEqK5L2dt1T+/ikGAbxmr28QR43hrVdHoRUkMPV+a2bWqT7y9jUU0RXNI1CHIo4NxSQt8= 14 | on: 15 | tags: true 16 | repo: modasserbillah/plot_coverage 17 | python: 3.8 18 | dd: 19 | secure: do+I0yMnjbbNCWNybkMoia+IIz5EKtqUR8h/sN14vykk/31A+ILCiM7jS81K6/LJkWNHyp9AWpVSs35qzmj900BtW96U63LHXhq3cR1h2aihB0KSVp+XtVs6dNutAdQ8yT+C/mv5qY0kcMq09lPKMUdylNaOblJYwl4+n6vIqnNvA17qAUJrj396hiqVCy+v/cOpTzElNntkn5fV8BKOJPqsMdpSLsyXnlYnPzda8MbgSB3YJrVAPVR/eN8Tgz5ZzBqG7e5V/zEUdv01XMNgyVv44XUfxxle6CQIZpirtQur3ad0/ZBBgm+PNxqj/Z/qCRoZg78UyPDQvc7FHTgtpVL+jgJp/l0cvOUxCAfaL/STihSxWWWJ+iXD2IDfRqVcFQZVZYilSTjNKzjHjBWg8K8ZD/EQClvMFokiTyHBD7Ai6JmtvhiIZo43lGpzYHtgQWG47bjNtiZm5kYTrc4lZzaDxWHL6FLWeAqDGfcCTGHaSLTB+o8U3z/hxRSTUrKoLzZzbVWcQfzRoHYaaVALIKw/UzdtD1/R3QDnLB4E9lyQhubACQN5S09yvKlVQThkU0sV8RDG73V4KAlowsd4cE3NcArGmlmGvPP9Uh10uDk4IDUDJVE3TYwxD9nA4YdA9jrn8A6Lm9uZyzJNhxcbb2EP5gPxugnWqvqxzO+9zbA= 20 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Modasser Billah 9 | 10 | Contributors 11 | ------------ 12 | 13 | None yet. Why not be the first? 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Contributing 5 | ============ 6 | 7 | Contributions are welcome, and they are greatly appreciated! Every little bit 8 | helps, and credit will always be given. 9 | 10 | You can contribute in many ways: 11 | 12 | Types of Contributions 13 | ---------------------- 14 | 15 | Report Bugs 16 | ~~~~~~~~~~~ 17 | 18 | Report bugs at https://github.com/modasserbillah/plot_coverage/issues. 19 | 20 | If you are reporting a bug, please include: 21 | 22 | * Your operating system name and version. 23 | * Any details about your local setup that might be helpful in troubleshooting. 24 | * Detailed steps to reproduce the bug. 25 | 26 | Fix Bugs 27 | ~~~~~~~~ 28 | 29 | Look through the GitHub issues for bugs. Anything tagged with "bug" and "help 30 | wanted" is open to whoever wants to implement it. 31 | 32 | Implement Features 33 | ~~~~~~~~~~~~~~~~~~ 34 | 35 | Look through the GitHub issues for features. Anything tagged with "enhancement" 36 | and "help wanted" is open to whoever wants to implement it. 37 | 38 | Write Documentation 39 | ~~~~~~~~~~~~~~~~~~~ 40 | 41 | plot_coverage could always use more documentation, whether as part of the 42 | official plot_coverage docs, in docstrings, or even on the web in blog posts, 43 | articles, and such. 44 | 45 | Submit Feedback 46 | ~~~~~~~~~~~~~~~ 47 | 48 | The best way to send feedback is to file an issue at https://github.com/modasserbillah/plot_coverage/issues. 49 | 50 | If you are proposing a feature: 51 | 52 | * Explain in detail how it would work. 53 | * Keep the scope as narrow as possible, to make it easier to implement. 54 | * Remember that this is a volunteer-driven project, and that contributions 55 | are welcome :) 56 | 57 | Get Started! 58 | ------------ 59 | 60 | Ready to contribute? Here's how to set up `plot_coverage` for local development. 61 | 62 | 1. Fork the `plot_coverage` repo on GitHub. 63 | 2. Clone your fork locally:: 64 | 65 | $ git clone git@github.com:your_name_here/plot_coverage.git 66 | 67 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 68 | 69 | $ mkvirtualenv plot_coverage 70 | $ cd plot_coverage/ 71 | $ python setup.py develop 72 | 73 | 4. Create a branch for local development:: 74 | 75 | $ git checkout -b name-of-your-bugfix-or-feature 76 | 77 | Now you can make your changes locally. 78 | 79 | 5. When you're done making changes, check that your changes pass flake8 and the 80 | tests, including testing other Python versions with tox:: 81 | 82 | $ flake8 plot_coverage tests 83 | $ python setup.py test or pytest 84 | $ tox 85 | 86 | To get flake8 and tox, just pip install them into your virtualenv. 87 | 88 | 6. Commit your changes and push your branch to GitHub:: 89 | 90 | $ git add . 91 | $ git commit -m "Your detailed description of your changes." 92 | $ git push origin name-of-your-bugfix-or-feature 93 | 94 | 7. Submit a pull request through the GitHub website. 95 | 96 | Pull Request Guidelines 97 | ----------------------- 98 | 99 | Before you submit a pull request, check that it meets these guidelines: 100 | 101 | 1. The pull request should include tests. 102 | 2. If the pull request adds functionality, the docs should be updated. Put 103 | your new functionality into a function with a docstring, and add the 104 | feature to the list in README.rst. 105 | 3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check 106 | https://travis-ci.com/modasserbillah/plot_coverage/pull_requests 107 | and make sure that the tests pass for all supported Python versions. 108 | 109 | Tips 110 | ---- 111 | 112 | To run a subset of tests:: 113 | 114 | $ pytest tests.test_plot_coverage 115 | 116 | 117 | Deploying 118 | --------- 119 | 120 | A reminder for the maintainers on how to deploy. 121 | Make sure all your changes are committed (including an entry in HISTORY.rst). 122 | Then run:: 123 | 124 | $ bump2version patch # possible: major / minor / patch 125 | $ git push 126 | $ git push --tags 127 | 128 | Travis will then deploy to PyPI if tests pass. 129 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | History 3 | ======= 4 | 5 | 1.0.0 (2020-06-25) 6 | ------------------ 7 | 8 | * First release on PyPI. 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | 3 | BSD License 4 | 5 | Copyright (c) 2020, Modasser Billah 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without modification, 9 | are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | * Redistributions in binary form must reproduce the above copyright notice, this 15 | list of conditions and the following disclaimer in the documentation and/or 16 | other materials provided with the distribution. 17 | 18 | * Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from this 20 | software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 26 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 29 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | 7 | recursive-include tests * 8 | recursive-exclude * __pycache__ 9 | recursive-exclude * *.py[co] 10 | 11 | recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean clean-test clean-pyc clean-build docs help 2 | .DEFAULT_GOAL := help 3 | 4 | define BROWSER_PYSCRIPT 5 | import os, webbrowser, sys 6 | 7 | from urllib.request import pathname2url 8 | 9 | webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) 10 | endef 11 | export BROWSER_PYSCRIPT 12 | 13 | define PRINT_HELP_PYSCRIPT 14 | import re, sys 15 | 16 | for line in sys.stdin: 17 | match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) 18 | if match: 19 | target, help = match.groups() 20 | print("%-20s %s" % (target, help)) 21 | endef 22 | export PRINT_HELP_PYSCRIPT 23 | 24 | BROWSER := python -c "$$BROWSER_PYSCRIPT" 25 | 26 | help: 27 | @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) 28 | 29 | clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts 30 | 31 | clean-build: ## remove build artifacts 32 | rm -fr build/ 33 | rm -fr dist/ 34 | rm -fr .eggs/ 35 | find . -name '*.egg-info' -exec rm -fr {} + 36 | find . -name '*.egg' -exec rm -f {} + 37 | 38 | clean-pyc: ## remove Python file artifacts 39 | find . -name '*.pyc' -exec rm -f {} + 40 | find . -name '*.pyo' -exec rm -f {} + 41 | find . -name '*~' -exec rm -f {} + 42 | find . -name '__pycache__' -exec rm -fr {} + 43 | 44 | clean-test: ## remove test and coverage artifacts 45 | rm -fr .tox/ 46 | rm -f .coverage 47 | rm -fr htmlcov/ 48 | rm -fr .pytest_cache 49 | 50 | lint: ## check style with flake8 51 | flake8 plot_coverage tests 52 | 53 | test: ## run tests quickly with the default Python 54 | pytest 55 | 56 | test-all: ## run tests on every Python version with tox 57 | tox 58 | 59 | coverage: ## check code coverage quickly with the default Python 60 | coverage run --source plot_coverage -m pytest 61 | coverage report -m 62 | coverage html 63 | $(BROWSER) htmlcov/index.html 64 | 65 | docs: ## generate Sphinx HTML documentation, including API docs 66 | rm -f docs/plot_coverage.rst 67 | rm -f docs/modules.rst 68 | sphinx-apidoc -o docs/ plot_coverage 69 | $(MAKE) -C docs clean 70 | $(MAKE) -C docs html 71 | $(BROWSER) docs/_build/html/index.html 72 | 73 | servedocs: docs ## compile the docs watching for changes 74 | watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . 75 | 76 | release: dist ## package and upload a release 77 | twine upload dist/* 78 | 79 | dist: clean ## builds source and wheel package 80 | python setup.py sdist 81 | python setup.py bdist_wheel 82 | ls -l dist 83 | 84 | install: clean ## install the package to the active Python's site-packages 85 | python setup.py install 86 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | plot_coverage 3 | ============= 4 | 5 | 6 | .. image:: https://img.shields.io/pypi/v/plot_coverage.svg 7 | :target: https://pypi.python.org/pypi/plot_coverage 8 | 9 | .. image:: https://img.shields.io/travis/modasserbillah/plot_coverage.svg 10 | :target: https://travis-ci.com/modasserbillah/plot_coverage 11 | 12 | 13 | 14 | 15 | 16 | Python package to generate plots from coverage report 17 | 18 | 19 | Generate visual plots to demonstrate your code coverage. Interactive plots are opened in the browser immediately 20 | after running the script. HTML files for the plots are stored alongside the coverage report inside `htmlcov` folder. 21 | 22 | Plots are generated using plotly express. 23 | 24 | 25 | Usage 26 | ------ 27 | * Install using `pip install plot-coverage` 28 | * From the project root (where htmlcov folder is located), run: 29 | - `plot_coverage --plot=treemap` 30 | - `plot_coverage --plot=sunburst` 31 | 32 | Note: Make sure htmlcov/index.html is present at the root of your project before running the above. So, `coverage html` 33 | should be run before attempting this. 34 | 35 | Example 36 | ------- 37 | 38 | Treemap 39 | ======== 40 | .. image:: https://raw.githubusercontent.com/modasserbillah/plot_coverage/master/treemap.png 41 | :alt: Treemap of coverage report 42 | :class: with-shadow 43 | :scale: 50 44 | 45 | Sunburst 46 | ========= 47 | .. image:: https://raw.githubusercontent.com/modasserbillah/plot_coverage/master/sunburst.png 48 | :alt: Sunburst of coverage report 49 | :class: with-shadow 50 | :scale: 50 51 | 52 | Features 53 | -------- 54 | 55 | * Generate Treemap plot for showing your coverage report with color sequence based on coverage percentage. 56 | * Generate Sunburst plot for showing your coverage report with color sequence based on coverage percentage. 57 | 58 | Credits 59 | ------- 60 | 61 | This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. 62 | 63 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 64 | .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage 65 | 66 | 67 | * Free software: BSD license -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = python -msphinx 7 | SPHINXPROJ = plot_coverage 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # plot_coverage documentation build configuration file, created by 4 | # sphinx-quickstart on Fri Jun 9 13:47:02 2017. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | # If extensions (or modules to document with autodoc) are in another 16 | # directory, add these directories to sys.path here. If the directory is 17 | # relative to the documentation root, use os.path.abspath to make it 18 | # absolute, like shown here. 19 | # 20 | import os 21 | import sys 22 | sys.path.insert(0, os.path.abspath('..')) 23 | 24 | import plot_coverage 25 | 26 | # -- General configuration --------------------------------------------- 27 | 28 | # If your documentation needs a minimal Sphinx version, state it here. 29 | # 30 | # needs_sphinx = '1.0' 31 | 32 | # Add any Sphinx extension module names here, as strings. They can be 33 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 34 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ['_templates'] 38 | 39 | # The suffix(es) of source filenames. 40 | # You can specify multiple suffix as a list of string: 41 | # 42 | # source_suffix = ['.rst', '.md'] 43 | source_suffix = '.rst' 44 | 45 | # The master toctree document. 46 | master_doc = 'index' 47 | 48 | # General information about the project. 49 | project = 'plot_coverage' 50 | copyright = "2020, Modasser Billah" 51 | author = "Modasser Billah" 52 | 53 | # The version info for the project you're documenting, acts as replacement 54 | # for |version| and |release|, also used in various other places throughout 55 | # the built documents. 56 | # 57 | # The short X.Y version. 58 | version = plot_coverage.__version__ 59 | # The full version, including alpha/beta/rc tags. 60 | release = plot_coverage.__version__ 61 | 62 | # The language for content autogenerated by Sphinx. Refer to documentation 63 | # for a list of supported languages. 64 | # 65 | # This is also used if you do content translation via gettext catalogs. 66 | # Usually you set "language" from the command line for these cases. 67 | language = None 68 | 69 | # List of patterns, relative to source directory, that match files and 70 | # directories to ignore when looking for source files. 71 | # This patterns also effect to html_static_path and html_extra_path 72 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 73 | 74 | # The name of the Pygments (syntax highlighting) style to use. 75 | pygments_style = 'sphinx' 76 | 77 | # If true, `todo` and `todoList` produce output, else they produce nothing. 78 | todo_include_todos = False 79 | 80 | 81 | # -- Options for HTML output ------------------------------------------- 82 | 83 | # The theme to use for HTML and HTML Help pages. See the documentation for 84 | # a list of builtin themes. 85 | # 86 | html_theme = 'alabaster' 87 | 88 | # Theme options are theme-specific and customize the look and feel of a 89 | # theme further. For a list of options available for each theme, see the 90 | # documentation. 91 | # 92 | # html_theme_options = {} 93 | 94 | # Add any paths that contain custom static files (such as style sheets) here, 95 | # relative to this directory. They are copied after the builtin static files, 96 | # so a file named "default.css" will overwrite the builtin "default.css". 97 | html_static_path = ['_static'] 98 | 99 | 100 | # -- Options for HTMLHelp output --------------------------------------- 101 | 102 | # Output file base name for HTML help builder. 103 | htmlhelp_basename = 'plot_coveragedoc' 104 | 105 | 106 | # -- Options for LaTeX output ------------------------------------------ 107 | 108 | latex_elements = { 109 | # The paper size ('letterpaper' or 'a4paper'). 110 | # 111 | # 'papersize': 'letterpaper', 112 | 113 | # The font size ('10pt', '11pt' or '12pt'). 114 | # 115 | # 'pointsize': '10pt', 116 | 117 | # Additional stuff for the LaTeX preamble. 118 | # 119 | # 'preamble': '', 120 | 121 | # Latex figure (float) alignment 122 | # 123 | # 'figure_align': 'htbp', 124 | } 125 | 126 | # Grouping the document tree into LaTeX files. List of tuples 127 | # (source start file, target name, title, author, documentclass 128 | # [howto, manual, or own class]). 129 | latex_documents = [ 130 | (master_doc, 'plot_coverage.tex', 131 | 'plot_coverage Documentation', 132 | 'Modasser Billah', 'manual'), 133 | ] 134 | 135 | 136 | # -- Options for manual page output ------------------------------------ 137 | 138 | # One entry per manual page. List of tuples 139 | # (source start file, name, description, authors, manual section). 140 | man_pages = [ 141 | (master_doc, 'plot_coverage', 142 | 'plot_coverage Documentation', 143 | [author], 1) 144 | ] 145 | 146 | 147 | # -- Options for Texinfo output ---------------------------------------- 148 | 149 | # Grouping the document tree into Texinfo files. List of tuples 150 | # (source start file, target name, title, author, 151 | # dir menu entry, description, category) 152 | texinfo_documents = [ 153 | (master_doc, 'plot_coverage', 154 | 'plot_coverage Documentation', 155 | author, 156 | 'plot_coverage', 157 | 'One line description of project.', 158 | 'Miscellaneous'), 159 | ] 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to plot_coverage's documentation! 2 | ====================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :caption: Contents: 7 | 8 | readme 9 | installation 10 | usage 11 | modules 12 | contributing 13 | authors 14 | history 15 | 16 | Indices and tables 17 | ================== 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | 8 | Stable release 9 | -------------- 10 | 11 | To install plot_coverage, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install plot_coverage 16 | 17 | This is the preferred method to install plot_coverage, as it will always install the most recent stable release. 18 | 19 | If you don't have `pip`_ installed, this `Python installation guide`_ can guide 20 | you through the process. 21 | 22 | .. _pip: https://pip.pypa.io 23 | .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ 24 | 25 | 26 | From sources 27 | ------------ 28 | 29 | The sources for plot_coverage can be downloaded from the `Github repo`_. 30 | 31 | You can either clone the public repository: 32 | 33 | .. code-block:: console 34 | 35 | $ git clone git://github.com/modasserbillah/plot_coverage 36 | 37 | Or download the `tarball`_: 38 | 39 | .. code-block:: console 40 | 41 | $ curl -OJL https://github.com/modasserbillah/plot_coverage/tarball/master 42 | 43 | Once you have a copy of the source, you can install it with: 44 | 45 | .. code-block:: console 46 | 47 | $ python setup.py install 48 | 49 | 50 | .. _Github repo: https://github.com/modasserbillah/plot_coverage 51 | .. _tarball: https://github.com/modasserbillah/plot_coverage/tarball/master 52 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=python -msphinx 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=plot_coverage 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The Sphinx module was not found. Make sure you have Sphinx installed, 20 | echo.then set the SPHINXBUILD environment variable to point to the full 21 | echo.path of the 'sphinx-build' executable. Alternatively you may add the 22 | echo.Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Usage 3 | ===== 4 | 5 | To use plot_coverage in a project:: 6 | 7 | import plot_coverage 8 | -------------------------------------------------------------------------------- /plot_coverage/__init__.py: -------------------------------------------------------------------------------- 1 | """Top-level package for plot_coverage.""" 2 | 3 | __author__ = """Modasser Billah""" 4 | __email__ = 'imtishad@gmail.com' 5 | __version__ = '1.0.2' 6 | -------------------------------------------------------------------------------- /plot_coverage/cli.py: -------------------------------------------------------------------------------- 1 | """Console script for plot_coverage.""" 2 | import sys 3 | import click 4 | from .plot_coverage import plot_coverage 5 | 6 | 7 | @click.command() 8 | @click.option("--plot", required=True, help="the type of plot you want (e.g, treemap, sunburst") 9 | def main(plot): 10 | """This package creates a visualization from the coverage report. 11 | 12 | Usage: 13 | 14 | plot_coverage --plot=treemap/sunburst 15 | """ 16 | plot_coverage(plot) 17 | return 0 18 | 19 | 20 | if __name__ == "__main__": 21 | sys.exit(main()) # pragma: no cover 22 | -------------------------------------------------------------------------------- /plot_coverage/plot_coverage.py: -------------------------------------------------------------------------------- 1 | """Main module.""" 2 | import os 3 | import pandas as pd 4 | import plotly.express as px 5 | from urllib.error import URLError 6 | 7 | 8 | def plot_coverage(plot): 9 | 10 | if plot.lower() not in ["treemap", "sunburst"]: 11 | print("Please provide a valid plot type with --plot=treemap / sunburst") 12 | return 13 | report_path = f"file:///{os.getcwd()}/htmlcov/index.html" 14 | 15 | try: 16 | # Assuming coverage report was generated and resides at htmlcov/index.html 17 | report_df = pd.read_html(report_path)[0] 18 | except URLError: 19 | print( 20 | "File not found! Please make sure your coverage report is in htmlcov/index.html" 21 | ) 22 | return 23 | except ValueError: 24 | print("Missing data. Your coverage report has no tables! ") 25 | return 26 | 27 | df, depth = prepare_data(report_df) 28 | fig = create_plot(df, depth, plot) 29 | fig.show() 30 | storage_path = f"htmlcov/coverage_{plot}.html" 31 | fig.write_html(storage_path) 32 | print(f"Plot saved to {storage_path}") 33 | 34 | 35 | def prepare_data(report_df): 36 | 37 | # Split the path into separate columns to feed into plotly 38 | path_columns = report_df["Module"].str.split("/", expand=True) 39 | depth = path_columns.shape[1] 40 | df = pd.concat([path_columns, report_df], axis=1) 41 | # coverage metric needs to be numeric for plotly 42 | df["coverage"] = df["coverage"].str.rstrip("%").astype("float") 43 | return df, depth 44 | 45 | 46 | def create_plot(df, depth, plot): 47 | path = [col for col in range(depth)] 48 | if plot.lower() == "treemap": 49 | treemap = px.treemap( 50 | df[:-1], # excludes the summary row 51 | path=path, 52 | color_continuous_scale=px.colors.diverging.RdYlGn, 53 | color="coverage", 54 | ) 55 | return treemap 56 | 57 | elif plot.lower() == "sunburst": 58 | sunburst = px.sunburst( 59 | df[:-1], 60 | path=path, 61 | color_continuous_scale=px.colors.diverging.RdYlGn, 62 | color="coverage", 63 | ) 64 | return sunburst 65 | 66 | print("Plot not supported. Please use either of treemap or sunburst.") -------------------------------------------------------------------------------- /plot_coverage/requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.9.1 2 | click==7.1.2 3 | html5lib==1.1 4 | pandas==1.0.5 5 | plotly==4.8.1 6 | lxml==4.5.1 7 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | pip==19.2.3 2 | bump2version==0.5.11 3 | wheel==0.33.6 4 | watchdog==0.9.0 5 | flake8==3.7.8 6 | tox==3.14.0 7 | coverage==4.5.4 8 | Sphinx==1.8.5 9 | twine==1.14.0 10 | Click==7.0 11 | pytest==4.6.5 12 | pytest-runner==5.1 -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 1.0.2 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | search = version='{current_version}' 8 | replace = version='{new_version}' 9 | 10 | [bumpversion:file:plot_coverage/__init__.py] 11 | search = __version__ = '{current_version}' 12 | replace = __version__ = '{new_version}' 13 | 14 | [bdist_wheel] 15 | universal = 1 16 | 17 | [flake8] 18 | exclude = docs 19 | 20 | [aliases] 21 | test = pytest 22 | 23 | [tool:pytest] 24 | collect_ignore = ['setup.py'] 25 | 26 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """The setup script.""" 4 | 5 | from setuptools import setup, find_packages 6 | 7 | with open('README.rst') as readme_file: 8 | readme = readme_file.read() 9 | 10 | with open('HISTORY.rst') as history_file: 11 | history = history_file.read() 12 | 13 | requirements = ['Click>=7.0', 'beautifulsoup4==4.9.1', 'html5lib==1.1', 'pandas==1.0.5', 'plotly==4.8.1', 'lxml==4.5.1'] 14 | 15 | setup_requirements = ['pytest-runner', ] 16 | 17 | test_requirements = ['pytest>=3', ] 18 | 19 | setup( 20 | author="Modasser Billah", 21 | author_email='imtishad@gmail.com', 22 | python_requires='>=3.6', 23 | classifiers=[ 24 | 'Development Status :: 2 - Pre-Alpha', 25 | 'Intended Audience :: Developers', 26 | 'License :: OSI Approved :: BSD License', 27 | 'Natural Language :: English', 28 | 'Programming Language :: Python :: 3', 29 | 'Programming Language :: Python :: 3.6', 30 | 'Programming Language :: Python :: 3.7', 31 | 'Programming Language :: Python :: 3.8', 32 | ], 33 | description="Python package to generate plots from coverage report", 34 | entry_points={ 35 | 'console_scripts': [ 36 | 'plot_coverage=plot_coverage.cli:main', 37 | ], 38 | }, 39 | install_requires=requirements, 40 | license="BSD license", 41 | long_description=readme + '\n\n' + history, 42 | include_package_data=True, 43 | keywords='plot_coverage', 44 | name='plot_coverage', 45 | packages=find_packages(include=['plot_coverage', 'plot_coverage.*']), 46 | setup_requires=setup_requirements, 47 | test_suite='tests', 48 | tests_require=test_requirements, 49 | url='https://github.com/modasserbillah/plot_coverage', 50 | version='1.0.2', 51 | zip_safe=False, 52 | ) 53 | -------------------------------------------------------------------------------- /sunburst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modasserbillah/plot_coverage/a2d3785bbc1c32be2b4b1d18806e4d6eacc0ecdb/sunburst.png -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Unit test package for plot_coverage.""" 2 | -------------------------------------------------------------------------------- /tests/mock_report.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Coverage report 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 27 |
28 | Hide keyboard shortcuts 29 |

Hot-keys on this page

30 |
31 |

32 | n 33 | s 34 | m 35 | x 36 | b 37 | p 38 | c   change column sorting 39 |

40 |
41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 |
Modulestatementsmissingexcludedbranchespartialcoverage
Total151490172783439.90%
cogapp/__init__.py20000100.00%
cogapp/__main__.py330000.00%
cogapp/backward.py22604269.23%
cogapp/cogapp.py48521512002849.34%
cogapp/makefiles.py2720014017.07%
cogapp/test_cogapp.py790549620030.00%
cogapp/test_makefiles.py715306023.38%
cogapp/test_whiteutils.py695000027.54%
cogapp/whiteutils.py455034488.61%
158 | 161 |
162 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /tests/test_plot_coverage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Tests for `plot_coverage` package.""" 4 | import pandas 5 | import pytest 6 | from click.testing import CliRunner 7 | 8 | from plot_coverage.plot_coverage import prepare_data 9 | from plot_coverage import cli 10 | 11 | 12 | @pytest.fixture 13 | def mock_df(): 14 | """Sample pytest fixture. 15 | 16 | See more at: http://doc.pytest.org/en/latest/fixture.html 17 | """ 18 | with open("tests/mock_report.html", "r") as data: 19 | df = pandas.read_html(data)[0] 20 | return df 21 | 22 | 23 | def test_command_line_interface(): 24 | """Test the CLI.""" 25 | runner = CliRunner() 26 | result = runner.invoke(cli.main) 27 | assert result.exit_code == 2 28 | assert 'Error: Missing option "--plot"' in result.output 29 | help_result = runner.invoke(cli.main, ["--help"]) 30 | assert help_result.exit_code == 0 31 | assert ( 32 | "This package creates a visualization from the coverage report" 33 | in help_result.output 34 | ) 35 | 36 | 37 | def test_prepare_data(mock_df): 38 | df, depth = prepare_data(mock_df) 39 | assert depth == 2 40 | assert df.shape[1] == 9 41 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py36, py37, py38, flake8 3 | 4 | [travis] 5 | python = 6 | 3.8: py38 7 | 3.7: py37 8 | 3.6: py36 9 | 10 | [testenv:flake8] 11 | basepython = python 12 | deps = flake8 13 | commands = flake8 plot_coverage tests 14 | 15 | [testenv] 16 | setenv = 17 | PYTHONPATH = {toxinidir} 18 | deps = 19 | -r{toxinidir}/requirements_dev.txt 20 | ; If you want to make tox run the tests with the same versions, create a 21 | ; requirements.txt with the pinned versions and uncomment the following line: 22 | ; -r{toxinidir}/requirements.txt 23 | commands = 24 | pip install -U pip 25 | pytest --basetemp={envtmpdir} 26 | 27 | -------------------------------------------------------------------------------- /treemap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modasserbillah/plot_coverage/a2d3785bbc1c32be2b4b1d18806e4d6eacc0ecdb/treemap.png --------------------------------------------------------------------------------