Skip to content

pathsim/docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

316 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PathSim Logo


PathSim Docs - Unified Documentation Site

A unified documentation site for the PathSim ecosystem, featuring API references, interactive examples, and versioned documentation for PathSim, PathSim-Chem, and PathSim-Vehicle. Built with SvelteKit and hosted at docs.pathsim.org.

Tech Stack

Getting Started

npm install
npm run dev

For production:

python scripts/build.py --all  # Extract API docs, notebooks, and build indexes
npm run build
npm run preview

Project Structure

src/
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ api/               # API data system
β”‚   β”‚   β”œβ”€β”€ versions.ts    # Version loading utilities, manifest types
β”‚   β”‚   └── generated/     # TypeScript types (index.ts)
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ api/           # API documentation components
β”‚   β”‚   β”‚   β”œβ”€β”€ ModuleDoc.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ ClassDoc.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ FunctionDoc.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ DocstringRenderer.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ TypeRef.svelte
β”‚   β”‚   β”‚   └── ApiToc.svelte
β”‚   β”‚   β”œβ”€β”€ common/        # Shared UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Icon.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ Tooltip.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ CodeBlock.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ NotebookCell.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ MarkdownRenderer.svelte
β”‚   β”‚   β”‚   └── RstRenderer.svelte
β”‚   β”‚   β”œβ”€β”€ layout/        # Page layout
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.svelte      # Includes version selector
β”‚   β”‚   β”‚   β”œβ”€β”€ MobileDrawer.svelte
β”‚   β”‚   β”‚   └── DocLayout.svelte
β”‚   β”‚   β”œβ”€β”€ notebook/      # Jupyter notebook rendering
β”‚   β”‚   β”‚   β”œβ”€β”€ Notebook.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ CodeCell.svelte
β”‚   β”‚   β”‚   β”œβ”€β”€ MarkdownCell.svelte
β”‚   β”‚   β”‚   └── CellOutput.svelte
β”‚   β”‚   β”œβ”€β”€ examples/      # Examples page components
β”‚   β”‚   β”‚   └── ExamplesToc.svelte
β”‚   β”‚   β”œβ”€β”€ search/        # Search UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ SearchInput.svelte
β”‚   β”‚   β”‚   └── SearchResult.svelte
β”‚   β”‚   └── pages/         # Full page components
β”‚   β”‚       β”œβ”€β”€ PackageOverview.svelte
β”‚   β”‚       └── PackageApi.svelte
β”‚   β”œβ”€β”€ config/            # Centralized configuration
β”‚   β”‚   β”œβ”€β”€ packages.ts    # Package metadata, links, features, installation
β”‚   β”‚   β”œβ”€β”€ pyodide.ts     # Python runtime config
β”‚   β”‚   └── links.ts       # External URLs
β”‚   β”œβ”€β”€ notebook/          # Notebook parsing and loading
β”‚   β”‚   β”œβ”€β”€ types.ts
β”‚   β”‚   β”œβ”€β”€ parser.ts
β”‚   β”‚   └── loader.ts      # Version manifest and notebook loading
β”‚   β”œβ”€β”€ pyodide/           # Python execution (Web Worker)
β”‚   β”‚   β”œβ”€β”€ index.ts       # Main thread bridge
β”‚   β”‚   β”œβ”€β”€ worker.ts      # Web Worker implementation
β”‚   β”‚   └── types.ts       # Message protocol types
β”‚   β”œβ”€β”€ semantic/          # Semantic search (client-side)
β”‚   β”‚   β”œβ”€β”€ model.ts       # Embedding model loader (e5-small-v2)
β”‚   β”‚   β”œβ”€β”€ similarity.ts  # Cosine similarity search
β”‚   β”‚   └── index.ts       # Public API
β”‚   β”œβ”€β”€ stores/            # Svelte stores
β”‚   β”‚   β”œβ”€β”€ apiContext.ts
β”‚   β”‚   β”œβ”€β”€ examplesContext.ts
β”‚   β”‚   β”œβ”€β”€ notebookStore.ts
β”‚   β”‚   β”œβ”€β”€ pyodideStore.ts
β”‚   β”‚   β”œβ”€β”€ versionStore.ts        # Per-package version persistence
β”‚   β”‚   β”œβ”€β”€ packageVersionsStore.ts # Pyodide package versions
β”‚   β”‚   β”œβ”€β”€ searchNavigation.ts
β”‚   β”‚   └── themeStore.ts
β”‚   └── utils/
β”‚       β”œβ”€β”€ search.ts      # Search with dynamic index loading
β”‚       β”œβ”€β”€ crossref.ts    # Cross-reference linking
β”‚       β”œβ”€β”€ codemirror.ts  # Editor setup
β”‚       └── clipboard.ts
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ +page.svelte       # Home (search, package cards)
β”‚   β”œβ”€β”€ +layout.svelte     # Root layout
β”‚   β”œβ”€β”€ pathsim/           # Static package routes (overview only)
β”‚   β”‚   └── +page.svelte
β”‚   β”œβ”€β”€ chem/
β”‚   β”‚   └── +page.svelte
β”‚   β”œβ”€β”€ vehicle/
β”‚   β”‚   └── +page.svelte
β”‚   └── [package]/         # Dynamic versioned routes
β”‚       β”œβ”€β”€ +layout.ts     # Package layout loader
β”‚       β”œβ”€β”€ [version]/
β”‚       β”‚   β”œβ”€β”€ +layout.ts     # Version validation, manifest loading
β”‚       β”‚   β”œβ”€β”€ +layout.svelte # Version context provider
β”‚       β”‚   β”œβ”€β”€ api/
β”‚       β”‚   β”‚   β”œβ”€β”€ +page.ts   # Load versioned API data
β”‚       β”‚   β”‚   └── +page.svelte
β”‚       β”‚   └── examples/
β”‚       β”‚       β”œβ”€β”€ +page.ts   # Load versioned notebook list
β”‚       β”‚       β”œβ”€β”€ +page.svelte
β”‚       β”‚       └── [slug]/
β”‚       β”‚           β”œβ”€β”€ +page.ts   # Load versioned notebook
β”‚       β”‚           └── +page.svelte
└── app.css                # Global design system

