Hi! Thanks for considering contributing to ckanext-iiif. 🦕
We welcome suggestions, bug reports, and code or documentation changes. This document will give you a quick overview of how to make one of these contributions.
If you're completely new to Git, GitHub, or contributing to open source, you might find it helpful to read some other material first, like W3's Git Tutorial, GitHub Quickstart, or How to Contribute to Open Source. This document does assume some familiarity with these concepts for brevity, but we're happy to help anyone who's new or needs further clarification.
We have a Code of Conduct, which all contributors and community participants are expected to adhere to.
This repository contains the code for an extension/plugin for a larger system called CKAN; it is not a standalone project.
This extension and several others are maintained by the Data Portal team at the Natural History Museum, London. This is a very small team, so contributions are very welcome!
The current core team consists of:
- Josh (@jrdh) - Technical Lead
- Ginger (@alycejenni) - Senior Software Engineer
Before asking your question, have you checked:
If none of those answer your question, try contacting us before raising it as an issue on GitHub. You can find places to contact us in SUPPORT.md.
Suggestions, feature requests, and bug reports are all submitted as GitHub issues.
See GitHub's documentation for the basics on how to create an issue. Before you create an issue, please check the existing issues to see if it's already been raised.
We've provided a template for bug reports. It's not 100% necessary to follow this template exactly, but it does demonstrate the kind of information that will be useful to anyone trying to fix the problem. The most key information is anything that will allow someone to try and recreate your issue on their own system.
We've also provided a template for feature suggestions. This is fairly sparse, and again isn't completely necessary to follow exactly. Please just try to provide as much information about your idea as possible.
If you want to contribute a change to any of the files in the repository, whether it's code, documentation, or repository meta files like .gitignore
, you'll need to make commits and pull requests.
The process is generally as follows:
- Fork the repository.
- Create a new branch to work on by branching off
dev
. We name ours in the formatuser/feature-name
, e.g.ginger/deprecate-ckanpackager
. Try to only work on one topic (e.g. implementing one feature, or fixing a couple of related bugs) per branch. - Make your changes, and commit often; each commit should only contain one change. See below for specifics on how to word your commits.
- Push your changes back to your fork.
- Open a pull request in this repository, with the base branch set to dev and the compare branch set to your new branch. Provide a summary of your changes in the description.
- There are several automated checks that will run when you open the pull request. Try to make all of them pass. If you do not at least attempt to make them pass, we will not merge your pull request.
- Tests. Update them so that they pass, if necessary. New tests are always welcome in any pull request, but if you have added a new feature that has decreased the coverage, new tests are required.
- Commit format validation. If you have not followed the conventional commits format for one or more of your commits, this will fail.
- Code format validation. If you have not formatted your code correctly (using Ruff, docformatter, and/or Prettier), this will fail.
- Wait for feedback from one of the core maintainers. If it's been a week or so and we haven't responded, we may not have seen it. You can find other places to contact us in SUPPORT.md.
Our commits follow the Conventional Commits style for consistency and to make it easy to generate changelogs. Please follow this style when you make your commits. We have our own slightly tweaked version of the default style called cz-nhm
. It's very similar with just a few additions.
Commits are formatted as follows - not every line is required:
<type>(<scope>): <subject>
<BLANK LINE>
BREAKING CHANGE: <subject>
<BLANK LINE>
<body>
<BLANK LINE>
Closes: <issues>
e.g.
fix(actions): write a short lowercase description of what you did
Give a bit more context or detail about the changes.
Closes: #1, #3
Or, a very basic but still completely valid commit:
feat: add an exciting new feature
The tools described below are very useful for generating these messages and sticking to the structure, so we highly recommend using them.
We use a few tools to help us with code standardisation and keeping to the conventional commits style. When making a commit, the two key tools to know about are:
Both tools are Python-based and can be installed with pip
. You'll probably want to use something like pipx or venv instead of installing them globally, but for simplicity, the instructions below are just for pip.
commitizen is a CLI tool for creating commits in the conventional commits style.
To install with pip
:
# NB: cz-nhm must be installed in the same environment as commitizen
pip install commitizen cz-nhm
Then to make a commit:
cz c
# and follow the prompts
pre-commit is a tool that runs a variety of checks and modifications before a commit is made. You can check the .pre-commit-config.yaml file to see exactly what it's currently configured to do for this repository, but of particular note:
- reformats Python code with Ruff
- reformats JavaScript and stylesheets with Prettier
- reformats docstrings with docformatter
- checks your commit message is correcly formatted
To install with pip
:
pip install pre-commit
When installed, the checks will be run on all staged files when you try to make a commit. If any of them fail or make any modifications, the commit will be abandoned and you will have to write the message again. Because of this, it's probably best to run the checks on the staged files manually before you even attempt a commit:
pre-commit run
Don't forget to stage any modifications that it makes! Once it runs without failing, then you can make your commit.
Something to remember is that empty docstrings will cause conflicts between Ruff and docformatter and the checks will fail repeatedly - so don't leave your docstrings empty!
We generally use external style guides and tools to help us maintain standardised code. Ruff and Prettier will be run with pre-commit.
We use Ruff to format our code, using defaults for everything except quote style (we use single quotes).
We also mostly use CKAN's style, with the following exceptions:
- prefer
f''
strings over.format()
- don't use
u''
strings - use double quotes for docstrings, not single quotes
We use Prettier to format these files. As with Ruff, we use defaults for everything except quote style (we use single quotes).
Particularly if you're making frontend changes such as modifying HTML, please make sure your changes meet level AA of the Web Content Accessibility Guidelines (WCAG).
Our documentation is generated using MkDocs, then hosted on Read the Docs. You can view the current documentation for this repository at ckanext-iiif.readthedocs.io.
Most of the documentation for this repository is generated automatically by pulling docstrings from the Python code. This documentation is placed in the "API" subfolder in the rendered output.
There are also a few pages written as standalone .md
files, e.g. configuration.md, or as a subfolder, e.g. usage. You can also edit these or create new pages. In most of our extensions these are still very sparse or automatically generated from content in the README, but the extension ckanext-versioned-datastore
has a good example of more complex documentation.
Once you've made your changes, follow the commit and pull request guidelines as you would for a code change. You will almost certainly be using the docs:
commit prefix.