Skip to main content

Module shape

Module shape 

Source
Expand description

What a project IS — decided once, read by every largo command.

A project is one of four shapes, and the shape follows from two facts: does it have a site (pages/ or static/), and does its entry program Serve?

shapepages/ or static/the entry Serves
ProjectShape::Siteyesno, or no entry
ProjectShape::FullStackyesyes
ProjectShape::Backendnoyes
ProjectShape::Programnono

Serve is an AST fact over the entry’s assembled closure — a Serve in an imported module counts, one named in a string or a comment does not. What each command does with a shape is a table on the shape itself (ProjectShape::serve_plan, ProjectShape::build_plan), so largo serve and largo build cannot disagree about what a project is, and check, test and fmt read their program set from the same Project.

A site needs no entry program: a ## Page mounts itself. Largo.toml names an entry only when the project has one — an entry the manifest DECLARES must exist, while the conventional default (src/main.lg) may be absent from a site.

Project::shape is the STRICT decision (a parse failure is an error); Project::shape_or_best_effort is the same decision made from what can still be read when the entry does not parse — the file layout and a lexical Serve scan — for largo serve --watch, which must bind a port and show the located error rather than refuse to start over an author’s typo.

Structs§

Project
A project on disk: its manifest, its entry program if it has one, and its directories.

Enums§

BuildPlan
What a plain largo build produces.
ProjectShape
What a project is. Decided by Project::shape; every command reads it rather than re-deriving a piece of it.
ServePlan
What largo serve stands up.