Griffe CLI

2.0.2 · active · verified Thu Apr 09

griffecli provides the command-line interface for Griffe, a powerful library designed to extract structural information and API signatures from Python projects. It's used to generate API documentation and detect breaking changes. The current version is 2.0.2, and it follows the release cadence of its core library, Griffe, which is actively maintained.

Warnings

Install

Imports

Quickstart

The primary way to use `griffecli` is via the command line. This example demonstrates how to programmatically invoke the `griffe dump` command, which extracts module information, and outputs it in JSON format. It's equivalent to running `griffe dump my_module.py --output-format json` in your shell.

import os
from pathlib import Path
from griffe.cli import main

# Create a dummy module for demonstration
Path('my_module.py').write_text(
    """"""A simple module.

def hello():
    """Say hello."""
    return 'Hello, Griffe!'
"""
)

# Programmatically run the 'griffe dump' command
# Equivalent to: griffe dump my_module.py --output-format json
# We pass arguments as if they were from the command line
try:
    main(['dump', 'my_module.py', '--output-format', 'json'])
except SystemExit as e:
    if e.code != 0:
        print(f"Error running Griffe: {e}")

# Clean up
Path('my_module.py').unlink(missing_ok=True)
Path('my_module.json').unlink(missing_ok=True)

view raw JSON →