https://github.com/lelit/pycov-mode
A GNU/Emacs minor mode that displays coverage.py status in the left fringe of Python buffers
https://github.com/lelit/pycov-mode
Last synced: 2 months ago
JSON representation
A GNU/Emacs minor mode that displays coverage.py status in the left fringe of Python buffers
- Host: GitHub
- URL: https://github.com/lelit/pycov-mode
- Owner: lelit
- Created: 2021-12-08T12:55:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-22T20:06:39.000Z (over 3 years ago)
- Last Synced: 2025-01-19T06:43:17.551Z (4 months ago)
- Language: Emacs Lisp
- Size: 64.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pycov-mode
A GNU/Emacs minor mode that visualizes [`coverage.py`](https://coverage.readthedocs.io/)
status in the left fringe of Python buffers.This basically loads a `JSON` file exported by [`coverage
json`](https://coverage.readthedocs.io/en/6.0/cmd.html#cmd-json), and decorates the referenced
Python sources putting a symbol in the left fringe, showing *covered*, *uncovered* and
*ignored* lines. Whenever the file changes, the decorations will be updated accordingly.**Table of Contents**
- [pycov-mode](#pycov-mode)
- [Installation](#installation)
- [Usage](#usage)## Installation
As I do not foresee releasing the package on [`MELPA`](https://melpa.org/), you must install
this manually, copying the `pycov-mode.el` somewhere in your `load-path` and then activate it
in Python buffers:``` emacs-lisp
(add-hook 'python-mode-hook 'pycov-mode)
```If you use [`Doom Emacs`](https://github.com/hlissner/doom-emacs) then something like the
following should work:``` emacs-lisp
(package! pycov-mode
:recipe (:host github :repo "lelit/pycov-mode"))(use-package! pycov-mode
:hook
(python-mode . pycov-mode))
```## Usage
`pycov-mode` reads the `JSON` file pointed by the `pycov-coverage-file` per-buffer variable. I
usually have a `check` rule in my *Makefile*, something like``` makefile
check:
coverage run -m pytest
coverage json -o coverage.json
```that updates the *coverage.json* each time I run the tests.
The remaining missing piece is setting the variable `pycov-coverage-file`: as it's already
marked as *safe*, I usually have the following entry in my top level *.dir-locals.el* file:``` emacs-lisp
((python-mode . ((pycov-coverage-file . "coverage.json"))))
```