smalldocs.serve
smalldocs preview: build the site, serve it on localhost, and rebuild and reload the browser on every change.snapshot
snapshot(root: Path, out: Path) -> dict[str, float]Note the modification time of every source file.
| Parameter | Type | Default | Description |
|---|---|---|---|
root |
Path | required | The project folder |
out |
Path | required | The output folder, which is left out |
| returns | dict[str, float] | Each file’s modification time |
class Handler
Serve the output folder, and the build number at /__smalldocs__/version.
Handler.do_GET
Handler.do_GET() -> NoneAnswer the build number, or a file.
Handler.end_headers
Handler.end_headers() -> NoneAsk the browser not to cache, so a reload shows the new build.
Handler.log_message
Handler.log_message(format: str, *args: object) -> NonePrint nothing for each request.
| Parameter | Type | Default | Description |
|---|---|---|---|
format |
str | required | The message, with % fields |
args |
object | required | The values for the fields |
rebuild
rebuild(root: Path) -> Path | NoneBuild the site for preview, printing a failure instead of stopping.
| Parameter | Type | Default | Description |
|---|---|---|---|
root |
Path | required | The project folder |
| returns | Path | None | The output folder, or None when the build failed |
preview
preview(root: Path, host: str = '127.0.0.1', port: int = 4200, open_browser: bool = True) -> intBuild, serve and watch until stopped with Ctrl-C.
| Parameter | Type | Default | Description |
|---|---|---|---|
root |
Path | required | The project folder |
host |
str | '127.0.0.1' |
The address to listen on |
port |
int | 4200 |
The port |
open_browser |
bool | True |
Open the site in a browser |
| returns | int | The exit code |