Skip to main content

Documentation framework built on Cross-Inertia

Project description

cross-docs

Python backend utilities for Cross-Docs documentation framework.

Installation

uv add cross-docs
# or
pip install cross-docs

Usage

from pathlib import Path
from fastapi import FastAPI, Request
from cross_docs import (
    generate_nav,
    create_docs_handler,
    strip_trailing_slash_middleware,
)
from inertia.fastapi import InertiaDep

app = FastAPI()
app.middleware("http")(strip_trailing_slash_middleware)

CONTENT_DIR = Path("content")
NAV = generate_nav(CONTENT_DIR / "docs")

docs_handler = create_docs_handler(CONTENT_DIR, NAV)

@app.get("/docs")
async def docs_index(request: Request, inertia: InertiaDep):
    return await docs_handler(request, inertia)

@app.get("/docs/{path:path}")
async def docs_page(path: str, request: Request, inertia: InertiaDep):
    return await docs_handler(request, inertia, path=path)

API

Markdown Utilities

  • parse_frontmatter(content: str) - Parse YAML frontmatter
  • load_markdown(content_dir: Path, path: str) - Load and parse markdown
  • load_raw_markdown(content_dir: Path, path: str) - Load raw markdown

Navigation

  • generate_nav(docs_dir, base_path, section_order, index_page) - Generate nav from files

Middleware

  • strip_trailing_slash_middleware - Redirect trailing slashes
  • wants_markdown(request) - Check Accept header for markdown

Routes

  • create_docs_handler(...) - Create a docs route handler

License

MIT

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

cross_docs-0.2.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

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

cross_docs-0.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file cross_docs-0.2.0.tar.gz.

File metadata

  • Download URL: cross_docs-0.2.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cross_docs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0e43ac3fcb75ac7d1613bb45fad2fe30aabac24452b8b26a91f8aa9db02715cb
MD5 058c142e6b895c78198bff94e673c9f0
BLAKE2b-256 1d67730e51a05cf01639d20db1db140350a2680cee041f3299645e63289bd3cd

See more details on using hashes here.

File details

Details for the file cross_docs-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cross_docs-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cross_docs-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc501bc22741f37dfcd082f3923fc04b097a78e0dc5596067f521dce0f1f5501
MD5 8109e2d7edfecf64152db07b255e3300
BLAKE2b-256 bdb10aae228ecfe75ae1478097cf8202c386929f176f9303d3a837e196f72c1e

See more details on using hashes here.

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