scripts/
β”œβ”€β”€ build.py               # Main build script (API, notebooks, indexes)
β”œβ”€β”€ build-indexes.py       # Standalone index generation
β”œβ”€β”€ build-embeddings.py    # Generate semantic search embeddings
β”œβ”€β”€ rebuild-manifests.py   # Rebuild notebook manifests (metadata only)
β”œβ”€β”€ requirements.txt
└── lib/
    β”œβ”€β”€ config.py          # Build configuration (min versions, paths)
    β”œβ”€β”€ api.py             # API extraction using Griffe
    β”œβ”€β”€ notebooks.py       # Notebook processing (incl. thumbnail extraction)
    β”œβ”€β”€ git.py             # Git operations (tags, checkout)
    └── executor.py        # Parallel execution utilities

static/
β”œβ”€β”€ {package}/             # Per-package versioned content
β”‚   β”œβ”€β”€ manifest.json      # Package manifest (versions, latest)
β”‚   └── {tag}/             # Per-version content (e.g., v0.16.4)
β”‚       β”œβ”€β”€ api.json           # API documentation
β”‚       β”œβ”€β”€ manifest.json      # Notebook metadata (incl. thumbnails)
β”‚       β”œβ”€β”€ search-index.json  # Versioned keyword search index
β”‚       β”œβ”€β”€ crossref-index.json # Versioned crossref index
β”‚       β”œβ”€β”€ embeddings-index.json # Versioned semantic search embeddings
β”‚       β”œβ”€β”€ notebooks/         # Jupyter notebook files
β”‚       β”œβ”€β”€ outputs/           # Pre-computed cell outputs
β”‚       └── figures/           # Pre-rendered figures
└── *.png                  # Logo files

Architecture Overview

Data Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Python Packages │────>β”‚ scripts/build.py│────>β”‚ Per-Version     β”‚
β”‚ (pathsim, etc.) β”‚     β”‚ (Griffe)        β”‚     β”‚ Static Files    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                        β”‚
                        For each git tag:               v
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚ static/{package}/{tag}/                 β”‚
                        β”‚   β”œβ”€β”€ api.json                          β”‚
                        β”‚   β”œβ”€β”€ manifest.json (notebooks)         β”‚
                        β”‚   β”œβ”€β”€ search-index.json                 β”‚
                        β”‚   β”œβ”€β”€ crossref-index.json               β”‚
                        β”‚   β”œβ”€β”€ notebooks/                        β”‚
                        β”‚   └── figures/                          β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

