I have identified where the exception is coming from, and I think I have a 
fix, but I'm not entirely sure whether it is valid. 

Location: sphinx.util.inspect.is_builtin_class_method()

Problem: __builtins__ is used directly, however Jython does not define 
__builtins__, therefore an exception is raised.

Possible Solution: use the __builtin__ module (instead of the __builtins__ 
produced by CPython when __name__ == "__main__")

Implementation:
At top of 'inspect.py': add import __builtin__
Lines 155 and 157: change __builtins__ to __builtin__

Test: With these changes the example provided in the DocString 
(is_builtin_class_method(int, 
'__init__')) does return True, rather than raising the 'not defined' 
exception.

How can I go about getting this reviewed, and so if appropriate 
incorporated in the next release?


On Monday, February 17, 2014 9:17:06 AM UTC, tetburr wrote:
>
> I have found more information about the warning - Sphinx is trying to use 
> the CPython-specific '__builtins__' module, rather than the universal 
> '__builtin__'.
>
> As stated here 
> <http://docs.python.org/2/library/__builtin__.html>'__builtins__' is a 
> CPython implementation detail. As stated 
> here <http://www.jython.org/archive/21/docs/differences.html>, "Jython 
> doesn't support restricted execution mode and doesn't have the magic 
> __builtins__ in every namespace. *Jython will probably never support 
> restricted execution mode -- Java's security model is recommended instead.*
> "
>
> Despite the "global name '__builtins__' is not defined" warnings (one for 
> each module and class) my documentation is being generated as expected.
>
> So, my question becomes - how do I suppress this warning without 
> suppressing all similar warnings?
>
> On Thursday, February 13, 2014 9:55:01 AM UTC, tetburr wrote:
>>
>> I have a Windows 7 machine running Jython 2.5.2 and Sphinx 1.2.1 (with 
>> Numpydoc 0.4). I have created a very simple module with a very simple class 
>> documented within it. Everything works fine (the html documentation is 
>> produced as expected), except for the following warning and error:
>>
>> - WARNING: error while formatting [module name].Example: global name 
>> '__builtins__' is not defined
>> - ERROR: Unknown directive type "autosummary"
>>
>> My setup (all installed manually (extract then 'jython setup.py install') 
>> because the Windows 7 machine is not connected to the internet):
>> - Jython 2.5.2
>> - Jinja2 2.6
>> - docutils 0.11
>> - Pygments 1.6
>> - Sphinx 1.2.1
>> - numpydoc 0.4
>>
>> The sphinx-* scripts have been renamed with the '.py' extension so that 
>> Windows recognises them as Python scripts (Windows does not look for 
>> shebangs, even for files without a file extension).
>>
>> The module:
>>
>> class Example(object):
>>     """
>>     An example class.
>>
>>     This class acts as a documentation example for testing 
>> auto-generation of documentation.
>>
>>     Parameters
>>     ----------
>>     a : string
>>         A parameter called `a`
>>
>>     b : integer
>>         A parameter called `b`
>>     """
>>
>>     def __init__(self, a, b):
>>         pass
>>
>>     def example_method(self, a, b):
>>         """
>>         An example method.
>>
>>         This method acts as a documentation example as well.
>>
>>         Parameters
>>         ----------
>>         a : string
>>             A parameter called `a`
>>
>>         b : integer
>>             A parameter called `b`
>>         """
>>         pass
>>
>> The conf.py includes:
>> sys.path.insert(1, r"absolute\path\to\module")
>> extensions = [
>>     'sphinx.ext.autodoc',
>>     'sphinx.ext.viewcode',
>>     'numpydoc',
>> ]
>>
>> Why do I get this wanring and error, and/or how can I fix them?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to