Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no attribute allow_extra_args #2

Closed
pmatos opened this issue Apr 25, 2017 · 5 comments
Closed

no attribute allow_extra_args #2

pmatos opened this issue Apr 25, 2017 · 5 comments

Comments

@pmatos
Copy link

pmatos commented Apr 25, 2017

Thanks for sphinx-click. I tried it with the git example from the click docs and unfortunately it fails with allow_extra_args even though the program itself works fine so it might be due to some interaction between click and sphinx.

The program is:

import os
import click


class Repo(object):
    def __init__(self, home=None, debug=False):
        self.home = os.path.abspath(home or '.')
        self.debug = debug


@click.group()
@click.option('--repo-home', envvar='REPO_HOME', default='.repo')
@click.option('--debug/--no-debug', default=False,
              envvar='REPO_DEBUG')
@click.pass_context
def cli(ctx, repo_home, debug):
    ctx.obj = Repo(repo_home, debug)

@cli.command()
@click.argument('src')
@click.argument('dest', required=False)
def clone(src, dest):
    pass


@cli.command()
@click.argument('src')
@click.argument('dest', required=False)
@click.pass_obj
def clone(repo, src, dest):
    pass

if __name__ == '__main__':
    print('starting')
    cli(obj={})

I call this git.py and put it inside a git subfolder with an empty __init__.py that looks like:

git
  |- git
  |    |- __init__.py
  |    \- git.py
  \- docs
      |- git.rst
      |- index.rst
       \- conf.py

And the I have a git.rst that looks like:

.. click:: git:git
   :prog: git
   :show-nested:

When I run make html in docs I get:

reading sources... [ 50%] git                                            
Exception occurred:
  File "/home/pmatos/.pyenv/versions/3.6.0/envs/git-venv/lib/python3.6/site-packages/click/core.py", line 254, in __init__
    allow_extra_args = command.allow_extra_args
AttributeError: module 'git.git' has no attribute 'allow_extra_args'
The full traceback has been saved in /tmp/sphinx-err-22udtufb.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Makefile:53: recipe for target 'html' failed
@pmatos
Copy link
Author

pmatos commented Apr 25, 2017

I should mention that I am using sphinx-click==1.0.0, sphinx==1.5.5 and click==6.7.

@kciarnie
Copy link

I am also noticing this issue

@vphilippon
Copy link

vphilippon commented Apr 26, 2017

I'm not a pro of this plugin, but by messing around a bit and reading the doc, I noticed that the directive expects <module>:<parser>, where <parser> would be the command or group object.

So in this case, we'd probably want:
git.rst:

.. click:: git.git:cli
   :prog: git
   :show-nested:

I get other errors after that, but maybe that'll help you going forward.

Maybe the doc needs a little fix too, the example talks about a "example_app" module, but then uses "hello_world" as the module.

Hope you'll be able to move forward with that.

@stephenfin
Copy link
Member

@pmatos I had to change git:git to git.git:cli, as @vphilippon suggests. However, it failed to find the modules as I hadn't installed them (there's no setup.py or similar). To fix this, I had to uncomment/append the following lines to the top of docs/conf.py for this to work:

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

(note that that's .. - not .)

This highlighted another bug, whereby the extension expects a description even if one is not present. I'll resolve that now, and update the docs to highlight the above.

stephenfin added a commit that referenced this issue May 4, 2017
Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes-Bug: #2
@stephenfin
Copy link
Member

This is fixed in 1.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants