Set up a development environment#
This guide sets up a local environment for working on the Cookieplone codebase and its documentation.
Prerequisites#
Clone the repository#
git clone https://github.com/plone/cookieplone.git
cd cookieplone
Install dependencies#
make install
This command runs uv sync, which creates the virtual environment in .venv with the development dependencies.
In a git clone, it then installs the pre-commit hooks with hatch run pre-commit install.
Run the test suite#
make test
All tests must pass before you submit a pull request. To run one test file or one test, call pytest directly:
uv run pytest tests/utils/test_git.py -v
uv run pytest tests/utils/test_git.py::test_repo_from_path -v
Run the linters#
make lint
This command runs the pre-commit hooks on all files: file checks, ruff, ruff format, codespell, pyroma, and check-python-versions.
make format runs the same hooks, which fix what they can.
Find your way around the code#
Location |
What it does |
|---|---|
|
The |
|
Finds, clones, and checks template repositories: |
|
Reads the user configuration ( |
|
Builds the |
|
|
|
The Jinja2 filters. |
|
The built-in validators. |
|
Helpers for Cookieplone and template hooks, such as |
|
The pytest plugins for testing template repositories. |
|
Default values and the names of environment variables. |
|
The test suite, laid out like the |
Python API reference documents the functions that template hooks use, and How Cookieplone works describes a run from start to finish.
Work on the documentation#
The documentation is a Sphinx site written in MyST Markdown, in docs/src/.
Its pages follow four sections: tutorials/, how-to-guides/, reference/, and concepts/.
Pages include longer samples from docs/_examples/, and the scripts in docs/_checks/ generate those samples to prove they work.
The Documentation workflow (.github/workflows/docs.yml) builds and checks the site on every push.
After a push to main, it publishes the site to https://plone.github.io/cookieplone/.
Add a page#
Create a Markdown file in the section's folder, and start it with the
mystfront matter that the other pages use:description,property=og:description,property=og:title, andkeywords.Add the file name to the
toctreeof the section'sindex.md.Build the site and fix every warning:
make docs-html SPHINXOPTS="-W --keep-going"The site sets
nitpicky = True, so every cross-reference, such as{py:func}, must resolve.Run Vale:
make docs-valeVale uses the Microsoft style and the vocabulary in
docs/styles/config/vocabularies/Plone/accept.txt. Add a correct term that Vale doesn't know to that file.
To preview the site while you edit, run make docs-livehtml, and open http://127.0.0.1:8050.
Check the documentation#
Command |
Checks |
|---|---|
|
The build, with warnings as errors. |
|
Style, grammar, and spelling. |
|
Every external link. |
|
The template reference pages, the example repositories, and the first project tutorial, against real generations. |
|
Cleans the build, then runs Vale, reports broken links, and runs doctest. |
make docs-snippets clones cookieplone-templates at the branch in DOCS_TEMPLATES_REF, next by default.
It needs network access, uv, Node.js, and git.
Update the template reference pages#
Official templates pages are partly generated from cookieplone-templates.
The questions table and the file tree of each page sit between % questions:begin and % questions:end, and between % tree:begin and % tree:end.
After a change in cookieplone-templates, generate every template, and rewrite those blocks:
uv run python docs/_checks/inventory_templates.py
uv run python docs/_checks/template_pages.py --write
The first command writes the inventory to docs/_templates-inventory/, which git ignores.
Update the rest of each page, such as requirements and next steps, by hand.
The tree in Create your first Plone project has its own command, docs/_checks/run_tutorial.sh --write.
Add a changelog entry#
Cookieplone uses towncrier.
Each pull request to main adds a news fragment to news/, and the Changelog check workflow fails without one.
Name the file after the issue number and the type of change, such as news/212.documentation.
The types are breaking, feature, bugfix, internal, documentation, and tests.
Write the entry in the past tense, and end it with your GitHub handle:
Added a troubleshooting entry for offline generation. @jane-doe
To preview the next changelog, run make changelog.
Release#
Maintainers release Cookieplone with make release.
It runs prerelease and release from zest.releaser, builds the package with uv build, publishes it with uv publish, and runs postrelease.
During the release, towncrier writes the news fragments into CHANGES.md.