1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Building a plan: working out which stages run, and in which order, from what a
//! caller asks for.
//!
//! A plan is the list of stages that satisfies a plan request, in dependency order
//! and grouped in batches; it is a pure value of the registry and the request, with
//! nothing of any document in it ([`Plan`]). One plan therefore serves every
//! document rendered the same way, and [`crate::core::run`] runs it over one
//! document at a time.
//!
//! A caller never lists stages itself. It *demands* capabilities (asks the plan for
//! stages that provide them), usually by choosing a workflow, a named set of demands
//! together with the choices that go with them
//! ([`WorkflowDef`](crate::core::registry::WorkflowDef)). A capability is a
//! registered dotted name for a state of processing that a stage brings about
//! ([`CapabilityDef`](crate::core::registry::CapabilityDef)). This module derives
//! the rest from what the registered stages declare: which stage provides each
//! needed capability, which lowering rule
//! ([`LoweringRule`](crate::core::lowering::LoweringRule)) lowers each element on
//! each backend ([`BackendDef`](crate::core::registry::BackendDef)), and
//! the order of the chosen stages. The guide sections [stages, capabilities, and
//! plans](crate::guide::concepts_overview#stages-capabilities-and-plans) and
//! [how a plan is built](crate::guide::pipeline#how-a-plan-is-built) describe the
//! whole picture.
//!
//! # Getting a plan
//!
//! - [`Plan::for_workflow`] builds the plan of a registered workflow, with
//! [`Overrides`] applied: the usual way.
//! - [`workflow_request`] turns a workflow into a [`PlanRequest`] without building
//! it, for a caller that inspects or adjusts the request first.
//! - [`Plan::build`] builds the plan of any [`PlanRequest`].
//!
//! Each returns a [`PlanError`] when the plan cannot be built. A preference the plan
//! cannot honor does not stop the build: it is kept as a [`PlanWarning`]. So is the
//! output of a selected lowering rule that nothing checks before the program reading
//! the output does
//! ([`LoweringDecl::unchecked_output`](crate::core::lowering::LoweringDecl::unchecked_output)),
//! one warning per backend and feature: the formulas of
//! [`math-passthrough`](crate::math_passthrough) on `html`, `latex-rendered` and
//! `latex-recomposed`, for instance, and those of a feature that registers the
//! same rules under its own names (the `math-techxt` extension's, on the two
//! LaTeX backends). The run reports each warning before its own diagnostics,
//! as `flm.run.ignored-preference`, `flm.run.preferred-rule-set-aside`,
//! `flm.run.preferred-rule-not-candidate` or `flm.run.unchecked-output`. A plan
//! holds nothing of a document, so the warnings do not depend on what the
//! document holds.
//!
//! # Module map
//!
//! - [`request`] — [`PlanRequest`], everything a plan is built from;
//! [`Overrides`], what a caller changes about a workflow's request; [`PlanKey`],
//! the number that identifies a plan.
//! - [`cx`] — [`PlanCx`], what a stage can consult while it states what it needs
//! for one plan.
//! - [`selection`] — how one lowering rule is chosen per element and backend
//! ([`SelectedRules`]) and how one stage is chosen to provide each needed
//! capability ([`Excluded`] records a stage that this choice ruled out).
//! - [`build`] — [`Plan`] and how it is built and checked, with [`StagePlan`],
//! what a plan records about one stage, [`PlanError`] and [`PlanWarning`].
//!
//! [`LoweringSelection`], the lowering rules a request prefers for one backend, is
//! defined in the registry module and re-exported here.
//!
//! # Examples
//!
//! Building the plan of a registered workflow, with nothing changed about it:
//!
//! ```
//! use flm_core::core::plan::{Overrides, Plan};
//! use flm_core::core::registry::{PackageEntry, RegistryBuilder, RegistryInputs};
//! use flm_core::stdlib::{self, StdlibConfig};
//!
//! let mut builder = RegistryBuilder::new();
//! builder.use_package(stdlib::add_features(PackageEntry::new("std"), StdlibConfig::new()));
//! builder.use_package(flm_core::math_passthrough::package());
//! let registry = builder.build(&RegistryInputs::new())?;
//!
//! let plan = Plan::for_workflow(®istry, "text", &Overrides::none())?;
//!
//! // The plan lists the stages that run after the rewrite stages, in the order
//! // the runner runs them.
//! assert!(plan.stage_names().iter().any(|name| name.as_str() == "flm.text.emit"));
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
pub use crateLoweringSelection;
pub use ;
pub use PlanCx;
pub use ;
pub use ;