This is a module docstring. It will appear in documentation.
You can use Markdown here to make it nicer. Also, in any docstring you
can put a global object import string in backticks, like other_module.OtherClass,
and it will be transformed to a link.
Handsdown API Index / Examples / Main Example
Auto-generated documentation for examples.main_example module.
MODULE_NAME- This is a comment-style documented global variable, so it is added tomain_examplemodule attributes with this comment as a documentation for it: 'My Module'
Show source in main_example.py:54
STUFF_COUNT- This is a comment-style documented class attribute, so it is added tomain_example.MyClassattributes with this comment as a documentation for it.: 3
MyClass documentation here.
This time we use RST docstrings format.
class MyClass(BaseClass): ...Show source in main_example.py:92
Magic methods are added to docs only if they have docstrings.
True if STUFF_COUNT is not zero
def __bool__(self) -> bool: ...Show source in main_example.py:65
This is a public method that uses comment-style type annotations. If decorators
or types from annotations are from your project, links to them will be added
to See also section. Since this function depends on STUFF_COUNT, we can add
it to a docstring in backticks and it will be transformed to a link.
# usage example
def my_stuff(amount):
return amount > 5
MyClass.do_something(my_stuff) # FalseAdded in version 1.3
Deprecated in version 1.8
Changed in version 1.4
All these directives are added to Notes section and formatted in Sphinx-style.
stuff- Function do execute.
stuff result.
@classmethod
def do_something(cls, stuff: StuffCallable) -> bool: ...Show source in main_example.py:27
This is module function and it is added to documentation even if it does not have a docstring. Function signature will be also generated respecting regular and comment-style type annotations. Let's use PEP 257 format here.
# Google-style code block here, but we could use Markdown code block as well
>>> hello('John')
'Hello, John!'
>>> hello('')
'Hello!'name- Name of the person to greet.
A greeting. No need to put types here if you use type annotations.
def hello(name: str) -> str: ...