gd_project¶
The Guidedog project builder: a handful of verbs over a loaded project.
use gd_project::{BuildOptions, BuilderKind, LoadOptions};
let project = gd_project::load("docs".as_ref(), &LoadOptions::default())?;
let result = gd_project::build(&project, BuilderKind::Html, &BuildOptions::default());
for report in &result.reports { /* gd_report::Report */ }
if let Some(problem) = &result.problem { eprintln!("{problem}"); }
gd_project::clean(&project)?;
A build discovers the documents (and the generated API pages), loads the translations, reads what changed since the last build (gd-read), resolves the project (gd-resolve), writes the output with the builder (gd-site, gd-book or gd-intl) into a gd-outputs generation, and publishes it whole.
Re-exports
- pub use gd_env::BuildOptions
- pub use gd_env::BuildResult
- pub use gd_env::BuildStage
- pub use gd_env::BuilderKind
- pub use gd_env::Confinement
- pub use gd_env::ContentRule
- pub use gd_env::ContentRules
- pub use gd_env::Jobs
- pub use gd_env::PluginAccess
- pub use gd_env::ReadScope
Structs
- pub struct gd_project::LoadOptions¶
-
Where a project is and what it is built with. Fill it with struct-update syntax:
LoadOptions { plugins: linked, ..Default::default() }.Fields
- pub config: gd_conf::LoadOptions¶
-
The command line’s say:
-c,-C,-D, the sphinx-build form’s folders.
- pub plugins: gd_plugins::Registry¶
-
The build plugins linked into this program, looked up before the machine registry (
plugins = [...]in conf.toml selects them).
- pub struct gd_project::Project¶
-
A loaded documentation project. Builds borrow it and never change it (each works on its own copy of the configuration), so one project may be built any number of times.
Fields
- pub settings: Digest¶
-
The digest of conf.toml’s text and the
-Doverrides: what every output uses.
- pub plugins: gd_plugins::Registry¶
-
The linked build plugins.
Implementations
Functions
- pub fn gd_project::build(project: &Project, kind: BuilderKind, options: &BuildOptions) -> BuildResult¶
-
Builds
projectwith the builderkind: reads the documents whose sources changed (all of them withfresh), resolves the project, writes the outputs whose inputs changed (all of them withall), and publishes them whole.The build applies
options.effective_confinement()to its own copy of the configuration andoptions.content_rules(&project.config)to every document. The project is never changed: a confined build confines only itself and any number of builds may follow. It never fails outright: the result carries the problem that stopped it (exit != 0), every report, and the counters. Only a build that did all its work, and that-Wdoes not fail, publishes; any other leaves the previous output, manifest and environment as they were.
- pub fn gd_project::writes_dependencies(kind: BuilderKind) -> bool¶
-
Tells whether
kindwrites a dependency manifest: every builder whose output a person reads.
- pub fn gd_project::build_limits(options: &BuildOptions) -> Result<Limits, Problem>¶
-
The limits every session of a build reads and renders with: the engine’s defaults with
--max-depth,--max-nodesand--stack-kib. Documents are read and pages rendered on threads ofgd_host::WORKER_STACK_BYTES(the command line runs its own work on one too), so the stack budget may be at most what such a thread holds.Fails with
build.stack(exit 2) when--stack-kibasks for more; a caller may call it before building to refuse the options early.
- pub fn gd_project::content_policy(rules: ContentRules) -> Policy¶
-
The policy of a build with the content
rules(gd_env::BuildOptions::content_rules): raw content and unsafe URLs allowed or omitted as they say (an unstated rule allows), untranslatable math allowed, and a document with an unknown directive or role reported and still built.
- pub fn gd_project::trusted_policy() -> Policy¶
-
The policy of a build of the user’s own project: raw HTML and Typst, any URL and untranslatable math are used as Sphinx uses them, and, as in Sphinx, a document with an unknown directive or role is reported and still built.
- pub fn gd_project::untrusted_policy() -> Policy¶
-
The policy of an
--untrustedbuild of a project from elsewhere: raw content and unsafe URLs (javascript:and the like) are left out with a warning. What such a build reads is its confinement (gd_env::Confinement::STRICT), not its policy.
- pub fn gd_project::clean(project: &Project) -> Result<(), Problem>¶
-
Removes everything in the project’s build folder, as
make cleandoes for Sphinx, and leaves the folder itself; a missing one is nothing to clean. Fails withproject.clean-rootwhen the build path is not a folder andhost.iowhen an entry cannot be removed.
- pub fn gd_project::load(dir: &Path, options: &LoadOptions) -> Result<Project, Problem>¶
-
Loads the project found from
dir(conf.toml there, indir/source, or in the nearest parent folder that has one) or the foldersoptionsnames.Fails with
core.registry.invalid(exit 2) when the engine registry has an adapter without an ID or version, or one ID twice, and with gd-conf’s problems (config.invalid,project.missing, …) when the configuration cannot be read. Whether the registry has the readers the documents need is known when a build finds them (build.reader).
- pub fn gd_project::watch_roots(config: &Config) -> Vec<PathBuf>¶
-
The paths
guidedog servewatches for changes: the source folder, the Odin package folders and Rust crates the API pages are made from, and the static, extra, template, include, autodoc and locale folders outside the source folder (those inside it are watched with it). The build folder is never one of them; skip it while watching (seeProject::watch_skip).
Constants
- pub const gd_project::DEPENDENCIES_FILE: &str = "gd-dependencies.json"¶
-
The manifest’s file name in the output folder.
- pub const gd_project::DEPENDENCIES_SCHEMA: u32 = 1¶
-
The version of the manifest’s form; it changes when a field changes meaning.
- pub const gd_project::RECORDS_LOCK: &str = "build.lock"¶
-
The lock file’s name in the records folder.