URL Scheme

URL Page
/ Home with search and package cards
/pathsim PathSim overview (features, installation)
/pathsim/v0.16.4/api API reference (specific version)
/pathsim/v0.16.4/examples Example notebooks gallery
/pathsim/v0.16.4/examples/harmonic-oscillator Specific notebook
/chem, /vehicle Other packages (same structure)

Key Abstractions

Layer Purpose Key Files
Build Script Extract API, notebooks, indexes scripts/build.py
Keyword Search Per-version search indexes search.ts, search-index.json
Semantic Search Natural language search via embeddings semantic/, embeddings-index.json
Cross-refs Per-version link resolution crossref.ts, TypeRef.svelte
Version Store Persist selected version per package versionStore.ts
Notebook Loader Fetch versioned notebooks loader.ts
Pyodide Worker Execute Python with versioned packages pyodide/worker.ts

Build System

The main build script handles all content generation:

# Build specific package (smart mode - only missing versions)
python scripts/build.py --package pathsim

# Rebuild all versions for all packages
python scripts/build.py --all

# Build indexes only (for existing content)
python scripts/build-indexes.py

What It Does

  1. API Extraction: Uses Griffe to extract from Python source
  2. Notebook Processing: Copies notebooks, extracts metadata
  3. Index Generation: Creates search and crossref indexes per version
  4. Manifest Generation: Creates package manifest with version list

Configuration (scripts/lib/config.py)

MIN_SUPPORTED_VERSIONS = {
    "pathsim": "0.7",
    "pathsim-chem": "0.1",
    "pathsim-vehicle": "0.1"
}

Search System

Search uses per-version indexes loaded dynamically.

Index Structure

Each version has its own search-index.json:

[
  {
    "name": "Integrator",
    "type": "class",
    "moduleName": "pathsim.blocks.integrator",
    "path": "pathsim/v0.16.4/api#Integrator",
    "description": "Integration block for ODE systems"
  }
]

Search Features

  • Multi-term queries: Each term scored independently
  • Scoring hierarchy: Exact match (100) > prefix (50) > contains (30) > description (10)
  • Type boosting: Pages 1.5x, classes 1.2x, examples 1.15x
  • Keyboard shortcut: Ctrl+F focuses search bar

Semantic Search

In addition to keyword search, the documentation supports semantic search powered by Transformers.js running client-side.

How It Works

  1. Build time: build-embeddings.py generates embeddings for all API items and examples using e5-small-v2
  2. Load time: Embeddings index loaded per-version from embeddings-index.json
  3. Query time: User query embedded in browser, cosine similarity finds relevant results

Embedding Index Structure

{
  "items": [
    {
      "name": "Integrator",
      "type": "class",
      "path": "pathsim/v0.16.4/api#Integrator",
      "embedding": [0.012, -0.034, ...]
    }
  ]
}

Features

  • Natural language queries: "How do I integrate a signal?" finds Integrator class
  • Client-side inference: No server required, runs in browser via ONNX Runtime
  • Lazy loading: Model loaded only when semantic search is triggered
  • Combined results: Semantic results merged with keyword search for best coverage

Cross-Reference System

Automatically links class/function names in docstrings to their API documentation.

Supported Patterns

:class:`Integrator`       # RST role syntax
`Integrator`              # Backtick code
'Integrator'              # Single-quoted names

Per-Version Resolution

Cross-references resolve to the current version's API:

Integrator β†’ /pathsim/v0.16.4/api#Integrator

Versioned Documentation

Each package maintains historical API versions with full content.

Package Manifest

Located at static/{package}/manifest.json:

{
  "package": "pathsim",
  "latestTag": "v0.16.4",
  "versions": [
    {
      "tag": "v0.16.4",
      "released": "2025-01-17",
      "hasExamples": true
    },
    {
      "tag": "v0.9.0",
      "released": "2025-09-26",
      "hasExamples": false
    }
  ]
}

