Sophon Style Python Docstrings
This is a module named example.py
, which represents
how to write the docstrings of module
, function
, class
and method
.
# -*- coding: utf-8 -*-
"""Short description of module.
Long description of module.
Can be multiline.
"""
def example_create(name, age=0, sex='male', **kwargs):
"""Short description of function.
Long description of function.
Can be multiline too.
# Arguments
name: `any`. Description of name.
age: `int`. Description of age. Defaults to zero.
If it is multiline then must indent the following lines.
sex: `str`. Description of sex. Defaults to 'male'.
**kwargs: `dict`.
# Return
`Person`: an instance object of `Person` class with given information.
# Note
Here is note.
# Examples
Here is examples.
```
jzm = example_create('jzm')
batman = example_create('Bruce Wayne', 28, 'male')
```
"""
pass
Class Person(object):
"""Short description of class.
Long description of class.
Can be multiline too.
# Arguments
name: `any`. Description of name.
age: `int`. Description of age. Defaults to zero.
If it is multiline then must indent the following lines.
sex: `str`. Description of sex. Defaults to 'male'.
**kwargs: `dict`.
# Note
Here is note.
# Examples
Here is examples.
```
jzm = Person('jzm')
batman = Person('Bruce Wayne', 28, 'male')
```
"""
def __init__(self, name, age=0, sex='male', **kwargs):
pass
def speak(self, message):
"""Short description of method.
Long description of method.
Can be multiline too.
# Arguments
message: `str`. Description of message.
# Return
`None`.
# Note
Here is note.
# Examples
Here is examples.
```
batman = example_create('Bruce Wayne', 28, 'male')
batman.speak('I am batman!')
```
"""
pass