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 cross_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.10.1.tar.gz (26.5 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.10.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cross_docs-0.10.1.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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.10.1.tar.gz
Algorithm Hash digest
SHA256 5feb61a7c7358bf0fcb43f117d6b7874c3bcad575999bc251cbefe57d5d4f0ff
MD5 98e3c1c5827a73667cb9e8a06d199242
BLAKE2b-256 7ab711ccf9c4a808f3393c4401016dd2ae0bbf71de1c3cb8238d6d81c0edab99

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cross_docs-0.10.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5206131074408dbdcb57c31ceddcec857f09a90f72cc7e654ea4eedb718832ac
MD5 e74453b16991314aaad2c721a18220aa
BLAKE2b-256 5d8a98e1744e32e49bda39061c2348c9f0241e5a3ff20fd16773a180018a49fe

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