Skip to content
Open
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2aee14d
Update pull request template
Dec 4, 2021
2ace7e9
Start on the instructions for adding new module
Dec 4, 2021
031460a
Merge branch 'main' into wrap-module-instructions
Dec 27, 2021
293035a
Expand guide for wrapping modules
Dec 27, 2021
ae143d0
Add section for adding aliases
Dec 27, 2021
a05a8a7
Consolidate list
Dec 27, 2021
49538ef
Fix grammar
Dec 27, 2021
aea5d95
Merge branch 'main' into wrap-module-instructions
Dec 27, 2021
62b8cae
Apply suggestions from code review
Dec 29, 2021
0c170b3
Update doc/contributing.md
Dec 31, 2021
7d26742
Apply suggestions from code review
seisman Sep 19, 2022
2edf308
Merge branch 'main' into wrap-module-instructions
seisman Nov 28, 2024
6dd7d9e
Merge branch 'main' into wrap-module-instructions
seisman Oct 10, 2025
5f3fd30
Updating
seisman Oct 10, 2025
de77f0c
Merge branch 'main' into wrap-module-instructions
seisman Oct 15, 2025
70fa80c
Update contributing guides
seisman Oct 15, 2025
6063abe
Update contributing guides
seisman Oct 15, 2025
f36dabe
Update contributing guides
seisman Oct 17, 2025
617ec8d
Merge branch 'main' into wrap-module-instructions
yvonnefroehlich Oct 17, 2025
0c32bd2
Merge branch 'main' into wrap-module-instructions
seisman Oct 18, 2025
9fd0cd8
Apply suggestions from code review
seisman Oct 19, 2025
9f38d88
Fix a typo [skip ci]
seisman Oct 19, 2025
a4f508a
Fix typos
seisman Oct 20, 2025
97d6026
Reformat some sentences
seisman Oct 20, 2025
ad04b8a
Fix styling
seisman Oct 20, 2025
f2a86b8
Remove two unnecessary subsections
seisman Oct 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 92 additions & 2 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ To increase the chances of getting your pull request accepted quickly, try to:
- Include an example of new features in the gallery or tutorials.
Please refer to [Gallery plots](contributing.md#contributing-gallery-plots)
or [Tutorials](contributing.md#contributing-tutorials).
If adding a new method/function/class, the gallery example or tutorial should
be submitted in a separate pull request.
* Have a good coding style
- Use readable code, as it is better than clever code (even with comments).
- Follow the [PEP8](https://pep8.org) style guide for code and the
Expand Down Expand Up @@ -467,8 +469,9 @@ function/class/module/method.
### PyGMT Code Overview

The source code for PyGMT is located in the `pygmt/` directory. When contributing
code, be sure to follow the general guidelines in the
[pull request workflow](contributing.md#pull-request-workflow) section.
code, please open an issue first to discuss the feature and its implementation
and be sure to follow the general guidelines in the
[pull request workflow](#pull-request-workflow) section.

### Code Style

Expand Down Expand Up @@ -511,6 +514,93 @@ contains rules for running the linter checks:
make check # Runs ruff in check mode
```

### Wrapping a GMT module

Wrapping a GMT module in PyGMT is usually a big task, but it can progress more smoothly
and efficiently when divided into **small, manageable chunks**. This section gives an
overview of the main tasks involved.

1. Create a feature request ("wrapper request issue") for wrapping a GMT module and
discuss what users would like to see in the new feature. [optional, usually done by
users].
2. Create a tracking issue ("wrapper tracking issue"), using the "Wrapper for a GMT
module" issue template, to track the progress of wrapping the module. Link it to the
Project board, and close the "wrapper request issue" with a comment such as
> Thank you for opening the feature request. The progress of wrapping the module will
> be tracked in issue #XXX and
> the [Project board](https://github.com/orgs/GenericMappingTools/projects/3)".
[usually done by maintainers].
3. Open one PR for the initial implementation, focusing on required and essential
parameters.
4. Close the "wrapper tracking issue" once the initial implementation is merged. Leave a
comment such as:
> The initial implementation of wrapping the XXX module was completed in PR #XXX.
> Not all functionalities are implemented yet. Further progress will be tracked in
> the Project board.
This is necessary to avoid having hundreds of long-term open issues.
5. Open one or more PRs to implement the remaining features and missing aliases.
6. Open one PR to add a gallery example or a tutorial.

These pull requests can be split among multiple contributors. There is no obligation for
a single contributor to complete all steps. Please comment on the "wrapper tracking
issue" if you would like to open a pull request for any of these tasks to avoid
redundant efforts.

#### Feature Request Issue for Wrapping a GMT module

* Find the [*Issues*](https://github.com/GenericMappingTools/pygmt/issues) tab at the
top of the GitHub repository and click *New Issue*.
* Choose the *Feature request* issue template.
* Follow the prompts for filling out the issue template.

#### Central Issue for tracking the progress

*This step is usually done by maintainers.*

* Find the [*Issues*](https://github.com/GenericMappingTools/pygmt/issues) tab on the
top of the GitHub repository and click *New Issue*.
* Choose the "Wrapper for a module" issue template.
* Fill out the issue template.

#### Initial feature implementation

First, comment on the "Wrapper tracking issue" that you will be working on the initial
implementation. This first pull request should be as minimal as possible - only adding
the required functionality (i.e., wrapping the required GMT parameters and supporting
the primary input/output types).

The following steps are common to all initial implementation pull requests that wrap a
GMT module:

* Create a new module `<module-name>.py` in `pygmt/src`. The module docstring should
include the module name and a short description of the functionality (e.g.,
`grdfill - Fill blank areas from a grid.`).
* Add a function `<module-name>` to the module. When writing the new function, it is
generally easiest to reference the source code for other functions that input/output
similar object types.
* Write a detailed docstring following the [numpy style guide](https://numpydoc.readthedocs.io/en/latest/format.html).
* Add the function to the import statements in `pygmt/src/__init__.py`.
* Add the function to the import statements in `pygmt/__init__.py`.
* Add the function to appropriate section of the API documentation in `doc/api/index.rst`.
* Add a testing module `test_<module-name>.py` in `pygmt/tests`, following
the guidelines in the [testing your code](#testing-your-code) section.

#### Add missing aliases

After the initial implementation, missing aliases can be added in separate PRs:

* Select a suitable alias for each GMT option, following the guidelines in the
[code style](#code-style) section. Before creating a new alias, check:

- whether the parameter is listed in the `COMMON_DOCSTRINGS` dictionary in
`pygmt/helpers/decorators.py`
- whether other wrapped GMT modules have a similar parameter
- whether [GMT.jl](https://www.generic-mapping-tools.org/GMT.jl/dev/) has defined an alias
* Add the alias to the `AliasSystem` class and the function signature.
* Add the alias and description to the parameters section of the docstring, using the
`fmt_docstring` decorator to add descriptions for parameters included in the
`COMMON_DOCSTRINGS` dictionary.

### Testing your Code

Automated testing helps ensure that our code is as free of bugs as it can be.
Expand Down