Has anyone figured out how to get sphinx-autodoc t...
# ask-the-community
g
Has anyone figured out how to get sphinx-autodoc to work with Flyte task/workflow decorators? I found that creating a Sphinx extension (similar to what Celery did here) worked, but am curious if anyone else has dealt with this
y
hey could you say more?
what are you trying to do?
you’re running sphinx separately i assume
autodoc is failing because the decorator is getting in the way?
g
Use sphinx-autodoc to document a task that uses the
@task
decorator.
Copy code
from flytekit import task


@task
def test_task(x: int) -> int:
    """My test task.

    Args:
        x: Integer for test
    """
    return x
Autodoc picks up the file, but does not document
test_task
- still trying to figure out why, but I think it has something to do with the decorator converting the object to a
PythonFunctionTask
instance
If I remove the task decorator, the
test_task
function is properly documented with sphinx-autodoc
Was seeing if anyone else has tried this - everything looks fine, like the decorated object has a
__doc__
property 🤔
I think the issue is ultimately with autodoc not handling decorators that return a class properly (see issue) but trying to find a workaround. Following what was done for Celery works (link above) but it’s not ideal
y
could you file an issue for this?
please
this is something we should clean up
along with the decorator type hinting
side note.
g
sure, I can file an issue
y
as of 1.3, we are pushing comments in tasks and workflows to admin
the UI is not yet updated but it will be soon hopefully
g
I saw the recent Documentation MR - excited for comments and other annotations in the near future!
Copy code
.. automodule:: flyte_common.my_task
   :members:
   :undoc-members:
   :show-inheritance:

.. autoclass:: flyte_common.my_task.my_task
   :members:
^ Seems like using automodule is not working, but autoclass directly on the task is working..
y
oh nice.
yeah the decorators turn them into classes
g
still super confused why automodule doesn’t pick it up 🤔 from the logs it almost looks like it thinks it’s a module and skips it
Copy code
[app] emitting event: 'autodoc-skip-member'('module', 'example_task', <flytekit.core.python_function_task.PythonFunctionTask object at 0x7fb9c4
[app] emitting event: 'autodoc-skip-member'('module', 'example_workflow', WorkflowBase - flyte_common.my_task.example_workflow && Inputs (1): {
203 Views