Skip to content

Latest commit

 

History

History
133 lines (99 loc) · 5.27 KB

submitting.md

File metadata and controls

133 lines (99 loc) · 5.27 KB

GRASS GIS development

GRASS - Geographic Resources Analysis Support System has been under continual development since 1982. The strength and success of GRASS GIS relies on the user community. With this in mind, the philosophy of the GRASS Development Team is to encourage users to develop their own unique tools and applications for GRASS. If you develop tools and techniques that you feel would benefit other GRASS users, please see below how to structure code and documentation for the benefit of all.

Submitting rules

Be sure to check your code against these rules:

Use pre-commit

It is highly recommended to install and use pre-commit before submitting any new or modified code or any other content. The pre-commit Git hooks set checks validity and executes automated formatting for a range of file formats, including C/C++ and Python. Pre-commit installs all necessary tools in a virtual environment upon first use.

If you never used pre-commit before, you must start by installing it on your system. You only do it once:

python -m pip install pre-commit

Pre-commit must then be activated in the code repository. Change the directory to the root folder and use the install command:

cd <grass_source_dir>

# once per repo
pre-commit install

Pre-commit will then be automatically triggered by the git commit command. If it finds any problem it will abort the commit and try to solve it automatically. In that case review the changes and run again git add and git commit.

It is also possible to run pre-commit manually, e.g:

pre-commit run clang-format --all-files
pre-commit run black --all-files

Or to target a specific set of files:

pre-commit run --files raster/r.somemodule/*

The pre-commit hooks set is defined in .pre-commit-config.yaml.

It is possible to temporally disable the pre-commit hooks in the repo, e.g. while working on older branches:

# backporting...
pre-commit uninstall

And to reactivate pre-commit again:

git switch main
pre-commit install

GRASS GIS programming best practice

There are many unwritten rules how GRASS modules should work, what they should do and what they shouldn't do. There is always some reason why some things are considered as "good" or "bad", still they are just noted in some long GRASS developer mailing list conversations. These pages here aim at collecting such ideas which are floating around in the ​GRASS-dev mailing list (and other places) to help new module developers/bugfixers to understand many little tricks how GRASS modules should work.

New list item adding guide

List items should be short and general. Add only things that are relevant to all modules or module groups. There should be reason why such rule/hint exists - add reference to ML archive thread or short description why such rule is important. Look into the documentation above for already existing specific rules. Feel free to add code/pseudocode samples, if they apply.

GRASS best practice list (unsorted)

GRASS GIS Addons

Submitting code to GitHub

See HowToGit

See also