- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
autosummary -- does not understand module level datas/attributes #344
Comments
From Fergus Noble on 2012-11-15 07:32:10+00:00 Can confirm this issue in version 1.1.3 and would also be interested in seeing a resolution. |
From Georg Brandl on 2013-03-31 13:57:37+00:00 Removing version: 0.6.3 (automated comment) |
From Marcel Stimberg on 2013-05-16 11:58:23+00:00 Everyone interested in this issue may have a look at pull request #142 where I tried to address it. Comments welcome! |
I think this issue is obsolete now, it has been fixed with the fix for issue #1444 and can therefore be closed. |
#1444 might fix the issue for classes but I unfortunately still have the issue for module attributes, A mediocre workaround I found is to forcibly set the CHROMATIC_ADAPTATION_TRANSFORMS = CaseInsensitiveMapping({
'XYZ Scaling': XYZ_SCALING_CAT,
'Von Kries': VON_KRIES_CAT,
'Bradford': BRADFORD_CAT,
'Sharp': SHARP_CAT,
'Fairchild': FAIRCHILD_CAT,
'CMCCAT97': CMCCAT97_CAT,
'CMCCAT2000': CMCCAT2000_CAT,
'CAT02': CAT02_CAT,
'CAT02_BRILL_CAT': CAT02_BRILL_CAT,
'Bianco': BS_CAT,
'Bianco PC': BS_PC_CAT
})
CHROMATIC_ADAPTATION_TRANSFORMS.__doc__ = """
Supported chromatic adaptation transforms.
CHROMATIC_ADAPTATION_TRANSFORMS : CaseInsensitiveMapping
**{'CAT02', 'XYZ Scaling', 'Von Kries', 'Bradford', 'Sharp', 'Fairchild,
'CMCCAT97', 'CMCCAT2000', 'CAT02_BRILL_CAT', 'Bianco', 'Bianco PC'}**
""" This is very limited because quite a lot of Python objects have read-only Here is a playground zip file to test all that: https://drive.google.com/file/d/1469JtgHLunCYud8DHWvgBofFYQ1qwpG6/view?usp=sharing |
@KelSolaar what version of sphinx do you use? Latest Sphinx considers the string after assignment is a docstring of the variable. |
I was using 1.5.7, upgraded to 1.6.6 and it breaks: (colour-2.7) Kali:autosummary kelsolaar$ rm -rf _build/ generated && make html
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.6.6
making output directory...
loading pickled environment... not yet created
[autosummary] generating autosummary for: doe.rst, index.rst
[autosummary] generating autosummary for: /Users/kelsolaar/Downloads/autosummary/generated/doe.rst, /Users/kelsolaar/Downloads/autosummary/generated/john.bar.rst, /Users/kelsolaar/Downloads/autosummary/generated/john.foo.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: 5 added, 0 changed, 0 removed
reading sources... [100%] index
/Users/kelsolaar/Downloads/autosummary/doe.rst:4: WARNING: autodoc: failed to import data u'foo' from module u'doe'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 666, in import_object
logger.debug('[autodoc] => %r', obj)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1440, in debug
self.logger.debug(msg, *args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1155, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1285, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1259, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 264, in __init__
and args[0]):
TypeError: __len__() takes exactly 2 arguments (1 given)
/Users/kelsolaar/Downloads/autosummary/doe.rst:4: WARNING: autodoc: failed to import data u'bar' from module u'doe'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 666, in import_object
logger.debug('[autodoc] => %r', obj)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1440, in debug
self.logger.debug(msg, *args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1155, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1285, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1259, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 264, in __init__
and args[0]):
TypeError: __len__() takes exactly 2 arguments (1 given)
/Users/kelsolaar/Downloads/autosummary/generated/john.bar.rst:6: WARNING: autodoc: failed to import data u'bar' from module u'john'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 666, in import_object
logger.debug('[autodoc] => %r', obj)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1440, in debug
self.logger.debug(msg, *args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1155, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1285, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1259, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 264, in __init__
and args[0]):
TypeError: __len__() takes exactly 2 arguments (1 given)
/Users/kelsolaar/Downloads/autosummary/generated/john.foo.rst:6: WARNING: autodoc: failed to import data u'foo' from module u'john'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 666, in import_object
logger.debug('[autodoc] => %r', obj)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1440, in debug
self.logger.debug(msg, *args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1155, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1285, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1259, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 264, in __init__
and args[0]):
TypeError: __len__() takes exactly 2 arguments (1 given)
/Users/kelsolaar/Downloads/autosummary/index.rst:12: WARNING: autodoc: failed to import data u'foo' from module u'john'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 666, in import_object
logger.debug('[autodoc] => %r', obj)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1440, in debug
self.logger.debug(msg, *args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1155, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1285, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1259, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 264, in __init__
and args[0]):
TypeError: __len__() takes exactly 2 arguments (1 given)
/Users/kelsolaar/Downloads/autosummary/index.rst:12: WARNING: failed to import object john.foo
/Users/kelsolaar/Downloads/autosummary/index.rst:12: WARNING: autodoc: failed to import data u'bar' from module u'john'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 666, in import_object
logger.debug('[autodoc] => %r', obj)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1440, in debug
self.logger.debug(msg, *args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1155, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1285, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 1259, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/local/anaconda3/envs/colour-2.7/lib/python2.7/logging/__init__.py", line 264, in __init__
and args[0]):
TypeError: __len__() takes exactly 2 arguments (1 given)
/Users/kelsolaar/Downloads/autosummary/index.rst:12: WARNING: failed to import object john.bar
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
generating indices... genindex py-modindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 8 warnings. |
It seems
|
Oh, sorry. I'd confused with autodoc. certainly autosummary does not refer the docstring. |
@tk0miya : Ah good catch, it is when I created the example, I copy-pasted the I'm having issues trying to document attributes that are directly defined from Kali:autosummary kelsolaar$ make html
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.5.6
making output directory...
loading pickled environment... not yet created
[autosummary] generating autosummary for: doe.rst, generated/doe.rst, generated/john.bar.rst, generated/john.foo.rst, generated/john.the_dict.rst, index.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 6 source files that are out of date
updating environment: 6 added, 0 changed, 0 removed
reading sources... [100%] index
/Users/kelsolaar/Downloads/autosummary/john.py:docstring of john.the_dict:3: ERROR: Unexpected indentation.
/Users/kelsolaar/Downloads/autosummary/john.py:docstring of john.the_dict:4: WARNING: Block quote ends without a blank line; unexpected unindent.
/Users/kelsolaar/Downloads/autosummary/john.py:docstring of john.the_dict:7: ERROR: Unexpected indentation.
/Users/kelsolaar/Downloads/autosummary/john.py:docstring of john.the_dict:8: WARNING: Inline strong start-string without end-string.
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
generating indices... genindex py-modindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 4 warnings.
Build finished. The HTML pages are in _build/html. I have started to pepper my code with explicit assignments to Is |
Not planned. I just realized this problem at your comment. So I tagged this as a task for 1.8. But I'm beginner of autosummary, so I can't say it will be fixed in 1.8. |
Thanks @tk0miya! I found a related problem that I will document in another issue. |
Sorry for very late. I just made a PR #5204 for this. Note: It supports docstring of module attributes. But it can't handle imported one. So |
…tring_of_modattrs Fix #344: autosummary does not understand docstring of module level attributes
Merged. It will be released as 1.8. |
Let's take following code:
Now if I do autosummary for the module like this:
Autosummary table contains incorrect entries for attributes/datas of module:
Underlying autodocumentor in other hand works correctly, since directive autodata gets the documentation string from attributes/datas of module correctly.
The text was updated successfully, but these errors were encountered: