click-contrib / sphinx-click

A Sphinx plugin to automatically document click-based applications
MIT License
212 stars 57 forks source link

Click commands disappear from autodoc #68

Closed ri0t closed 3 years ago

ri0t commented 3 years ago

I just noticed that all the click commands are not appearing in autodoc-generated pages.

Check out the original module: https://github.com/isomeric/isomer/blob/master/isomer/tool/remote.py

vs. the generated click documentation: https://isomer.readthedocs.io/en/latest/manual/Administration/tool.html#iso-remote

vs. the generated autodoc documentation: https://isomer.readthedocs.io/en/latest/dev/packages/isomer/isomer.tool.remote.html

This might confuse readers a lot, especially since i found no sane way to link to the click documentation pages in all of the concerned autodoc pages.

stephenfin commented 3 years ago

I think you need to file this bug against the isomer project. Looks like a misconfiguration on their end.

ri0t commented 3 years ago

I could but since i'm the core coder there, that wouldn't really help much ;)

Any ideas what i'm doing wrong? I didn't configure much around autodoc or sphinx-click.. My starting page describing the CLI with click-sphinx:

.. click:: isomer.tool.tool:isotool
   :prog: iso
   :nested: full

What i use to autodoc everything:

#!/usr/bin/env sh

sphinx-apidoc -f -M -e -d 5 --ext-autodoc --ext-viewcode -o dev/packages/isomer ../../isomer

Thanks in advance!

stephenfin commented 3 years ago

It looks like sphinx-click is doing what it's supposed to and it's Sphinx's autodoc featue that's not working. That sounds like a bug report for Sphinx, if anything. I can't really help you there. The issue is potentially down to the various click decorators but that's a pure guess. Maybe try using wrapper functions to work around it? (remember to update the click docs to use new names if you change anything).

@cli.group()
@click.other_stuff
def _remote(ctx, name, install, platform, source, url, existing):
    remote(ctx, name, install, platform, source, url, existing)

def remote(ctx, name, install, platform, source, url, existing):
    pass