Skip to content

Trim verbose docstring in commands/__init__.py#398

Merged
tschm merged 2 commits intomainfrom
copilot/refactor-docstring-in-init-py
Mar 8, 2026
Merged

Trim verbose docstring in commands/__init__.py#398
tschm merged 2 commits intomainfrom
copilot/refactor-docstring-in-init-py

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 8, 2026

The src/rhiza/commands/__init__.py docstring was 57 lines of usage prose (bash examples, per-command descriptions) that belongs in README.md/USAGE.md, not a package __init__ whose actual code is 5 lines.

Changes

  • src/rhiza/commands/__init__.py: Replace the 57-line docstring with a concise 3-liner; imports and __all__ untouched.
# Before: 57-line docstring with full usage guide, bash examples, per-command descriptions
# After:
"""Command implementations for the Rhiza CLI.

Implementation functions that back the Typer commands in `rhiza.cli`.
Run ``rhiza <command> --help`` for usage details.
"""
Original prompt

Goal

The src/rhiza/commands/__init__.py docstring is 57 lines long — longer than most of the command implementations it describes. It contains a full usage guide with bash examples, per-command descriptions, and prose that belongs in README.md or USAGE.md, not a package __init__.

The actual code in that file is just 5 lines (two imports, a re-export __all__, and two blank lines).

Current file

# src/rhiza/commands/__init__.py  (current — 67 lines total)
"""Command implementations for the Rhiza CLI.

This package contains the core implementation functions that back the Typer
commands exposed by `rhiza.cli`. These commands help you manage reusable
configuration templates for Python projects.

## Available Commands

### init

Initialize or validate `.rhiza/template.yml` in a target directory.

Creates a default configuration file if it doesn't exist, or validates
an existing one. The default configuration includes common Python project
files like `.github`, `.editorconfig`, `.gitignore`,
`.pre-commit-config.yaml`, `Makefile`, and `pytest.ini`.

### materialize (deprecated)

This command is deprecated. Use ``rhiza sync`` instead.

Retained as a backward-compatibility shim; it delegates to :func:`sync`
with the ``"merge"`` strategy.

### sync

Sync templates using diff/merge instead of overwriting.

Uses cruft's diff utilities (``git diff --no-index``) and 3-way patch
application (``git apply -3``) so that local customisations are preserved
while upstream changes are applied safely.  Tracks the last-synced
template commit in ``.rhiza/template.lock``.

### validate

Validate Rhiza template configuration.

Validates the `.rhiza/template.yml` file to ensure it is syntactically
correct and semantically valid. Performs comprehensive validation including
YAML syntax checking, required field verification, field type validation,
and repository format verification.

## Usage Example

These functions are typically invoked through the CLI:

    ```bash
    $ rhiza init                    # Initialize configuration

    $ rhiza sync                    # Sync templates (primary command)

    $ rhiza validate                # Validate template configuration

    $ rhiza materialize             # Deprecated — use rhiza sync
    ```

For more detailed usage examples and workflows, see the USAGE.md guide
or try rhiza <command> --help
"""

from .init import init
from .materialize import materialize
from .sync import sync
from .tree import tree
from .validate import validate

__all__ = ["init", "materialize", "sync", "tree", "validate"]

Required change

Replace the entire 57-line docstring with a concise 3-line docstring:

"""Command implementations for the Rhiza CLI.

Implementation functions that back the Typer commands in `rhiza.cli`.
Run ``rhiza <command> --help`` for usage details.
"""

The rest of the file (imports and __all__) must remain unchanged.

Constraints

  • Touch only the docstring — do not change the imports or __all__.
  • No test changes are needed; there are no tests that assert on this docstring text.
  • Keep the file's trailing newline intact.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: tschm <2046079+tschm@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor long docstring in src/rhiza/commands/__init__.py Trim verbose docstring in commands/__init__.py Mar 8, 2026
Copilot finished work on behalf of tschm March 8, 2026 08:51
@tschm tschm marked this pull request as ready for review March 8, 2026 08:51
@tschm tschm merged commit 2e41c2f into main Mar 8, 2026
14 checks passed
@tschm tschm deleted the copilot/refactor-docstring-in-init-py branch March 8, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants