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.2b0.tar.gz (86.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.2b0-py3-none-any.whl (40.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scribpy-0.0.2b0.tar.gz
  • Upload date:
  • Size: 86.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.2b0.tar.gz
Algorithm Hash digest
SHA256 d90f6060ee81e7879aa227d56d395bb88864b2c1b4fba2b8ce70be1cc75977a2
MD5 604e3a803d6579f7f36d2a9fb623daed
BLAKE2b-256 63712e30fc32dbaa65a61b9efb4f0605d1b8d1b29d2123852e761d91e0eb949a

See more details on using hashes here.

Provenance

The following attestation bundles were made for scribpy-0.0.2b0.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.2b0-py3-none-any.whl.

File metadata

  • Download URL: scribpy-0.0.2b0-py3-none-any.whl
  • Upload date:
  • Size: 40.6 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.2b0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee3bd76db8115da3e62036883caf9cb632ed4e6003822567d9e3a32ed4b3cc89
MD5 a785fe72b955838a11986fb4e51057ff
BLAKE2b-256 1df1983909bc9ecd5f450c15284d19b31d8c2dbfcc0d774bd785dbc08fef583d

See more details on using hashes here.

Provenance

The following attestation bundles were made for scribpy-0.0.2b0-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