from pathlib import Path
assert Path("README.md").exists(), "Expected README.md to exist before this page runs."
assert Path("_extensions").is_dir(), "Expected _extensions directory to exist before this page runs."4 Manual Pages
This section illustrates the smallest useful shape of a Quarto Manual page, and serves as the working template for Quarto Manual authors.
A Page should do three things:
- prove that the page is ready to run;
- perform one or more concrete procedure steps;
- prove that those steps worked.
In Quarto Manuals, we implement these requirements in specific block types, which means:
- exactly one
.manual-prereqblock; - one or more
.manual-procedureblocks; - exactly one
.manual-checkblock.
4.1 1. Prerequisites
Use the prerequisite block to check whether the page is allowed to proceed. This is where page-to-page dependency should be enforced.
Good prerequisite checks look for visible project state:
- does a required file already exist?
- did a previous page create the expected directory?
- does a previously emitted test suite pass?
- is the required tool available?
The easiest way to set up a prerequisite block is to use the tests you defined in the check block from a previous page.
Before running this page, confirm that the project already has a data/ directory and a README.md file.
You can also express prerequisites with shell checks:
#| eval: false
test -f README.md
test -d data
If this page depends on tests from a previous page, run them here:
#| eval: false
pytest tests/test_previous_step.py
4.2 2. Procedure
Procedure blocks contain the work of the page. A page may use one procedure block or several.
Each procedure block should do one clear part of the step.
Create a directory for project configuration files.
from pathlib import Path
Path("config").mkdir(exist_ok=True)Write a small JSON file that later pages can inspect.
from pathlib import Path
import json
config_path = Path("config/manual.json")
config_path.write_text(
json.dumps({"status": "configured"}, indent=2) + "\n",
encoding="utf-8",
)4.3 3. Check
Use the check block to prove that the page succeeded.
Checks should assert the results of the procedure blocks above. If you want the page to emit a reusable test file, you can combine the manual check block with a quarto-emit class.
from pathlib import Path
import json
def test_manual_page_created_config():
config_path = Path("config/manual.json")
assert config_path.exists(), "Expected config/manual.json to exist."
data = json.loads(config_path.read_text(encoding="utf-8"))
assert data["status"] == "configured"This block serves two purposes:
- as a manual check, it shows the reader how to verify the page;
- as an emit block, it can materialize a real test file for later reuse.