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

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

Failed docstrings:
  src/example.py:42 (detected: imperative, expected: third person)
  src/foo_bar.py:98 (detected: imperative, expected: 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.4.tar.gz (12.1 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.4-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docmood-0.0.4.tar.gz
  • Upload date:
  • Size: 12.1 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.4.tar.gz
Algorithm Hash digest
SHA256 27a9a6fa6f7943042ed51c431e419b4982e16c89f013d8007315a85cba3200ca
MD5 8b90be4f07dd4462418138b38c307975
BLAKE2b-256 b8df4db2bcfe698fe55f46fafc45d30e9c6838cd64cfb057965f4668b166259d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: docmood-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.1 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e57d6c38a95dae3c33e5c2ef21a25e31d61aadce73a69dd630a39061b5bb7b10
MD5 99e8b8f1acfee2aa8e5a70ba6cf98183
BLAKE2b-256 6540e3d75b10f4ca75f24ca7acbd875f81a8884e982a3258ee446cb5cb736657

See more details on using hashes here.

Provenance

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