SignatureEntry(
fn : type,
*,
greedy : bool = True
) -> None:Builds the representation of a function signature.
Parameters
fn : typegreedy : bool = Trueaka majordome_utilities.documents
SignatureEntry(
fn : type,
*,
greedy : bool = True
) -> None:Builds the representation of a function signature.
fn : typegreedy : bool = Truedocumentation(
self : Any,
**kwargs : Any
) -> None:Generates the markdown documentation for the function.
title : str = Noneclass Dummy:
""" A dummy class for testing purposes. """
def method(self, a, b):
""" This is a method.
Parameters
----------
a : int
This is the first parameter.
b : int
This is the second parameter.
"""
pass
@staticmethod
def static_method(a, b):
""" This is a static method.
Parameters
----------
a : int
This is the first parameter.
b : int
This is the second parameter.
"""
pass
@classmethod
def class_method(cls, a, b):
""" This is a class method.
Parameters
----------
a : int
This is the first parameter.
b : int
This is the second parameter.
"""
pass
@property
def prop(self) -> int:
""" This is a property. """
return 42Documentation of all members at once is discouraged, but it is possible to do so by calling all methods of `DocumentedClass:
doc = DocumentedClass(Dummy)
doc.constructor()
doc.members()
doc.properties()
doc.classmethods()
doc.staticmethods()For generating more organized documentation, it is possible to selectively include or exclude static methods, class methods and properties. This allows to generate separate sections for each type of member, which can be more readable and easier to navigate.
The constructor:
Dummy():A dummy class for testing purposes.
Only normal methods:
method(
self : Any,
a : Any,
b : Any
):This is a method.
a : Anyb : AnyOnly static methods:
static_method(
a : Any,
b : Any
):This is a static method.
a : Anyb : AnyOnly class methods:
class_method(
cls : Any,
a : Any,
b : Any
):This is a class method.
a : Anyb : AnyOnly properties:
prop(self : Any): -> int:This is a property.
A minimal function with no parameters and no docstring:
def awesome_useless():
passawesome_useless():(missing summary)
A function with variadic parameters and no documented parameters:
def awesome_useless(*args, **kwargs):
""" Some useless function. """
passawesome_useless(
*args : Any,
**kwargs : Any
):Some useless function.
*args : AnyA function with variadic parameters with type annotation and explictly documented keyword parameter:
def awesome_useless(*args: tuple[int, ...], **kwargs):
""" Some useless function.
Parameters
----------
args : tuple
Positional arguments. This is intended to be a catch-all for
any number of positional arguments. Let's write a long text.
some_kwarg : int = 1
Keyword argument. This is intended to be a catch-all for any
number of keyword arguments. Let's write a long text.
"""
passawesome_useless(
*args : tuple[int, ...],
**kwargs : Any
):Some useless function.
*args : tuple[int, ...]some_kwarg : int = '1'A function with a positional-only parameter, a keyword-only parameter and variadic parameters:
def awesome_useless(a: int, /, b, **kwargs):
""" Some useless function. """
passawesome_useless(
a : int,
/,
b : Any,
**kwargs : Any
):Some useless function.
a : intb : AnyFunction with all kinds of parameters:
def awesome_useless(x, /, y: int = 0, *, z: int = 0, **kwargs) -> None:
""" Some useless function.
Parameters
----------
x : int
Nothing to say about this.
y : int
Nothing to say about this.
z : int
Nothing to say about this.
xx : int
Nothing to say about this.
"""
passawesome_useless(
x : Any,
/,
y : int = 0,
*,
z : int = 0,
**kwargs : Any
) -> None:Some useless function.
x : Anyy : int = 0z : int = 0xx : int = None