Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11.0-rc.1"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand Down
23 changes: 21 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@

...

<a name="2.3.2"></a>
## [2.3.2] (2024-05-07)

### Changes
- Unpin TQDM version requirement. [#142] by [MiWeiss].

<a name="2.3.1"></a>
## [2.3.1] (2024-02-28)

### Features
- Add support for Python 3.12. [#139] by [MiWeiss].

### Deprecations
- Remove support for Python 3.7. [#139] by [MiWeiss].


<a name="2.3.0"></a>
## [2.3.0] (2023-04-13)
Expand Down Expand Up @@ -162,7 +177,9 @@
* Initial release


[Unreleased]: https://github.com/HunterMcGushion/docstr_coverage/compare/v2.3.0...HEAD
[Unreleased]: https://github.com/HunterMcGushion/docstr_coverage/compare/v2.3.2...HEAD
[2.3.2]: https://github.com/HunterMcGushion/docstr_coverage/compare/v2.3.1...v2.3.2
[2.3.1]: https://github.com/HunterMcGushion/docstr_coverage/compare/v2.3.0...v2.3.1
[2.3.0]: https://github.com/HunterMcGushion/docstr_coverage/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/HunterMcGushion/docstr_coverage/compare/v2.1.1...v2.2.0
[2.1.1]: https://github.com/HunterMcGushion/docstr_coverage/compare/v2.1.0...v2.1.1
Expand Down Expand Up @@ -219,4 +236,6 @@
[#87]: https://github.com/HunterMcGushion/docstr_coverage/pull/87
[#106]: https://github.com/HunterMcGushion/docstr_coverage/pull/106
[#116]: https://github.com/HunterMcGushion/docstr_coverage/pull/116
[#117]: https://github.com/HunterMcGushion/docstr_coverage/pull/117
[#117]: https://github.com/HunterMcGushion/docstr_coverage/pull/117
[#139]: https://github.com/HunterMcGushion/docstr_coverage/pull/139
[#142]: https://github.com/HunterMcGushion/docstr_coverage/pull/142
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ docstr-coverage some_project/src

#### Options

- _--destination=\<type\>, -dst \<type\>_ - Set the results output destination (default stdout)
- stdout - Output to standard STDOUT.
- file - Save output to file.
- _--format=\<type\>, -frm \<type\>_ - Set output style (default text)
- text - Output in simple style.
- markdown - Output in Markdown notation.
- _--skip-magic, -m_ - Ignore all magic methods (except `__init__`)
- _--skip-init, -i_ - Ignore all `__init__` methods
- _--skip-file-doc, -f_ - Ignore module docstrings (at the top of files)
Expand Down Expand Up @@ -178,7 +184,7 @@ and configuring the `paths` section of the [`.docstr.yaml` config](#config-file)
```yaml
repos:
- repo: https://github.com/HunterMcGushion/docstr_coverage
rev: v2.3.0 # most recent docstr-coverage release or commit sha
rev: v2.3.2 # most recent docstr-coverage release or commit sha
hooks:
- id: docstr-coverage
args: ["--verbose", "2"] # override the .docstr.yaml to see less output
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = "Hunter McGushion"

version = "" # The short X.Y version
release = "2.3.0" # The full version, including alpha/beta/rc tags
release = "2.3.2" # The full version, including alpha/beta/rc tags

##################################################
# General Configuration
Expand Down
8 changes: 6 additions & 2 deletions docstr_coverage/badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
[coverage-badge](https://github.com/dbrgn/coverage-badge) a star!"""

import os
import sys

import pkg_resources
if sys.version_info >= (3, 9):
from importlib.resources import files
else:
from importlib_resources import files

COLORS = {
"brightgreen": "#4c1",
Expand Down Expand Up @@ -80,7 +84,7 @@ def badge(self) -> str:
if self._badge is None:
value = "{:.0f}".format(self.coverage)
template_path = os.path.join("templates", "flat.svg")
template = pkg_resources.resource_string(__name__, template_path).decode("utf8")
template = files(__package__).joinpath(template_path).read_text(encoding="utf-8")
self._badge = template.replace("{{ value }}", value).replace("{{ color }}", self.color)
return self._badge

Expand Down
36 changes: 34 additions & 2 deletions docstr_coverage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from docstr_coverage.config_file import set_config_defaults
from docstr_coverage.coverage import analyze
from docstr_coverage.ignore_config import IgnoreConfig
from docstr_coverage.printers import LegacyPrinter
from docstr_coverage.printers import LegacyPrinter, MarkdownPrinter


def do_include_filepath(filepath: str, exclude_re: Optional["re.Pattern"]) -> bool:
Expand Down Expand Up @@ -261,6 +261,24 @@ def _assert_valid_key_value(k, v):
default=".docstr_coverage",
help="Deprecated. Use json config (--config / -C) instead",
)
@click.option(
"-dst",
"--destination",
type=click.Choice(["stdout", "file"]),
default="stdout",
help="Results output destination",
show_default=True,
metavar="DESTINATION",
)
@click.option(
"-frm",
"--format",
type=click.Choice(["text", "markdown"]),
default="text",
help="Format of output",
show_default=True,
metavar="FORMAT",
)
def execute(paths, **kwargs):
"""Measure docstring coverage for `PATHS`"""

Expand Down Expand Up @@ -328,7 +346,21 @@ def execute(paths, **kwargs):
show_progress = not kwargs["percentage_only"]
results = analyze(all_paths, ignore_config=ignore_config, show_progress=show_progress)

LegacyPrinter(verbosity=kwargs["verbose"], ignore_config=ignore_config).print(results)
report_format: str = kwargs["format"]
if report_format == "markdown":
printer = MarkdownPrinter(results, verbosity=kwargs["verbose"], ignore_config=ignore_config)
elif report_format == "text":
printer = LegacyPrinter(results, verbosity=kwargs["verbose"], ignore_config=ignore_config)
else:
raise SystemError("Unknown report format: {0}".format(report_format))

destination: str = kwargs["destination"]
if destination == "file":
printer.save_to_file()
elif destination == "stdout":
printer.print_to_stdout()
else:
raise SystemError("Unknown output type: {0}".format(destination))

file_results, total_results = results.to_legacy()

Expand Down
2 changes: 1 addition & 1 deletion docstr_coverage/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_docstring_coverage(
ignore_names=ignore_names,
)
results = analyze(filenames, ignore_config)
LegacyPrinter(verbosity=verbose, ignore_config=ignore_config).print(results)
LegacyPrinter(results, verbosity=verbose, ignore_config=ignore_config).print_to_stdout()
return results.to_legacy()


Expand Down
Loading