DocStringExtensions adds abbreviations and templates to Julia's docsystem. An abbreviation such as SIGNATURES or FIELDS is interpolated into a docstring and expands into generated Markdown when the docstring is rendered.
src/interface.jldeclaresAbbreviation, theformatfallback, and theinterpolationextension point.src/abbreviations/holds one file per abbreviation, named after itsconst(typedef.jlforTYPEDEF). Each defines a subtype ofAbbreviation, theconstinstance, and aformat(abbr, buf, doc)method that writes its Markdown tobuf. A typed variant shares its untyped twin's file, andmodule_names.jlandpackage_files.jleach hold two abbreviations that share aformat.src/definitions.jlreads the documented expression: argument defaults, field defaults, and where a struct definition ends.src/methods.jlfinds and groups the methods a docstring documents. It also reads what Julia records about each method, such as its keywords and inferred return type.src/settings.jlreads the environment variables a reader sets to change how docstrings render, such as the return arrow.src/type_text.jlwrites a type as its source writes it, with each<:Tparameter written as its bound or as theconstalias that gives it. Signatures, field lists andTYPEDEFprint types through it.src/printmethod.jlrenders a method signature forSIGNATURES,TYPEDSIGNATURESand the method lists.- A helper with a single caller, including a compat shim for an older Julia, sits in its caller's file.
src/templates.jlimplements@template, which wraps every docstring of a given kind in a module.src/hook.jlreplacesCore.atdocto capture the documented expression forinterpolationand to resolve templates.src/DocStringExtensions.jlincludes the files so that each loads after any type its fields or method signatures name.docs/is the Documenter site.docs/make.jlbuilds it.test/holds the suite.test/AGENTS.mdcovers how it is written.CHANGELOG.mdfollows Keep a Changelog. Record user-facing changes underUnreleased, with issue and PR links written inline.
- CI runs Julia 1.0, the LTS, the latest release, and nightly. Code in
src/andtest/must parse and run on 1.0, so check any syntax or Base function newer than that against the floor. - The package leans on undocumented Base internals (
Base.kwarg_decl, method table fields, binding partitions on 1.12+). TheBase assumptionstestset intest/base_assumptions.jlrecords each one. Add a case there when the code starts relying on another. - A user-facing change updates every page that shows the feature, in the same commit as the code. Check the docstring, the
Examplesmodule indocs/Examples/src/and its page indocs/src/examples/,docs/src/setup.md, andCHANGELOG.md. Searchdocs/for the names the change touches, then build the docs as CI does. The build runs the doctests and fails on a broken@ref. - From Julia 1.6 the package runs interpreted (
@compiler_options compile = mininsrc/DocStringExtensions.jl), and it ships no precompile workload, which would slow every dependent's load. Interpreted code costs nothing to compile, but a closure or generator handed to Base, as inmap,filter,any,sort!withbyor a comprehension, compiles a new specialization of the Base function on the first render. Write those as loops. formatmethods can run in a stale world during macro expansion. Wrap binding lookups such asDocs.resolveandmethodsinBase.invokelatest, as the existingformatmethods do.
julia --project <<'EOF'
using TestEnv; TestEnv.activate()
include("test/runtests.jl")
EOFPkg.test() runs the same suite in a fresh sandbox. Use it as the final check before a commit.
Runic formats src/ and test/. The CI Format job runs the check and fails on any unformatted file.
just fmt # Format in place
just fmt-check # Check without changing files, as CI doesjulia --project=docs docs/instantiate.jl
julia --project=docs docs/make.jldocs/Project.toml takes DocStringExtensions from this checkout and Documenter from docs/deps/Documenter through [sources]. Documenter depends on DocStringExtensions, so docs/instantiate.jl clones the latest Documenter there and widens its compat bound when it leaves out this version.