Skip to main content

A Python tool that checks the grammatical mood consistency of function and method docstrings.

Project description

docmood

A Python tool that checks the grammatical mood consistency of your function and method docstrings.

What it does

docmood scans your Python project and verifies that all function/method docstrings follow a consistent grammatical style:

  • Imperative mood: "Return the value", "Get the user", "Calculate the sum"
  • Third-person mood: "Returns the value", "Gets the user", "Calculates the sum"

Installation

From PyPI:

pip install docmood

Usage

Run in your project directory:

docmood .

Or as a module:

python -m docmood /path/to/project

Example Output

Failed docstrings:
  src/example.py:7 (detected: unknown, expected: imperative)
  src/foo_bar.py:7 (detected: unknown, expected: imperative)
========================================
[docmood] Found 20 docs: 18/20 passed (90%)

Configuration

docmood can be configured via pyproject.toml or docmood.ini in your project root.

Option 1: pyproject.toml (recommended)

Add a [tool.docmood] section:

[tool.docmood]
# Expected mood for all docstrings
# Options: "imperative" or "third_person"
# Default: "imperative"
mood = "imperative"

# Whether to allow docstrings with unknown/undetectable mood
# If true, unknown mood is counted as passed (with a warning)
# If false, unknown mood is counted as failed
# Default: true
allow_unknown = true

# Additional directory names to skip during scanning (added to defaults)
# Default dirs always skipped: .git, .hg, .svn, .mypy_cache, .pytest_cache, 
#   .ruff_cache, .tox, .nox, __pycache__, build, dist, site-packages, venv, .venv
# Example: skip_dirs = ["node_modules", "coverage"] will skip the defaults PLUS node_modules and coverage
skip_dirs = ["node_modules", "coverage"]

Option 2: docmood.ini

Create a docmood.ini file in your project root:

[docmood]
# Expected mood for all docstrings
# Options: imperative, third_person
# Default: imperative
mood = imperative

# Whether to allow docstrings with unknown/undetectable mood
# If true, unknown mood is counted as passed (with a warning)
# If false, unknown mood is counted as failed
# Default: true
allow_unknown = true

# Comma-separated list of ADDITIONAL directory names to skip during scanning
# These are added to the default skip directories
# Default skip directories: .git,.hg,.svn,.mypy_cache,.pytest_cache,.ruff_cache,.tox,.nox,__pycache__,build,dist,site-packages,venv,.venv
# Example: If you set skip_dirs = src,node_modules, then the following will be skipped:
#   .git,.hg,.svn,.mypy_cache,.pytest_cache,.ruff_cache,.tox,.nox,__pycache__,build,dist,site-packages,venv,.venv,src,node_modules
# skip_dirs = node_modules,coverage

See docmood.ini.example for a complete example with comments.

Configuration Options

Option Values Default Description
mood imperative, third_person imperative Expected grammatical mood for docstrings
allow_unknown true, false true Whether to treat undetectable mood as passed
skip_dirs List of directory names [] (empty) Additional directories to skip (added to defaults)

Directories always skipped by default: .git, .hg, .svn, .mypy_cache, .pytest_cache, .ruff_cache, .tox, .nox, __pycache__, build, dist, site-packages, venv, .venv

Note: The skip_dirs option is additive. If you specify skip_dirs = ["node_modules"], the tool will skip all default directories PLUS node_modules.

Exit Codes

  • 0: All docstrings passed
  • 1: One or more docstrings failed validation

Development

Development instructions live in CONTRIBUTING.md.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docmood-0.0.6.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docmood-0.0.6-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file docmood-0.0.6.tar.gz.

File metadata

  • Download URL: docmood-0.0.6.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for docmood-0.0.6.tar.gz
Algorithm Hash digest
SHA256 da39872b82f8051493ccb1a70480d908615e9e16cba87a2b6d38f8ae5a745bd7
MD5 5a5d72c0b5bd7752be8bbe392c27b8af
BLAKE2b-256 90c8e3e7d18af09b7132bbbcb78e7d6330b2906ae8c689f93668178f24081145

See more details on using hashes here.

Provenance

The following attestation bundles were made for docmood-0.0.6.tar.gz:

Publisher: publish-pypi.yml on Oleh-Stefanovych/docmood

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docmood-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: docmood-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for docmood-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a12b55b778a445125d6e0ee27edd8a2f4500d27809deb778748d6f86d80ed6ce
MD5 d926d8cba484baf3d87c8c1eec325b82
BLAKE2b-256 d049f82cff96057730b202bff023575da34c32154a1d34245f45044dbf15e08c

See more details on using hashes here.

Provenance

The following attestation bundles were made for docmood-0.0.6-py3-none-any.whl:

Publisher: publish-pypi.yml on Oleh-Stefanovych/docmood

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page