Summary
Add a developer-facing guide for the new optional-features support in
cement.ext.ext_generate (landed in PR #768, target release 3.0.16) to
the GitBook developer docs at https://docs.builtoncement.com. Sphinx is
API-reference only — narrative usage docs live in GitBook.
Defer until after 3.0.16 cut
Holding this until the 3.0.16 release is cut so the docs land against
released behavior. Avoids documenting an interface that could still
shift between now and the release tag.
Where the feature lives
- Implementation:
cement/ext/ext_generate.py — _process_features()
on GenerateTemplateAbstractBase
- Demo:
demo/generate-features/ (working webapp template + README)
- Tests:
tests/ext/test_ext_generate.py (test6–test15 fixtures cover
enabled/disabled, transitive requires, out-of-order requires,
unknown/missing config, null blocks)
- Changelog: `3.0.15 - DEVELOPMENT` → Bugs + Features
What the doc should cover
- Mental model — features as Y/N toggles with
enabled /
disabled side-effect blocks plus optional requires.
- `.generate.yml` schema reference — one table for the
feature-root keys (`name`, `default`, `requires`, `enabled`,
`disabled`) and one for the block keys (`variables`, `exclude`,
`ignore`).
- CLI invocation — `--defaults` vs interactive vs `--clone`,
plus `--force`. Note that interactive prompts are now lazy:
prerequisites resolved before dependents are prompted; declining a
prerequisite skips the dependent prompt entirely.
- Reading feature state in templates — `features.` is
exposed in the Jinja2 context; gate content with
`{% if features.docker %} ... {% endif %}`. Variables injected by
an enabled block are top-level template vars.
- Worked example — point at `demo/generate-features/`; show the
three expected output trees from its README.
- Authoring checklist — base variables → optional-feature
bucketing → `disabled.ignore` for files to skip → `enabled.variables`
for extra prompts → `requires` for dependencies → `{% if %}` for
gated rendered content → test both `--defaults` and an interactive
decline.
- Pitfalls — `exclude` vs `ignore` semantics, regex anchoring
(`'.Dockerfile.'` not `'Dockerfile'`), explicit YAML `null`
coalesces to `[]` (no crash), cyclic `requires` will
`RecursionError`, `requires` only references other feature
names (not arbitrary variables).
- Validation behavior — missing `name` and unknown `requires`
raise `ValueError` (so the validation survives `python -O`).
Suggested GitBook location
Under the existing `generate` extension page on docs.builtoncement.com,
likely as a new subsection ("Optional Features") after the existing
variable-prompt content.
Acceptance
Related
Summary
Add a developer-facing guide for the new optional-features support in
cement.ext.ext_generate(landed in PR #768, target release 3.0.16) tothe GitBook developer docs at https://docs.builtoncement.com. Sphinx is
API-reference only — narrative usage docs live in GitBook.
Defer until after 3.0.16 cut
Holding this until the 3.0.16 release is cut so the docs land against
released behavior. Avoids documenting an interface that could still
shift between now and the release tag.
Where the feature lives
cement/ext/ext_generate.py—_process_features()on
GenerateTemplateAbstractBasedemo/generate-features/(working webapp template + README)tests/ext/test_ext_generate.py(test6–test15 fixtures coverenabled/disabled, transitive
requires, out-of-orderrequires,unknown/missing config, null blocks)
What the doc should cover
enabled/disabledside-effect blocks plus optionalrequires.feature-root keys (`name`, `default`, `requires`, `enabled`,
`disabled`) and one for the block keys (`variables`, `exclude`,
`ignore`).
plus `--force`. Note that interactive prompts are now lazy:
prerequisites resolved before dependents are prompted; declining a
prerequisite skips the dependent prompt entirely.
exposed in the Jinja2 context; gate content with
`{% if features.docker %} ... {% endif %}`. Variables injected by
an enabled block are top-level template vars.
three expected output trees from its README.
bucketing → `disabled.ignore` for files to skip → `enabled.variables`
for extra prompts → `requires` for dependencies → `{% if %}` for
gated rendered content → test both `--defaults` and an interactive
decline.
(`'.Dockerfile.'` not `'Dockerfile'`), explicit YAML `null`
coalesces to `[]` (no crash), cyclic `requires` will
`RecursionError`, `requires` only references other feature
names (not arbitrary variables).
raise `ValueError` (so the validation survives `python -O`).
Suggested GitBook location
Under the existing `generate` extension page on docs.builtoncement.com,
likely as a new subsection ("Optional Features") after the existing
variable-prompt content.
Acceptance
parent page
artifact (run `pip install cement==3.0.16 && pdm run python
myapp.py generate webapp /tmp/out --defaults` and confirm output
matches docs)
GitBook page once published
pointer
Related