Skip to main content

Manipulate, edit, and generate documents from Markdown files.

Project description

Scribpy

A Python toolkit and document compiler for engineering-grade Docs-as-Code workflows.


Overview

Scribpy is a Python package (≥ 3.12) designed to be the foundation of a Docs-as-Code approach for Markdown-based documentation.

It provides a structured framework to:

  • write documentation as version-controlled Markdown files;
  • lint and validate Markdown and documentation structure;
  • manipulate Markdown programmatically;
  • assemble multiple files into complete documents;
  • generate tables of contents and section numbering;
  • export documentation to Markdown, HTML, and PDF;
  • apply CSS styling to HTML and PDF outputs;
  • support reproducible documentation builds in local or CI/CD environments.

Docs-as-Code

Scribpy follows the Docs-as-Code principles:

  • documentation is stored as plain text and versioned in Git;
  • documentation quality is checked automatically before generation;
  • builds are reproducible from sources and configuration;
  • generated outputs are artifacts, not manually edited deliverables.
Markdown Sources
    ↓
Configuration (scribpy.toml)
    ↓
Linting & Validation
    ↓
Transformation (TOC, includes, numbering, links)
    ↓
Assembly
    ↓
Build Artifacts
    ├── Markdown
    ├── HTML
    └── PDF

Installation

pip install scribpy

Requires Python ≥ 3.12.


Quick Start

from scribpy.core import load_markdown, get_headings, build_project

doc = load_markdown("docs/architecture.md")

for heading in get_headings(doc):
    print(heading.level, heading.title)

result = build_project(".")

CLI

scribpy init                    # Initialize a project
scribpy lint                    # Validate documentation quality
scribpy build                   # Build all enabled outputs
scribpy build markdown          # Build assembled Markdown
scribpy build html              # Build HTML
scribpy build pdf               # Build PDF
scribpy format docs/            # Format Markdown files
scribpy rewrite-links docs/     # Rewrite internal links
scribpy toc                     # Generate table of contents
scribpy index show              # Display document index
scribpy index check             # Validate document index
scribpy clean                   # Remove build artifacts

Configuration

Scribpy uses a scribpy.toml configuration file:

[project]
name = "System Engineering Handbook"
version = "1.0.0"
authors = ["Engineering Team"]
language = "en"

[paths]
source = "docs"
assets = "assets"
styles = "styles"
output = "build"

[document]
entrypoint = "index.md"
title = "System Engineering Handbook"
number_sections = true
include_toc = true

[lint]
enabled = true
fail_on_warning = false

[builders.html]
enabled = true
css = ["styles/html.css"]

[builders.pdf]
enabled = true
engine = "weasyprint"
css = ["styles/pdf.css"]

Package Architecture

src/scribpy/
├── cli/          — Command-line interface
├── core/         — Public Python API facade
├── config/       — scribpy.toml loading and validation
├── project/      — Project scanning and document index
├── model/        — Core data types (frozen dataclasses)
├── parser/       — Markdown parsing layer
├── lint/         — Documentation quality engine
├── transforms/   — Transformation pipeline (TOC, includes, numbering)
├── builders/     — Output generation (Markdown, HTML, PDF)
├── themes/       — Templates and CSS themes
├── assets/       — Images, diagrams, static files
├── extensions/   — Plugin registry
└── utils/        — Low-level path, string, I/O helpers

Project Layout

A typical Scribpy documentation project:

my-documentation/
├── scribpy.toml
├── docs/
│   ├── index.md
│   ├── introduction.md
│   └── architecture.md
├── assets/
│   └── images/
├── styles/
│   ├── html.css
│   └── pdf.css
└── build/
    ├── markdown/
    ├── html/
    └── pdf/

Development

uv sync --dev       # install package + dev dependencies
make check          # format · lint · typecheck · test

Individual commands:

Command Description
make format Auto-format with ruff
make lint Lint with ruff
make typecheck Type-check with mypy (strict mode)
make test Run tests with coverage report

Release to PyPI

Releases are tag-driven. The package version is derived from the Git tag by hatch-vcs, so do not edit the version manually in pyproject.toml.

Run the local checks first:

make check
make check-dist

make check-dist builds both distribution artifacts into dist/ and validates their metadata with Twine. Local builds made away from an exact release tag will have a development version; the published version is produced by the GitHub tag.

Create and push a version tag from main:

git switch main
git pull --ff-only
git tag v0.0.1b1
git push origin v0.0.1b1

Tags pushed from commits that are not on origin/main are rejected by the publish workflow.

The GitHub Actions Publish workflow then:

  1. runs the checks;
  2. builds the source distribution and wheel;
  3. publishes to PyPI after the pypi environment approval, if configured.

Before the first release, configure Trusted Publishing on PyPI:

Repository owner Repository name Workflow filename Environment
antoinebarre scribpy publish.yml pypi

Install a beta build from PyPI:

python -m pip install --pre scribpy

PyPI package files are immutable: if a version has already been uploaded, bump the tag before publishing again, for example v0.0.1b2.


Design

Scribpy favors a functional programming style:

  • pure functions over mutable objects;
  • frozen dataclasses for data containers;
  • dependency injection over inheritance;
  • protocols for injectable services;
  • explicit pipeline stages with typed inputs and outputs.

See doc/SDD.md for the full Software Design Document.


Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feat/my-feature
  3. Commit following Conventional Commits
  4. Open a pull request

Code must comply with SOLID principles, Google Python Style Guide, full type hints, and cyclomatic complexity < 5 per function.


License

MIT © Antoine

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

scribpy-0.0.4b0.tar.gz (132.1 kB view details)

Uploaded Source

Built Distribution

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

scribpy-0.0.4b0-py3-none-any.whl (64.7 kB view details)

Uploaded Python 3

File details

Details for the file scribpy-0.0.4b0.tar.gz.

File metadata

  • Download URL: scribpy-0.0.4b0.tar.gz
  • Upload date:
  • Size: 132.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scribpy-0.0.4b0.tar.gz
Algorithm Hash digest
SHA256 3acd6ccfcf314a8e0125de55d5580ade854957125eb4bb8d5b57ed3ffbed6373
MD5 ec621a3900263020a4b4d84a5ec89e4d
BLAKE2b-256 001f3a9afe6410dcf6a37108546041d00882b17e6172922897684a2b3513ac82

See more details on using hashes here.

Provenance

The following attestation bundles were made for scribpy-0.0.4b0.tar.gz:

Publisher: publish.yml on antoinebarre/scribpy

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

File details

Details for the file scribpy-0.0.4b0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for scribpy-0.0.4b0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8246b6edad5527ab14e884f9301fcc6472a62b1a3991732e44b45836ec7ee26
MD5 f7e1b10af8a01c6f5a41dc66ee175c24
BLAKE2b-256 aeece420114fed00a46fbf327715ed670f7ab214376d8763e7222b09adb9d631

See more details on using hashes here.

Provenance

The following attestation bundles were made for scribpy-0.0.4b0-py3-none-any.whl:

Publisher: publish.yml on antoinebarre/scribpy

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