Skip to content

Commit

Permalink
Add example documentation of docstring formats (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsJPWerner committed Feb 15, 2022
1 parent e946679 commit 0191e18
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ Visual Studio Code extension to quickly generate docstrings for python functions

## Docstring Formats

To turn of type generation in docstrings use the `-notypes` template of the desired format. The docBlockr format is a typed version of PEP0257.

- Google (default)
- docBlockr
- Numpy
- Sphinx
- one-line-sphinx
- PEP0257
To turn off type generation in docstrings use the `-notypes` template of the desired format. The docBlockr format is a typed version of PEP0257.

- [google](docs/google.md)
- [sphinx](docs/sphinx.md)
- [numpy](docs/numpy.md)
- [docBlockr](docs/docblockr.md)
- [one-line-sphinx](docs/one-line-sphinx.md)
- [pep257](docs/pep257.md)

## Usage

Expand Down
27 changes: 27 additions & 0 deletions docs/docblockr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# docBlockr Docstring Format

```python
def abc(a: int, c = [1,2]):
"""_summary_
Arguments:
a {int} -- _description_
Keyword Arguments:
c {list} -- _description_ (default: {[1,2]})
Raises:
AssertionError: _description_
Returns:
_type_ -- _description_
"""
if a > 10:
raise AssertionError("a is more than 10")

return c
if a > 10:
raise AssertionError("a is more than 10")

return c
```
21 changes: 21 additions & 0 deletions docs/google.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Google Docstring Format

```python
def abc(a: int, c = [1,2]):
"""_summary_
Args:
a (int): _description_
c (list, optional): _description_. Defaults to [1,2].
Raises:
AssertionError: _description_
Returns:
_type_: _description_
"""
if a > 10:
raise AssertionError("a is more than 10")

return c
```
28 changes: 28 additions & 0 deletions docs/numpy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Numpy Docstring Format

```python
def abc(a: int, c = [1,2]):
"""_summary_
Parameters
----------
a : int
_description_
c : list, optional
_description_, by default [1,2]
Returns
-------
_type_
_description_
Raises
------
AssertionError
_description_
"""
if a > 10:
raise AssertionError("a is more than 10")

return c
```
16 changes: 16 additions & 0 deletions docs/one-line-sphinx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One Line Sphinx Docstring Format

```python
def abc(a: int, c = [1,2]):
"""_summary_
:param int a: _description_
:param list c: _description_, defaults to [1,2]
:raises AssertionError: _description_
:return _type_: _description_
"""
if a > 10:
raise AssertionError("a is more than 10")

return c
```
23 changes: 23 additions & 0 deletions docs/pep257.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Pep257 Docstring Format

```python
def abc(a: int, c = [1,2]):
"""_summary_
Arguments:
a -- _description_
Keyword Arguments:
c -- _description_ (default: {[1,2]})
Raises:
AssertionError: _description_
Returns:
_description_
"""
if a > 10:
raise AssertionError("a is more than 10")

return c
```
19 changes: 19 additions & 0 deletions docs/sphinx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Sphinx Docstring Format

```python
def abc(a: int, c = [1,2]):
"""_summary_
:param a: _description_
:type a: int
:param c: _description_, defaults to [1,2]
:type c: list, optional
:raises AssertionError: _description_
:return: _description_
:rtype: _type_
"""
if a > 10:
raise AssertionError("a is more than 10")

return c
```

0 comments on commit 0191e18

Please sign in to comment.