wsmeext.sphinxext Sphinx integration, autodoc and find_service_path 0.5b1
Created originally on Bitbucket by korroot
Hello. While working on project, I have developed REST API using Pecan. I have added response using WSME for JSON formating. I planned to use Sphinx for code documentation. Then the mess started.
Using: Pecan 0.2.0b2 WSME 0.5b1 Sphinx 1.2b1
When trying to use autodoc in Sphinx, the wsmeext.sphinxext.find_service_path does not work:
sphinx-build -b html -d _build/doctrees . _build/html
Making output directory...
Running Sphinx v1.2b1
loading pickled environment... not yet created
building [html]: targets for 6 source files that are out of date
updating environment: 6 added, 0 changed, 0 removed
reading sources... [ 66%] source/myapp.controllers
Exception occurred:
File "/usr/local/lib/python2.7/dist-packages/wsmeext/sphinxext.py", line 123, in scan_services
if len(path) > wsme.api.APIPATH_MAXLEN:
AttributeError: 'module' object has no attribute 'APIPATH_MAXLEN'
I have played around with /usr/local/lib/python2.7/dist-packages/wsmeext/sphinxext.py replacing missing attribute with value 20, and then it started to work as follows:
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.2b1
loading pickled environment... not yet created
building [html]: targets for 6 source files that are out of date
updating environment: 6 added, 0 changed, 0 removed
reading sources... [ 66%] source/myapp.controllers
Exception occurred:
File "/usr/local/lib/python2.7/dist-packages/wsmeext/sphinxext.py", line 124, in scan_services
raise ValueError("Path is too long: " + str(path))
ValueError: Path is too long: ['book', 'is_config_loaded', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator', 'denominator']
The full traceback has been saved in /tmp/sphinx-err-l2g9kl.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.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-users/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
It looks like infinite loop while going deeper and deeper into class' values.
The conf.py Sphinx file:
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'wsmeext.sphinxext']
wsme_protocols = ['restjson']
wsme_root = "myapp.controllers.root.RootController"
The source/myapp.controllers.rst file:
:mod:`Book` Module
-------------------
.. automodule:: myapp.controllers.book
.. autoservice:: myapp.controllers.book.BookController
:members:
Lets say there is only root controller and one BookController(RestController) and this BookController has 2 methods:
get_one(self, book_id)
get_all(self)
If more info is needed to debug this, please ask.
Regards :)