click-contrib / sphinx-click

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

Unknown directive type "click" #65

Closed staticdev closed 4 years ago

staticdev commented 4 years ago

I am using a following versions of packages:

click==7.1.2 Sphinx==3.2.1 sphinx-click==2.5.0

Then I added to my project directive as in the usage documentation:

.. click:: __main__:cli
   :prog: gitp
   :show-nested:

But when I try to build documentation with sphinx-build I get the error: Unknown directive type "click".

You can see my code here: https://github.com/staticdev/git-portfolio/blob/master/src/git_portfolio/__main__.py

stephenfin commented 4 years ago

You need to enable the extension by adding the following to your conf.py.

extensions = ['sphinx_click']
staticdev commented 4 years ago

@stephenfin I added the extension, but it changed the error message:

README.rst:69: WARNING: "<class 'function'>" of type "__main__:main" is not derived from "click.BaseCommand"

But I followed the documentation and am using the a @click.group. I also tried changing to another @click.group:

.. click:: __main__:create
   :prog: gitp
   :show-nested:

Then I get another error:

README.rst:69: WARNING: Module "__main__" has no attribute "create"

stephenfin commented 4 years ago

I suspect __main__ isn't what you think it is. Try git_portfolio.__main__:create. If that doesn't work, I'd suggest starting with the examples and working backwards to get what you need.

staticdev commented 4 years ago

@stephenfin you are absolutely correct again! git_portfolio.__main__:create did the trick.

Double thanks for the issue!