Skip to content

Propagate docstring from decorated function in FunctionTask #552

@ghisvail

Description

@ghisvail

I would like to provide documentation (with doctests) for a FunctionTask, like:

@task
@annotate({"return": {"sum": int}})
def add(x: int, y: int):
    """Add x to y.

    Examples
    ----------
    >>> task = add(x=1, y=2)
    >>> result = task()
    >>> result.output.sum
    3
    """
    return a + b

Similar to what we have been doing with interfaces implemented with ShellCommandTask.

This does not work however, since the docstring of the wrapped function is not propagated to the FunctionTask class. So far, I have implemented one wrapped function per Python module and used the module's docstring for this purpose.

I wonder whether we could propagate this docstring so that each FunctionTask can have its own documentation.

Unless there is already a feature to achieve this that I totally missed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions