sphinx-click icon indicating copy to clipboard operation
sphinx-click copied to clipboard

Cannot generate documentation using asyncclick

Open jmartel-olvid opened this issue 1 year ago • 2 comments

Hi,

I am trying to use sphinx-click with an asyncclick CLI.

I had issues when I used the last version (6.0.0) because it told me click module was not found.

So I fixed it by removing import click.core line in ext.py file.

This line have been added in commit 05b69cf. I am not sure why because without it it works i my configuration, I tried with version 5.1.0 and it's fine.

Thanks for your time

Here are my versions to reproduce the issue: Python 3.12.3 asyncclick==8.1.7.2 sphinx-click==6.0.0

jmartel-olvid avatar Sep 19 '24 09:09 jmartel-olvid

Try the following patch

--- a/sphinx_click/ext.py
+++ b/sphinx_click/ext.py
@@ -5,11 +5,11 @@ import traceback
 import typing as ty
 import warnings

+import click.core
 try:
     import asyncclick as click
 except ImportError:
     import click
-import click.core
 from docutils import nodes
 from docutils.parsers import rst
 from docutils.parsers.rst import directives

NickCao avatar Feb 06 '25 21:02 NickCao

I have the same issue. Why not support both? Like that:

  467         if not isinstance(
  468             parser, (asyncclick.Command, asyncclick.Group, click.Command, click.Group)                                                                         
  469         ):
  470             raise self.error(
  471                 '"{}" of type "{}" is not click.Command or click.Group.'
  472                 '"click.BaseCommand"'.format(type(parser), module_path)
  473             )
  474         return parser

Of course, it's necessary to adjust the other calls of isinstance, too. As a quick-fix it worked really well for me.

jloehel avatar Apr 10 '25 00:04 jloehel

Any update on this? I see there's a draft PR with no activity since April 14th. I'm also interested in this and willing to help.

eberkut avatar Jul 09 '25 13:07 eberkut

Would be very interested by this feature too !

Paul-AUB avatar Jul 09 '25 13:07 Paul-AUB

Any update on this? I see there's a draft PR with no activity since April 14th. I'm also interested in this and willing to help.

Does the PR fixes your issue? Can you please test it. :-D I used the approach in one private project like this:

sphinx-click = {git = "https://github.com/jloehel/sphinx-click", rev = "wip-asyncclick"}

I'll try to get the PR ready for review this weekend.

jloehel avatar Jul 15 '25 18:07 jloehel