Skip to content

Commit 56b28d6

Browse files
einarferuvanos
andauthored
Minimal for docstrings (#2281)
* Minimal for docstrings --------- Co-authored-by: Maic Siemering <[email protected]>
1 parent e05e10e commit 56b28d6

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

CONTRIBUTING.md

+33-4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ The following command will run black for you if you do not want to configure you
9191
a good idea to run this command when you are finished working anyways, as our CI will use this to check that
9292
the formatting is correct.
9393

94-
Docstring should be formatted using [Google Style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
95-
9694
```bash
9795
python make.py format
9896
```
@@ -101,6 +99,37 @@ In addition to Black, this will sort the imports using [Ruff](https://docs.astra
10199
your editor to run this, please see [this link](https://docs.astral.sh/ruff/integrations/) for more information on
102100
Ruff integration for your specific editor.
103101

102+
Docstring should be formatted using [Google Style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
103+
104+
The minium for docstrings is covering all parameters in an `Args:` block.
105+
106+
```python
107+
Args:
108+
width (int): The width of something
109+
height (int): The height of something
110+
title (str, optional): The title of something
111+
```
112+
113+
* `Args:` should be used for all parameters
114+
* `Returns:` can be used if the return value needs additional explanation outside of
115+
the current docstring. If the return type is already clear from type annotation it
116+
can be omitted.
117+
* `Raises:` can be used if the function raises exceptions that need to be documented
118+
* `Yields:` can be used if the function is a generator and yields values
119+
* `Attributes:` we should try to avoid and instead document the attributes in the code
120+
* Types are visible in the api docs. It's not mandatory to include complex types in the
121+
docstring, however, simpler typing is easy enough to include.
122+
* Using `optional` is a good way to indicate that a parameter is optional.
123+
* Properties and attribute docs don't need a return type when the return type
124+
is already clear from type annotation.
125+
126+
Attribute docstring in module or class:
127+
128+
```py
129+
my_attribute_in_class_or_module: type = value
130+
"""This is a docstring for the attribute."""
131+
```
132+
104133
### Typing
105134

106135
Arcade is using type hints to help with code readability and maintainability.
@@ -190,7 +219,7 @@ Run the doc build to build the web page files, and host a webserver to preview:
190219
python make.py serve
191220
```
192221

193-
You can now open http://localhost:8000 in your browser to preview the docs.
222+
You can now open <http://localhost:8000> in your browser to preview the docs.
194223

195224
The `doc/build/html` directory will contain the generated website files. When you change source files,
196225
it will automatically regenerate, and browser tabs will automatically refresh to show your updates.
@@ -214,7 +243,7 @@ Start a local web server to preview the doc:
214243
python -m http.server -d doc/build/html
215244
```
216245

217-
You can now open http://localhost:8000 in your browser to preview the doc.
246+
You can now open <http://localhost:8000> in your browser to preview the doc.
218247

219248
Be sure to re-run build & refresh to update after making changes!
220249

0 commit comments

Comments
 (0)