sigildocs

(sigil resources)

(sigil resources) - Unified resource resolution for Sigil

Provides access to library, documentation, and asset files with automatic resolution across project builds, bundled archives, and filesystem.

Resolution order:

  1. Project build output (if package.sgl found in cwd or parents)
  2. Bundled archive (if running from a bundled executable)
  3. Executable-relative (assets/ folder next to binary, for 'assets only)
  4. Filesystem (library-paths for 'lib only)

Resource categories determine the base path:

  • 'lib -> project: build/dev/lib/ | bundle: lib/ | system: library-paths
  • 'docs -> project: docs/ | bundle: docs/
  • 'assets -> project: assets/ | bundle: assets/ | exe-relative: assets/

Example:

(import (sigil resources))

;; Read module JSON docs
(read-resource 'lib "sigil/string.json")

;; Read language reference markdown
(read-resource 'docs "reference/language/syntax.md")

;; Read an asset file
(read-resource-bytes 'assets "images/logo.png")

Exports

Clear the resource resolution cache.

Use this if you change directories or modify project structure.

project-rootprocedure

Get the project root directory, or #f if not in a project.

A project is detected by finding package.sgl in the current directory or any parent directory.

in-project?procedure

Check if currently running within a Sigil project.

Get the current resource resolution context.

Returns 'project if resources are being loaded from a project, 'bundle if from a bundled executable, or 'system for filesystem.

Check if a resource exists.

Category is one of: 'lib, 'docs, 'assets Path is relative within that category (e.g., "sigil/string.json")

read-resourceprocedure

Read a resource as a string.

Returns the file contents as a string, or #f if not found. Category is one of: 'lib, 'docs, 'assets

Read a resource as a bytevector.

Returns the file contents as a bytevector, or #f if not found. Useful for binary assets like images.