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

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.5.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.5-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docmood-0.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 239aab9c7a8d689d801479b04cbda3a5ddc1e64388322855d575afafd20130c1
MD5 4759a0ce0ad390afb338c8f9e395ab7c
BLAKE2b-256 4ad5ef35342e1f636eb8f856d7bc08b0a0a9b8fb70793dbbf024131d2a3c948a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: docmood-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 15.9 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8751ae380fd285ff0047593fbd257b9ea825154bf6a52061a8fa8c44d430fc1e
MD5 3c1554bc053c619cb0399529b867a781
BLAKE2b-256 c84be213335ad4c07d1da362d7641fed674d1673d60029bc97732f0d1738925d

See more details on using hashes here.

Provenance

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