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

"add_documenter()" is now removed from Sphinx 1.8 #14

Closed
jsivak opened this issue Mar 31, 2019 · 5 comments
Closed

"add_documenter()" is now removed from Sphinx 1.8 #14

jsivak opened this issue Mar 31, 2019 · 5 comments

Comments

@jsivak
Copy link

jsivak commented Mar 31, 2019

Getting the following error now that I've installed Sphinx 1.8:

Traceback (most recent call last):
  File "/home/jsivak/personal/knowledge_ve/bin/better-apidoc", line 6, in <module>
    from better_apidoc import main
  File "/home/jsivak/personal/knowledge_ve/lib/python3.7/site-packages/better_apidoc.py", line 51, in <module>
    from sphinx.ext.autodoc import add_documenter, \
ImportError: cannot import name 'add_documenter' from 'sphinx.ext.autodoc' (/home/jsivak/personal/knowledge_ve/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py)

The Sphinx 1.7 change log indicates that the "add_documenter()" function was going to be removed, and now in 1.8 it is actually removed.

I've forked the repo, but I don't know how to get an "app" object so that I can update the code to use "Please use app.add_autodocumenter() instead." as specified in the change log.

Any ideas/pointers?

Thanks

@jsivak jsivak changed the title "add_documenter" is now removed from Sphinx 1.8 "add_documenter()" is now removed from Sphinx 1.8 Mar 31, 2019
@goerz goerz closed this as completed in 41aaf55 Apr 2, 2019
@goerz
Copy link
Owner

goerz commented Apr 2, 2019

You're right. Unfortunately, I don't think it's possible to really fix this: the app object is available in conf.py (and, from there, is passed to any Sphinx extensions). I don't see any way to get an app object cleanly into better-apidoc, as a script.

I just pushed a very ugly workaround: have a global variable APP in the sphinx-apidoc script, and set that variable from conf.py before calling sphinx-apidoc.main(). This is not a permanent solution. The changes in Sphinx 1.7/1.8 make sphinx-apidoc in its current form impossible. I see only one option: refactor the script into a Sphinx extension, not a standalone script. I actually think this a good idea in any case. It will greatly simplify how apidoc is incorporated into the build process. I never liked that the original apidoc was designed as a script that has to be run manually/via a modified Makefile before sphinx itself generates the documentation. Indeed, I was already invoking better-apidoc from inside conf.py, so that I didn't have to touch docs/Makefile. It would certainly be much cleaner to just add an apidoc to the list of extensions in conf.py, and set options like the location of the API files to be generated and the templates to be used as variables, also in conf.py.

Refactoring into an extensions is not a crazily complicated change, but at the moment I cannot give any estimate on when I might have time to do this. For the moment, "it works for me", which I realize is not very satisfactory to anyone else using the script. For the time being, you'll have to use the same ugly workarounds I'm using.

@goerz
Copy link
Owner

goerz commented Apr 2, 2019

Refactoring into an extension would also solve #2, #3, #9, #11

@jsivak
Copy link
Author

jsivak commented Apr 3, 2019

Gotcha, thanks for the explanation and "hacks" to potentially keep better-apidoc somewhat working for the time being.

@goerz
Copy link
Owner

goerz commented Apr 4, 2019

The plan is to merge into the sphinxcontrib.apidoc extension in the relatively near future.

@goerz
Copy link
Owner

goerz commented Oct 25, 2019

Update: apidoc recently added basic templating, and I've opened a pull request to merge better-apidoc back into apidoc: sphinx-doc/sphinx#6768

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

2 participants