This is a Cookiecutter template for creating new Synapse modules.
What you get:
- a Synapse module package
- a
READMEwith basic instructions on installation, development and releasing setup.cfgmetadata (the declarative equivalent ofsetup.py)- CI configurations for
- GitHub Actions
- GitLab
- code checking tools (invokable with
tox, checked in CI)- code formatting using
blackandisort - code style checking using
flake8 - type checking using
mypy(with checking against Synapse supported in Synapse 1.46 and later)- strict by default (configurable in
mypy.ini)
- strict by default (configurable in
- code formatting using
- unit testing using
trial(invokable withtox, checked in CI) - Specific to the 'Synapse Team' variant:
CODEOWNERSfor automatic review requests for thesynapse-coreteam on GitHub when a pull request is opened- The Apache 2.0 licence with copyright notices
Please refer to the Synapse 'Writing a module' documentation for descriptions and examples (at the bottom of most pages) of using the Synapse module API, including registering callbacks.
To use this template, you will first need to install Cookiecutter.
Full instructions to do so can be found in the Cookiecutter documentation,
but in summary, pip install --user cookiecutter or sudo apt install cookiecutter
will do if you use pip or apt.
cd to a directory where you would like to create a new project as a subdirectory, then run
cookiecutter https://github.com/matrix-org/synapse-module-cookiecutter-template.gitYou will then be asked a series of questions to populate your project:
directory_name: Specify the name of a project directory. This directory will be created.module_human_name: Specify a human-readable module name here. This is used in theREADMEfile and the changelog.package_description: Specify a human-readable module description. This is used in theREADMEfile andsetup.cfgfile.package_name: Specify a snake_case Python package name here. This will be used as the package name for your module.module_class_name: Specify a PascalCase Python class name here. This will be used as the class name for your module class.main_git_branch: Specify the name of your main Git branch here. Although this template does not initialise a Git repository automatically, the CI configuration and suggested release instructions mention it. This is commonlymain,master,trunk,defaultordevelop.variant: Choose whether or not to include the 'Synapse Team'-specific customisations; picksynapse_teamif the module will be maintained by the Synapse Team. Otherwise, pickstandard.use_scm_version: Choose whether to use SCM info to set the version of the module. This will usesetuptools_scmfor that, so check its manual for more info.
If all goes well, you should now have a project starter!
What you do from here on is up to you!
However, it's probably worth initialising a Git repository and making the first commit be exactly what is produced by this template. (Doing this may make it easier to upgrade an existing project to a later version of the template in the future: you could branch off from the initial commit, re-run the template generator, commit, and then merge that branch into your main branch.)
If you use GitHub or GitLab, you should use its web interface to enable the included CI configuration.
During development, you can clone this repository and call
cookiecutter path/to/synapse-module-cookiecutter-templatewhen needed, to test your changes.