Guidedog Manual 1.0.0-beta.16
Idioma
En esta página
Guidedog / Documentación 1.0.0-beta.16

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 registry: Option<Registry>

The readers and renderers; None: guidedoc_defaults::registry().

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 config: Config

The checked settings.

pub warnings: Vec<Report>

What loading warned about; every build reports them again.

pub settings: Digest

The digest of conf.toml’s text and the -D overrides: what every output uses.

pub registry: Registry

The readers and renderers.

pub plugins: gd_plugins::Registry

The linked build plugins.

Implementations

impl Project
pub fn watch_skip(&self) -> Vec<PathBuf>

The paths a watch skips: the build folder, whose changes are the build’s own.

Functions

pub fn gd_project::build(project: &Project, kind: BuilderKind, options: &BuildOptions) -> BuildResult

Builds project with the builder kind: reads the documents whose sources changed (all of them with fresh), resolves the project, writes the outputs whose inputs changed (all of them with all), and publishes them whole.

The build applies options.effective_confinement() to its own copy of the configuration and options.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 -W does 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 kind writes 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-nodes and --stack-kib. Documents are read and pages rendered on threads of gd_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-kib asks 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 --untrusted build 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 clean does for Sphinx, and leaves the folder itself; a missing one is nothing to clean. Fails with project.clean-root when the build path is not a folder and host.io when 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, in dir/source, or in the nearest parent folder that has one) or the folders options names.

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 serve watches 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 (see Project::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.