(sigil publish docs)
(sigil publish docs) - Documentation Site Publishing
Pipeline stages, theme, and CSS for generating API documentation sites using sigil-publish. Bridges sigil-docs extraction with the sigil-publish functional pipeline.
Example:
(import (sigil publish)
(sigil publish docs))
(define docs-site
(site
title: "My Docs"
content: "docs/**/*.md"
theme: docs-theme))
(run-publish docs-site)Exports
docs-themeprocedureDocumentation site theme matching the Sigil docs design.
Uses external CSS at /css/style.css with dark theme and sidebar navigation. This theme is designed for the Sigil documentation site and matches the existing site styling.
scan-api-docsprocedureCreate a pipeline stage that scans API documentation.
Scans compiled .sgb files from a lib directory and extracts documentation via runtime introspection. Procedure docstrings are available at runtime; module-level descriptions require compiler support (see %set-module-docstring!).
Options: output-prefix: - URL prefix for generated pages (default: "/lib/") filter: - Predicate (path-string) -> bool to filter modules Path is relative to lib-dir without .sgb extension (e.g., "sigil/core", "scheme/base") packages-dir: - Directory containing package sources (e.g., "packages") If provided, modules are grouped by package on the index
(scan-api-docs "build/lib"
output-prefix: "/lib/"
packages-dir: "packages"
filter: (lambda (path)
(or (string-starts-with? path "sigil/")
(string-starts-with? path "scheme/"))))scan-library-docsprocedureScan library documentation organized by package.
Creates a "Libraries" nav group with one entry per package. Each package page includes:
- Quick Reference section linking to .md docs from _pkg/
- Modules section listing API documentation
Example:
(scan-library-docs "build/dev/lib"
output-prefix: "/docs/lib/"
filter: (lambda (path)
(or (string-starts-with? path "sigil/")
(string-starts-with? path "scheme/"))))module-details->output-pathprocedureConvert module-details to output path. Uses pretty URLs: /api/sigil-core/index.html
format-library-nameprocedureFormat library name as (lib name).
lib-index-templateprocedureTemplate for library index page body.
Returns SXML for the body content (without html/head wrapper). The pipeline's theme will wrap this in a full page. Groups modules by inferred package name.
module-details-templateprocedureTemplate for module documentation page body.
Returns SXML for the body content.
export-details->sxmlprocedureConvert export-details to SXML (export card structure). Uses the same card-based layout as the original site.
syntax-details->sxmlprocedureConvert syntax-details to SXML (export card structure).
generate-docs-cssprocedurePipeline stage that generates the docs CSS file.
Adds a synthetic asset with a producer that writes /css/style.css during graph execution. This ensures CSS generation logging appears with other asset outputs.
docs-siteprocedureCreate a documentation site configuration.
Returns a dict with:
- config: Configuration dict for the pipeline
- pipeline: List of pipeline stages
- watch-patterns: List of glob patterns to watch for changes
Smart defaults:
- Content: docs/**/*.md
- Assets: docs/static/**/*
- Theme: Built-in docs theme
- Output: out/
Options:
- title: Site title
- base-url: Base URL for the site
- content: Glob pattern for content files
- assets: Glob pattern for asset files
- theme: Theme function
- transforms: List of transform functions
- output-dir: Output directory
- draft-mode: Include draft content
- lib-dir: Directory containing compiled .sgb modules for library docs
- lib-filter: Predicate to filter which modules to include in library docs Takes a relative module path (e.g., "sigil/core")
- lib-url-path: URL path for generated library pages (default: "/lib/")
- extra-stages: Additional pipeline stages to run after scanning (e.g., sxml-page generators)
(define my-docs (docs-site title: "My Project"))
;; With API documentation
(define my-docs
(docs-site title: "My Project"
lib-dir: "build/lib"
lib-filter: (lambda (path)
(string-starts-with? path "myproject/"))))
;; With custom SXML pages
(define my-docs
(docs-site title: "My Project"
extra-stages: (list
(sxml-page path: "/about"
title: "About"
content: `(div (p "About this site."))))))with-api-docsprocedureAdd API documentation to a site.
Creates a "Libraries" nav group with per-package pages including Quick Reference sections and module listings.
Modifies the site spec to include:
- scan-library-docs stage in the pipeline (before filter-drafts)
- generate-docs-css stage (at the end)
- Watch patterns for .sgb, .json, and _pkg/*.md files
Use with the threading macro:
(-> (site title: "My Project"
content: "docs/**/*.md")
(with-api-docs "build/dev/lib"
output-prefix: "/api/"
filter: (lambda (path)
(string-starts-with? path "myproject/"))))with-docs-themeprocedureApply the docs theme to a site.
Sets the theme to docs-theme and adds CSS generation if not present.
(-> (site title: "My Docs"
content: "docs/**/*.md")
(with-docs-theme))load-docs-configprocedureLoad docs configuration from docs.sgl or use defaults.
If docs.sgl exists, loads and evaluates it. Otherwise, creates a default configuration using project metadata.
output-dir-override: If #f, uses config file's output-dir. If set, overrides it.
get-project-titleprocedureGet project title from package.sgl or directory name.
sxml-pagevariableRe-exported from (sigil publish generate)
rewrite-linksprocedureTransform that rewrites .md links to their output paths.
Use with config transforms: to automatically fix internal links. Resolves relative links against the current item's source path and looks up the target's output path in the path index.
Transform signature: (config state item node) -> node
Re-exported from (sigil publish stages)
syntax-highlightprocedureHighlight Scheme/Sigil code blocks.
Handles two formats:
- (pre (@ (lang "scheme")) ...) from markdown
- (pre (code (@ (class "language-scheme")) ...)) standard HTML
Tokenizes the code and wraps tokens in spans with CSS classes like tok-comment, tok-string, tok-keyword, etc.
Transform signature: (config state item node) -> node
Re-exported from (sigil publish transform)