module

CRDoc::Stdlib

The standard library docs published at https://crystal-lang.org/api/<version>/.

Constants

CACHE_FILE = "index.v3.json"

Cache file name. Bump it when Model drops fields, so old caches refetch.

CONNECT_TIMEOUT = 10.seconds

Timeouts for docs requests.

EXPIRING_VERSIONS = ["master", "latest"] of ::String

Versions that move over time, so their cache expires.

MASTER_TTL = 1.day

How long a cached master (nightly) index stays fresh.

MAX_REDIRECTS = 5
READ_TIMEOUT = 30.seconds
SUGGESTION_COUNT = 8

Number of versions listed in a "not found" message.

Class methods

base_url

Root of the published API docs.

Source
base_url=(base_url : String)

Root of the published API docs.

Source
cache_path(version : String) : Path

Location of the slim index for version in the cache.

Source
cached_versions

Versions present in the cache, newest first.

Source
docs_version(version : String) : String

Maps a compiler version to the docs version that exists for it.

Source
expired?(version : String, fetched_at : Time, now : Time = Time.utc) : Bool

True when a copy of version fetched at fetched_at has expired. Only the moving targets (master, latest) expire.

Source
installed_version

Docs version matching the crystal compiler on the PATH, such as 1.21.1. A -dev build maps to master.

Asking the compiler costs over 100 ms, so the answer is cached and keyed on the resolved executable's path and mtime.

Source
load(version : String, refresh : Bool = false) : Source

Loads the stdlib source for version, fetching and caching it when absent or when refresh is set. master means nightly and expires after a day.

Source
parse_version(output : String) : String | Nil

Extracts the version from crystal --version output, such as Crystal 1.21.1 [73ea5c2b1] (2026-09-26).

Source
stale?(path : Path, version : String, now : Time = Time.utc) : Bool

True when the cached file at path is missing or too old to use.

Source