Documenting a file with sphinx, that has local_import in it

194 views
Skip to first unread message

Vasil Petkov

unread,
May 28, 2011, 4:47:01 AM5/28/11
to web2py-users
Hello!

I use web2py 1.94 on Ubuntu with Python 2.7 and Sphinx 1.0.7. For the
documentation purposes, i have created a 'doc'-directory inside my
web2py-application. My web2py project has the following structure:

web2py
|_ server
| |_ applications
| |_ init
| | |_ controllers
| | |_ myapp.py
... ...
| |_ modules
| |_ xml2obj.py
...
|_ doc

When i try to generate documentation for the myapp.py-file with
sphinx, i get the following warning:

Traceback (most recent call
last):
File "/usr/local/lib/python2.7/dist-packages/Sphinx-1.0.7-py2.7.egg/
sphinx/ext/autodoc.py", line 329, in import_object
__import__(self.modname)
File "/home/vpetkov/Documents/web2py/server/applications/init/
controllers/myapp.py", line 16, in <module>
xml2obj = local_import('xml2obj', reload=False)
NameError: name 'local_import' is not defined

/home/vpetkov/Documents/web2py/server/doc/myapp.rst:7: (WARNING/2)
autodoc can't import/find module 'myapp', it reported error: "name
'local_import' is not defined", please check your spelling and
sys.path

Additionally. in conf.py Sphinx file, i added
sys.path.append(os.path.abspath('../applications/init/modules/'))

Jason Brower

unread,
May 28, 2011, 4:49:05 AM5/28/11
to web...@googlegroups.com
It's not in your version. But the upcoming release I think fixes this
very issue.
As far as I know.
Best Regards,
Jason

Vasil Petkov

unread,
May 28, 2011, 4:58:37 AM5/28/11
to web2py-users
Hello Jason!

On May 28, 11:49 am, Jason Brower <encomp...@gmail.com> wrote:
> It's not in your version.

What do you mean with this? What is not in my version?

> But the upcoming release I think fixes this
> very issue.

And what and where is fixed?

Massimo Di Pierro

unread,
May 28, 2011, 11:18:42 AM5/28/11
to web2py-users
controllers and models in web2py are written in python but are not
python modules. They use objects
(request,response,...,local_import,...) that are not imported.

Sphinx does not understand this.

I am sure there is a way around (for example add to your models and
controllers:

if 1:
from gluon import *
request,response,session,cache,T = \
current.request,current.response,
current.session,current.cache,current.T
from gluon.compileapp import local_import_aux as local_import

) but I cannot say for sure without details about what you are trying
to do.

Dan

unread,
Jun 30, 2011, 1:29:53 PM6/30/11
to web2py-users
I'm having the same issue. Where do I have to include all this? Is
there some other workaround for this? It would be great if we could
use Sphinx for documenting out Web2Py apps.

Thanks for any help.



On May 28, 5:18 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:

Richard Vézina

unread,
Jun 30, 2011, 2:00:46 PM6/30/11
to web...@googlegroups.com
Interresting too in the fix to use Sphynx to document app...

Richard

Carl Hunter Roach

unread,
Aug 8, 2017, 11:06:14 AM8/8/17
to web2py-users
Is this still the recommended workaround to get Sphinx to generate documentation for projects built upon Web2py?

Richard Vézina

unread,
Aug 8, 2017, 11:51:25 AM8/8/17
to web2py-users
I think web2py is sphinx compliant now, I recall that Simone (Niphold) had refactor docstring to do so... To be confirmed...

Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carl Hunter Roach

unread,
Aug 8, 2017, 12:40:14 PM8/8/17
to web...@googlegroups.com
thanks Richard.

I saw the changelog thanking Niphold wrt docstrings but only found Massimo's suggestion of additional code to add to each .py file to get Sphinx to "find" all my project files. 
 
Off the bat, after I point Sphinx at gluon, I get errors about request, current et al not being found. This is what I expected given web2py's architecture. I'm just on the hunt for a workaround.

I see that gluon/packages/dal has Sphinx definition files but these, I don't think, provide clues to how to deal with request et al. And gluon itself doesn't have Sphinx config files so, perhaps, Sphinx-support has a way to go?


To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/cYQTCXeGVdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Carl D Hunter Roach
Bisham Barn Owl Group
Runnymede Ringing Group

Richard Vézina

unread,
Aug 8, 2017, 1:24:40 PM8/8/17
to web2py-users
I look at sphinx a long time ago, so you kind of lost me now... But I tought after I press send that fact that web2py doc is available with readthedoc which is (correct me if I am wrong) base on sphinx, so web2py is suppose to work with sphinx... But web2py apps, I guess it another story, for some of the reasons you mention... About request and other web2py environnement objects maybe you can work something base on this workaround related to IDE :


To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/cYQTCXeGVdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Carl D Hunter Roach
Bisham Barn Owl Group
Runnymede Ringing Group

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

Carl Hunter Roach

unread,
Aug 8, 2017, 3:45:58 PM8/8/17
to web...@googlegroups.com
Thanks Richard.
Are you using an alernative to Sphinx with your web2py projects?
I've tried epydoc which is straightforward but I found  its docstring format a little labourious.

To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/cYQTCXeGVdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Carl D Hunter Roach
Bisham Barn Owl Group
Runnymede Ringing Group

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/cYQTCXeGVdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Richard Vézina

unread,
Aug 8, 2017, 3:52:21 PM8/8/17
to web2py-users
Saddly never had time to integrate such tools in my project... I never really understand the concept of Epydoc for my part haha!! 

Richard

To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/cYQTCXeGVdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Carl D Hunter Roach
Bisham Barn Owl Group
Runnymede Ringing Group

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/cYQTCXeGVdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Carl D Hunter Roach
Bisham Barn Owl Group
Runnymede Ringing Group

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages