Skip to main content

A Pre-commit hook for 'one sentence per line' documentation practices.

Project description

onesentence

PyPI - Version Build Status Ruff uv Software DOI badge

A Pre-commit hook for checking 'one sentence per line' documentation practices.

One sentence per line is a practice where developers use only one line per sentence. This can make it easier to review or provide comments on in version control systems like git. That said, it can sometimes be difficult to remember or "debug" this style preference. We provide this linting tool to assist with finding and fixing areas of content where the style preference is one sentence per line.

Installation

Install onesentence from PyPI or from source. Also reference the pre-commit hook instructions for use through pre-commit.

# install from pypi
pip install onesentence

# install directly from source
pip install git+https://github.com/CU-DBMI/onesentence.git

Usage

The onesentence tool provides a command-line interface for checking and fixing files to ensure they follow the "one sentence per line" rule.

Commands

  onesentence check <file_path> [<file_path> ...]

This command checks whether each given file adheres to the "one sentence per line" rule. One or more files may be passed (for example, the filenames pre-commit hands to a hook). It returns a non-zero exit code if any file has a violation.

  onesentence fix <file_path> [<file_path> ...] [--output <path>]

This command corrects each given file by splitting lines with multiple sentences onto separate lines. By default every file is corrected in place, so processing many files never lets one file overwrite another. Pass --output <path> to write a single corrected file to a separate destination; this is only valid with exactly one input file. It returns a non-zero exit code if any file required changes.

Pre-commit hook

Install this pre-commit hook into your project with a block like the following:

repos:
  - repo: https://github.com/CU-DBMI/onesentence
    rev: v0.1.1
    hooks:
        # run checks
        - id: check
        # run checks and fixes where possible
        - id: fix

Using onesentence with a Markdown formatter

If you also run a Markdown formatter such as mdformat, configure it to preserve existing line breaks so it does not undo the one-sentence-per-line splitting. For mdformat this means using --wrap=keep (the default), and notably not --wrap=no or a fixed wrap width, either of which would rejoin sentences onto a single line.

  - repo: https://github.com/executablebooks/mdformat
    rev: 0.7.22
    hooks:
        - id: mdformat
          args: ["--wrap=keep"]

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

onesentence-0.1.4.tar.gz (54.8 kB view details)

Uploaded Source

Built Distribution

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

onesentence-0.1.4-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file onesentence-0.1.4.tar.gz.

File metadata

  • Download URL: onesentence-0.1.4.tar.gz
  • Upload date:
  • Size: 54.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for onesentence-0.1.4.tar.gz
Algorithm Hash digest
SHA256 256495117087099679e1d8917582e790579f8a3a7639377e6e82c94b84b278a5
MD5 61df666efc7b0fd18fff1c124219cefd
BLAKE2b-256 4e2db4bdd27075993e2f53beedc70424869843c34c1efda5e78a5573c1ca20d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for onesentence-0.1.4.tar.gz:

Publisher: publish-pypi.yml on CU-DBMI/onesentence

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

File details

Details for the file onesentence-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: onesentence-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for onesentence-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d7b29c464c93376db1a8076d9843204a8843a4fef7fc76585f9d0f8b101bd89a
MD5 155eae5a91eac490848b639ea6029dbc
BLAKE2b-256 ea70f8e8ddf35726d8728a82ff9fb5410d78fb98a2d23f875f2048d4a0cd091d

See more details on using hashes here.

Provenance

The following attestation bundles were made for onesentence-0.1.4-py3-none-any.whl:

Publisher: publish-pypi.yml on CU-DBMI/onesentence

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