Version Selection

  • Sidebar dropdown: Shows all versions with "latest" badge
  • Persistence: Selected version stored in localStorage per package
  • Smart navigation: When switching to a version without examples, redirects to overview

Interactive Notebooks

Jupyter notebooks run in the browser via Pyodide with versioned package support.

Execution

  • Pyodide runs in a Web Worker (non-blocking)
  • Versioned packages: Installs specific version matching the docs (e.g., pathsim==0.16.4)
  • Cell outputs rendered: text, images, HTML, errors
  • Math support via KaTeX

Keyboard Shortcuts

Jupyter-style keyboard shortcuts for code cells:

Shortcut Action
Ctrl+Enter Run cell and advance to next
Ctrl+Shift+Enter Run cell (stay in place)
Escape Unfocus current cell
  • Pressing Ctrl+Enter with no cell focused auto-selects the first code cell
  • Focused cells show a highlight border for visibility
  • Cells scroll into view when focused

Example Thumbnails

Example tiles on the gallery page display thumbnails extracted from notebook figures:

  • Extracted from the first .. image:: (RST) or ![](...) (Markdown) directive
  • Falls back to description text if no figure found
  • Thumbnails stored in version manifest metadata

Version-Aware Execution

When viewing /pathsim/v0.14.0/examples/..., Pyodide installs pathsim==0.14.0 to ensure examples work correctly with that version's API.


Configuration

Package Configuration (src/lib/config/packages.ts)

Central source of truth for all package metadata:

export const packages = {
  pathsim: {
    id: 'pathsim',
    name: 'PathSim',
    description: 'Block-diagram simulation framework',
    logo: 'pathsim_logo.png',
    docs: 'pathsim',
    api: 'pathsim/api',
    examples: 'pathsim/examples',
    pypi: 'https://pypi.org/project/pathsim',
    conda: 'https://anaconda.org/conda-forge/pathsim',
    github: 'https://github.com/pathsim/pathsim',
    features: [...],
    installation: [
      { name: 'pip', command: 'pip install pathsim' },
      { name: 'conda', command: 'conda install -c conda-forge pathsim', minVersion: '0.14.0' }
    ],
    quickstart: { ... }
  }
};

Pyodide Configuration (src/lib/config/pyodide.ts)

export const PYODIDE_VERSION = '0.26.2';
export const PYTHON_PACKAGES = [
  { pip: 'pathsim', required: true, pre: true, import: 'pathsim' },
  { pip: 'matplotlib', required: true, pre: false, import: 'matplotlib' }
];
export const TIMEOUTS = { INIT: 120000, EXECUTION: 60000 };

Scripts

Script Purpose
npm run dev Start development server
npm run build Production build
npm run preview Preview production build
npm run check TypeScript/Svelte type checking
python scripts/build.py Build all content (smart mode)
python scripts/build.py --all Rebuild all versions
python scripts/build-indexes.py Regenerate search/crossref indexes
python scripts/build-embeddings.py Generate semantic search embeddings
python scripts/rebuild-manifests.py Update notebook metadata without re-execution

Design System

Global styles in app.css with CSS custom properties:

Colors

Variable Dark Light
--surface #08080c #f0f0f4
--surface-raised #1c1c26 #ffffff
--text #f0f0f5 #1a1a1f
--accent #0070c0 #0070c0

Typography

  • UI Font: Inter
  • Code Font: JetBrains Mono
  • Sizes: 12px (base), 14px (md), 16px (lg)

Components

  • .panel, .tile, .card - Container styles
  • .elevated - Subtle shadow effect
  • .crossref - Cross-reference link styling

Deployment

GitHub Pages deployment via GitHub Actions.

Workflow

  1. Clone PathSim repositories
  2. Run python scripts/build.py --all (extracts API, notebooks, builds indexes)
  3. Build SvelteKit (npm run build)
  4. Deploy to GitHub Pages

Scheduled Builds

Documentation is automatically rebuilt on a schedule to pick up new package releases:

  • Trigger: GitHub Actions cron schedule (configurable)
  • Smart builds: Only processes new git tags not already in static/
  • Auto-deploy: New versions appear without manual intervention

Environment Variables

  • BASE_PATH: URL base path (e.g., /pathsim-docs)

License

MIT

About

The Repo for the PathSim Docs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •