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

Updating sphinx from 1.8.0 to 1.8.1 results in warning #6047

Closed
topic2k opened this issue Feb 9, 2019 · 8 comments
Closed

Updating sphinx from 1.8.0 to 1.8.1 results in warning #6047

topic2k opened this issue Feb 9, 2019 · 8 comments

Comments

@topic2k
Copy link

topic2k commented Feb 9, 2019

Previously posted in forum: https://groups.google.com/d/msg/sphinx-users/C1JJH62UMaM/AigXvOC-CQAJ

Describe the bug
After the updating sphinx from 1.8.0 to 1.8.1 building of the docs print these warnings:

WARNING: error while formatting arguments for eg.TriggerEvent: 'function' object has no attribute '__bases__'
WARNING: error while formatting arguments for eg.PrintError: 'function' object has no attribute '__bases__'

To Reproduce
Steps to reproduce the behavior (Windows only):

$ git clone https://github.com/EventGhost/EventGhost
$ cd EventGhost\_build\data
$ sphinx-build -b html docs tmp

Expected behavior
A sphinx build run without errors.

Your project
https://github.com/EventGhost/EventGhost
https://github.com/EventGhost/EventGhost/tree/master/_build/data/docs

Environment info

  • OS: Windows
  • Python version: 2.7.15
  • Sphinx version: 1.8.1
  • Sphinx extensions: sphinx.ext.autodoc

Additional context

Komiya Takeshi wrote
I think that might be related with this change.
sphinx-doc:16533cf...sphinx-doc:65a560f#diff-48ca4d6544b092f35d729127500bff5fR1058

@tk0miya
Copy link
Member

tk0miya commented Feb 10, 2019

As I commented in the group, what I'd like to know is how eg.TriggerEvent and eg.PrintError are implemented. It is strongly related with this problem. In your post, replacing isfunction() by isroutine() is needed for your code. It means these code are not functions.

Could you let me know how to implement them? Unfortunately, I don't have windows PC. so it would be very nice if you let me know the location of code.

@tk0miya tk0miya added this to the 1.8.5 milestone Feb 10, 2019
@topic2k
Copy link
Author

topic2k commented Feb 10, 2019

eg.TriggerEvent is implemented in eg.Classes.EventThread.py.
eg.PrintError is implemented in eg.Classes.Log.py

@tk0miya
Copy link
Member

tk0miya commented Feb 10, 2019

It seems both are not functions. They're methods. inspect.isfunction() returns False value for methods.

$ python
Python 3.7.1 (default, Oct 23 2018, 19:06:59)
[Clang 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo:
...     def meth(self): pass
...
>>> import inspect
>>> inspect.isfunction(Foo().meth)
False

I feel very strange to use function directive for methods...

@topic2k
Copy link
Author

topic2k commented Feb 10, 2019

With that information i stepped through the building and the source files. When i replace .. autofunction:: eg.TriggerEvent in eg/index.rst with .. automethod:: eg.EventThread.TriggerEvent the build generates no warning (for TriggerEvent), but in the output we then have EventThread.TriggerEvent instead of eg.TriggerEvent.
Can it be because we assign the method to the dynamic module?

If this is special case with our source code, is there way i can automatically replace EventThread.TriggerEvent with eg.TriggerEvent in the generated file?

@topic2k
Copy link
Author

topic2k commented Feb 11, 2019

I've made a small runable app that also runs on Linux. Run python2 build_docs.py to see the warning. (python3 doesn't raise the warning)

EventGhost.zip

tk0miya added a commit to tk0miya/sphinx that referenced this issue Feb 17, 2019
tk0miya added a commit to tk0miya/sphinx that referenced this issue Feb 17, 2019
@tk0miya
Copy link
Member

tk0miya commented Feb 17, 2019

I just posted PR #6083. I suppose this fixes the warning. Could you try it please?

@topic2k
Copy link
Author

topic2k commented Feb 17, 2019

The fix results in a correct build. Thank you.

tk0miya added a commit that referenced this issue Feb 17, 2019
…hods

Fix #6047: autodoc: ``autofunction`` emits a warning for method objects
@tk0miya
Copy link
Member

tk0miya commented Feb 17, 2019

Thank you for confirmation :-)

@tk0miya tk0miya closed this as completed Feb 17, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants