Skip to content

Commit

Permalink
md linting
Browse files Browse the repository at this point in the history
  • Loading branch information
juleshaas committed Apr 24, 2024
1 parent 10c87d9 commit db4e8c6
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions How-to-create-a-GRASS-GIS-addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ A GRASS python module consists of
### Structure (here `r.blend` as example)

1. shebang (first line)
2. header (author, purpose, license)
3. `# % ` comments are important (ignored by python but important for parser)

1. header (author, purpose, license)

1. `# % ` comments are important (ignored by python but important for parser)

- See https://grass.osgeo.org/grass-devel/manuals/g.parser.html

Expand All @@ -77,18 +79,21 @@ A GRASS python module consists of
- key is key in command line (e.g. 'first')
- answer is default values
- access them in main function like `options['first']`
- there are also [standard options]("https://grass.osgeo.org/grass84/manuals/parser_standard_options.html) which can be extended
- there are also [standard options](%22https://grass.osgeo.org/grass84/manuals/parser_standard_options.html) which can be extended

###### `# % flag`

###### `# % rules`

- define dependencies between options, required options and more. See official [docs](https://grass.osgeo.org/grass84/manuals/g.parser.html#conditional-parameters)

4. `def main():` reads in all variables (`options['first']`)
1. `def main():` reads in all variables (`options['first']`)

- a main function is required
5. indefinite additional functions are possible
6. include parser at the end before calling main function:

1. indefinite additional functions are possible

1. include parser at the end before calling main function:

```python
if __name__ == "__main__":
Expand All @@ -108,13 +113,19 @@ A GRASS python module consists of
## Best practises

- python style guide
- [PEP 8 – Style Guide for Python Code](https://peps.python.org/pep-0008/])

- [PEP 8 – Style Guide for Python Code](https://peps.python.org/pep-0008/%5D)
- https://trac.osgeo.org/grass/wiki/Submitting
- https://trac.osgeo.org/grass/wiki/Submitting/Python

- html documentation (no full html please, parts are auto-generated at compile time)

- https://trac.osgeo.org/grass/wiki/Submitting/Docs

- to support i18n, import following module and use macro '\_' before strings. The text after will be replaced with existing lookup tables for other languages

- use existing functions: esp. from PyGRASS

- API description: https://grass.osgeo.org/grass-devel/manuals/libpython/pygrass_index.html
- PyGRASS paper: An Object Oriented Python Application Programming Interface (API) for GRASS: https://www.mdpi.com/2220-9964/2/1/201/htm

Expand Down Expand Up @@ -204,7 +215,9 @@ Choose a name depending on the "family":
```

- Fix lint errors which black couldn't fix or add exception to `.flake8` file

- Black does not fix GRASS GIS parameter `#%`. This can be batch changed with `sed -i 's|^#%|# %|g' foo.py`

- There may not be any linting issues left as the pipeline would fail

#### General steps Part 2
Expand Down Expand Up @@ -242,4 +255,4 @@ For more information on standardized messages see [here](https://trac.osgeo.org/
- Delete "old" code from internal repository
- Add hint to internal repository README that the addon was moved and where to find it
- Adjust README.md in actinia-assets/grass-gis-addons
- Adjust deployments which use the addon, if applicable
- Adjust deployments which use the addon, if applicable

0 comments on commit db4e8c6

Please sign in to comment.