Contributing#
We welcome contributions to the city2graph project! This document provides guidelines for contributing to the project.
Setting Up Development Environment#
Fork the repository on GitHub.
Clone your fork locally:
git clone https://github.com/<your-name>/city2graph.git cd city2graph git remote add upstream https://github.com/c2g-dev/city2graph.git
Set up the development environment:
uv sync --group dev --extra cpu source .venv/bin/activate # On Windows: .venv\Scripts\activate
Making Changes#
Create a new branch for your changes:
git checkout -b feature/your-feature-name
Make your changes to the codebase.
Run pre-commit checks before committing:
uv run pre-commit run --all-files
Run the tests to ensure your changes don’t break existing functionality:
uv run pytest --cov=city2graph --cov-report=html --cov-report=term
Update or add documentation as needed.
Commit your changes with a descriptive commit message.
Code Style#
We follow strict code quality standards using the following tools:
Ruff: For linting and formatting Python code
mypy: For static type checking
numpydoc: For docstring style validation
Key style guidelines:
Use 4 spaces for indentation.
Maximum line length of 88 characters.
Use docstrings following numpydoc conventions for all public modules, functions, classes, and methods.
Use type hints where appropriate.
Pre-commit hooks will automatically run these checks when you commit changes.
Documentation#
When contributing new features or making significant changes, please update the documentation:
Add docstrings to all public functions, classes, and methods.
Update the relevant documentation files in the
docs/source
directory.If adding a new feature, consider adding an example to
docs/source/examples.rst
.
Pull Requests#
Push your changes to your fork:
git push origin feature/your-feature-name
Open a pull request on GitHub.
Describe your changes in the pull request description.
Reference any related issues that your pull request addresses.
Your pull request will be reviewed, and you may be asked to make changes before it’s merged.
Building Documentation#
To build and preview the documentation locally:
Create and activate a virtual environment with uv:
uv venv docs-env source docs-env/bin/activate # On Windows: docs-env\Scripts\activate
Install documentation dependencies:
uv pip install -e ".[docs]"
Build the documentation:
cd docs make html
Open
docs/build/html/index.html
in your browser to view the documentation.