When raising a PR, make sure to run pre-commit hooks to ensure that the notebooks are cleaned and the README is updated.
pre-commit run --all-filesSometimes this will fail and update your notebooks or the README file. Generally, you can re-run the
command and it will pass as the pre-commit hooks will fix the issues it finds.
We use pre-commit hooks to maintain code quality and automate documentation updates. Pre-commit runs automatically when you attempt to commit changes, ensuring that all notebooks are clean and documentation is up-to-date.
To install pre-commit:
pip install pre-commit
pre-commit installThis will install pre-commit and set up the git hooks defined in our .pre-commit-config.yaml file.
We use two primary hooks:
-
Notebook Cleaning: This hook removes execution counts and outputs from notebooks to keep diffs clean and focused on content changes rather than execution artifacts.
-
README Generator: This hook automatically updates the README.md file based on the notebook file structure, ensuring that our documentation accurately reflects the current state of available examples.
You can run the hooks manually on all files with:
pre-commit run --all-filesOr on staged files only:
pre-commit runNotebooks in this repository are automatically converted to MDX format and published to the Wherobots documentation site. This happens via a GitHub Actions workflow (.github/workflows/convert-notebooks.yml) that runs when notebooks are modified on the main branch.
- Conversion: The
notebook_to_mdx.pyscript converts.ipynbfiles to.mdxformat, extracting markdown and code cells while generating appropriate frontmatter. - Navigation: The
update_docs_navigation.pyscript updates the docs navigation structure to include the converted notebooks under "Spatial Analytics Tutorials" > "Example Notebooks". - Publishing: A PR is automatically created against the
wherobots/docsrepository with the converted files.
When you add a new notebook to this repository, you must update the navigation mapping so it appears in the correct category in the documentation:
- Edit
.github/workflows/scripts/update_docs_navigation.py - Add your notebook to the
FILENAME_TO_CATEGORYdictionary with the appropriate category - The filename key should be lowercase with hyphens (e.g.,
My_New_Notebook.ipynbbecomes"my-new-notebook")
Example:
FILENAME_TO_CATEGORY = {
# ... existing entries ...
"my-new-notebook": "Analyzing Data", # Add your notebook here
}Available categories:
"Getting Started""Analyzing Data""RasterFlow""Reading and Writing Data""Open Data Connections""Scala"
If you don't add your notebook to the mapping, it will appear under an "Other" category in the documentation.
You can preview how notebooks will look on the docs site locally using the Makefile targets. This requires the wherobots/docs repo cloned alongside this repo (at ../docs by default).
- Python 3.x
- Node.js (for Mintlify CLI via
npx) wherobots/docsrepo cloned at../docs
| Target | Description |
|---|---|
make preview |
Full local preview workflow. Syncs the docs repo to main, converts notebooks to MDX, updates navigation, and starts the Mintlify dev server at http://localhost:3000. |
make preview-branch DOCS_BRANCH=<branch> |
Same as preview but checks out a specific docs repo branch instead of main. Useful when redesigning the tutorials section on a feature branch. |
make convert |
Converts notebooks to MDX files in the docs repo. Cleans previous output first. |
make update-nav |
Updates docs.json navigation to include converted notebooks. |
make sync-docs |
Checks out and pulls the target branch (default: main) in the docs repo. |
make clean |
Removes generated MDX files from the docs repo. |
| Variable | Default | Description |
|---|---|---|
DOCS_DIR |
../docs |
Path to the wherobots/docs repo clone |
DOCS_BRANCH |
main |
Docs repo branch to sync to |
# Standard preview against docs main branch
make preview
# Preview against a feature branch in the docs repo
make preview-branch DOCS_BRANCH=redesign-tutorials
# Just convert notebooks without starting the server
make convert
# Use a different docs repo location
make preview DOCS_DIR=~/projects/docsIf you would like to contribute a notebook and add it to Wherobots Example Notebooks, open a pull request with your contribution and work with the reviewers to get your notebook merged. If merged, it will make it into the next eligible release. Additionally we are happy to work with you to share your work with the broader Apache Sedona and Wherobots user community via our newsletter or other mediums.
If you are a member of the Wherobots org, the following instructions apply.
To release a version of these notebooks, make a tag of the commit to release, naming it based on the release you want to target.
git tag v1.6.0
git push origin v1.6.0
Then, use the Github UI to make a release from the tag.
If a release for notebooks has already been published, remake the tag:
git tag -d v1.6.0
git push --delete origin v1.6.0
git tag v1.6.0
git push origin v1.6.0
then delete the old release in the Github UI after the tag is made. Create the new release in the Github UI, marking the previous tag to compare against.
When writing example notebooks, follow these guidelines.
- Opening image
- If this is a solution notebook, start with a banner that repeats the imagery used for the notebook's thumbnail. It should be about 1200x220 px. (See Generate PMTiles using Wherobots for an example.)
- Otherwise, start with this small logo:

- Headings
- Use
#(H1) once in a notebook, as the title that immediately follows the opening image. - Use
##(H2) for most section headings, and###(H3) if a second level makes sense. - Anything smaller should probably be omitted or simply emphasized with bold text.
- If there's text that comes after the heading, put them in the same cell.
- Use
- Avoid duplicating code in both markdown cells and executable code cells. To keep notebooks succinct, use code blocks in markdown cells only when:
- The code should not be executed (e.g., showing long-running code, alternative approaches, or code to avoid)
- Examples: a Pythonic alternative to SQL, code that demonstrates an anti-pattern, or code with placeholders
- Function or variable names should be enclosed in
code formatting.
- Use
>indents for definitions.
- Focus on the scenario at hand. Use links to docs or other resources for expanded coverage of a topic.
- Focus on education and reader empowerment. Avoid a promotional tone.
- Use few or no emojis.
- Never use emojis instead of markdown-formattted bullets or numbers. Emoji bullets can impede accessibility for people using screen readers.
- Precede code cells with with a markdown cell with a
##H2 or###H3 headline to facilitate rapid scanning.
For example:
ST_Isochrone(geometry, 1, 'car', false)
- Do include a brief description for new topics.
- Don't describe anything covered in the Getting Started notebooks (e.g. getting the
sedonacontext). - Describe the code block before (above) the code block. Use comments to call out specific, interesting parameters or functions.
- Comments should be one short line and support or expand what's in prose, as opposed to repeating it.
- Whenever possible, cells should output something. If the cell isn't designed to output already (e.g. a map), provide context or confirmation of what happened with calls like
show,count, orprintSchema. - Always use
wklsinstead of hard-coding admin boundaries.