Skip to main content

Minimal docstring mood tool (demo)

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

[docmood] Checking that all method docstrings use imperative mood

⚠ Warning: Found 2 docstrings with unknown mood:
  src/example.py:10
  src/example.py:25
  (These are counted as passed because allow_unknown=true)

[docmood] Found 15 method docs: 13/15 passed (87%)

Failed docstrings:
  src/utils.py:42 (detected: third person)
  src/helpers.py:18 (detected: third person)

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]
mood = imperative
allow_unknown = true
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.3.tar.gz (10.3 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.3-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docmood-0.0.3.tar.gz
  • Upload date:
  • Size: 10.3 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.3.tar.gz
Algorithm Hash digest
SHA256 28fae576ebbb1a3fec8bed98124577cc17fcb65f3e6c714771e66e34ff540ad0
MD5 37d5e95ea3d8c641e4ae41661d789c33
BLAKE2b-256 7b0c84d6752fda388f291fc0f361fa4b652a83fa7b0f4060fd8715c82cb21c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for docmood-0.0.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: docmood-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 925f84aaf348e2129aab7c3195b49ef1722b70791370a9dbdc687345a5af45dd
MD5 f079cb65d5932ae6c5c16f959861edbe
BLAKE2b-256 e4d40c8e007357272bf99e5342e325b6acb0cd7c42607fc7c2e798bb46f42596

See more details on using hashes here.

Provenance

The following attestation bundles were made for docmood-0.0.3-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