Closed joeced closed 6 years ago
Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):
fixes #34
Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):
fixes #34
Original comment by yarmond (Bitbucket: yarmond, GitHub: yarmond):
I think the following would work with both Sphinx 1.2.x and 1.3.x:
#!python
try:
# Sphinx >= 1.3.0
from sphinx.util.inspect import object_description
except ImportError:
# Sphinx < 1.3.0
from sphinx.util.inspect import safe_repr as object_description
Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):
so I replaced safe_repr
with object_description
and most of the tests build, but the re.subn
doesn't replace ellipsis for some reason, so I still need to troubleshoot that, if any one wants to take a stab
also I'm unhappy that this breaks sphinxcontrib-matlabdomain
for Sphinx<1.3, which is a large group of users so I would like to fix that as well before pushing out another release, again contributions are welcome!
and while we're at it there are still a couple of open issues, namely fixing class methods that have separate files so that their protocols are ignored when reading the mfile with the classdef, otherwise it raises type error since the function doesn't look right to Pygments. Any help would be greatly appreciated.
Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):
sphinx.util.inspect.safe_repr()
has been replaced by sphinx.util.inspect.object_description()
. I will update this and submit a new package as soon as I can. In the meantime change it in mat_documenters
modulematlab_src_dir
to set the root of your project. Python can not import MATLAB m files.sys.path.append()
to add sphinxcontrib-matlabdomain to your python path. You should install sphinxcontrib-matlabdomain using pip
as described in the Installation section of the README.rst. If you are uncertain about installing sphinxcontrib-matlabdomain into your main or system site-packates (or dist-packages) then create a virtualenv, activate it and install your requirements including sphinxcontrib-matlabdomain there. IMHO it is bad practice and generally unpythonic to use sys.path.append()
in reusable code.Original comment by Levyn (Bitbucket: Levyn, GitHub: Levyn):
I just got the same error with python v2.7.9 and sphinx v1.3.1 on Windows 7
Originally I tried to use sphinxcontrib-matlabdomain with python v3.4 (WinPython). But there I got errors that looked like being syntax problems, so I changed to python v2. Would it actually be possible to run sphinxcontrib-matlabdomain with python v3? I did not find this information in the extension's description.
Below some further information about the errors of the python v2 attempt:
Thanks in advance, Levyn
Here's my conf.py
#!python
import sys
import os
sys.path.insert(0, os.path.abspath('..\..\sphinxcontrib-matlabdomain-0.2.6\sphinxcontrib'))
sys.path.insert(0, os.path.abspath('..\..\sphinxcontrib-matlabdomain-0.2.6'))
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinxcontrib.matlab',
]
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = 'TestMAtlab'
copyright = '2015, Levyn'
version = '1'
release = '1'
exclude_patterns = []
pygments_style = 'sphinx'
html_theme = 'default'
html_static_path = ['_static']
htmlhelp_basename = 'TestMAtlabdoc'
latex_elements = {
latex_documents = [
('index', 'TestMAtlab.tex', 'TestMAtlab Documentation',
'Levyn', 'manual'),
]
man_pages = [
('index', 'testmatlab', 'TestMAtlab Documentation',
['Levyn'], 1)
]
texinfo_documents = [
('index', 'TestMAtlab', 'TestMAtlab Documentation',
'Levyn', 'TestMAtlab', 'One line description of project.',
'Miscellaneous'),
]
and here's the error message from the cmd:
#!cmd
C:\Users\Levyn\Documents\7_Sphinx\TestMatlab>sphinx-build -vvv -P -b html source build
Running Sphinx v1.3.1
[app] setting up extension: 'sphinx.ext.autodoc'
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.ModuleDocumenter'>
[app] adding directive: ('automodule', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.ClassDocumenter'>
[app] adding directive: ('autoclass', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.ExceptionDocumenter'>
[app] adding directive: ('autoexception', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.DataDocumenter'>
[app] adding directive: ('autodata', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.FunctionDocumenter'>
[app] adding directive: ('autofunction', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.MethodDocumenter'>
[app] adding directive: ('automethod', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.AttributeDocumenter'>
[app] adding directive: ('autoattribute', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.InstanceAttributeDocumenter'>
[app] adding directive: ('autoinstanceattribute', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding config value: ('autoclass_content', 'class', True)
[app] adding config value: ('autodoc_member_order', 'alphabetic', True)
[app] adding config value: ('autodoc_default_flags', [], True)
[app] adding config value: ('autodoc_docstring_signature', True, True)
[app] adding config value: ('autodoc_mock_imports', [], True)
[app] adding event: 'autodoc-process-docstring'
[app] adding event: 'autodoc-process-signature'
[app] adding event: 'autodoc-skip-member'
[app] setting up extension: 'sphinx.ext.viewcode'
[app] adding config value: ('viewcode_import', True, False)
[app] connecting event 'doctree-read': <function doctree_read at 0x03379CF0> [id=0]
[app] connecting event 'env-merge-info': <function env_merge_info at 0x03379D30> [id=1]
[app] connecting event 'html-collect-pages': <function collect_pages at 0x03379DB0> [id=2]
[app] connecting event 'missing-reference': <function missing_reference at 0x03379D70> [id=3]
[app] setting up extension: 'sphinxcontrib.matlab'
Original exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\application.py", line 429, in setup_extension
mod = __import__(extension, None, None, ['setup'])
File "C:\Python27\lib\site-packages\sphinxcontrib_matlabdomain-0.2.6-py2.7.egg\sphinxcontrib\matlab.py", line 13, in <module>
import mat_documenters as doc
File "C:\Python27\lib\site-packages\sphinxcontrib_matlabdomain-0.2.6-py2.7.egg\sphinxcontrib\mat_documenters.py", line 28, in <module>
from sphinx.util.inspect import getargspec, isdescriptor, safe_getmembers, \
ImportError: cannot import name safe_repr
Exception occurred while building, starting debugger:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\cmdline.py", line 244, in main
opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
File "C:\Python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\application.py", line 143, in __init__
self.setup_extension(extension)
File "C:\Python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\application.py", line 433, in setup_extension
err)
ExtensionError: Could not import extension sphinxcontrib.matlab (exception: cannot import name safe_repr)
> c:\python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\application.py(433)setup_extension()
-> err)
Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):
@Aeus, could you please provide more detail:
I've never seen this error, so without more to go on, I'm not sure what to look for.
Originally reported by: Anonymous
I am using sphinx to generate code for a matlab document, however I cannot build anything due to an error on the beginning of build;
Could not import extension sphinxcontrib.matlab (exception: cannot import name safe_repr) make: *** [html] Error 1
I am unsure why this error is appearing as the call seems valid in the extension.