sigildocs

(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-themeprocedure

Documentation 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-docsprocedure

Create 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 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/"))))

Convert module-details to output path. Uses pretty URLs: /api/sigil-core/index.html

Format library name as (lib name).

Template 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.

Template for module documentation page body.

Returns SXML for the body content.

Convert export-details to SXML (export card structure). Uses the same card-based layout as the original site.

Convert syntax-details to SXML (export card structure).

Pipeline 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-siteprocedure

Create 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-docsprocedure

Add 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/"))))

Apply 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 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 title from package.sgl or directory name.

sxml-pagevariable

Re-exported from (sigil publish generate)

Highlight 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)