2

I'm trying to run the example/demo given on sphinxcontrib-matlabdomain pypi site but autodoc module fails to import the matlab example files.

I setup the sphinx environment with sphinx-quickstart. OS is Ubuntu 18.04. My directory structure looks like this

root
|--------test_data
|                |--MyHandleClass.m
|
|
|--------conf.py
|--------Makefile
|--------index.rst

The relevant parts of my config.py are

import os
:
:
extensions = [
    'sphinxcontrib.matlab',
    'sphinx.ext.autodoc',
]
:
:
matlab_src_dir = os.path.abspath('.')
print "matlab_src_dir: ", matlab_src_dir

The rst file is copied from the example

Test Data
=========
This is the test data module.

.. automodule:: test_data

:mod:`test_data` is a really cool module.

My Handle Class
---------------
This is the handle class definition.

.. autoclass:: MyHandleClass

    :show-inheritance:
    :members: 

The output when running make html is

Running Sphinx v1.8.5
matlab_src_dir:  /home/xxxxx/Desktop/sphinxtest
WARNING: while setting up extension sphinx.ext.autodoc: directive 'automodule' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autoclass' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autoexception' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autodata' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autofunction' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'automethod' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autoattribute' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autoinstanceattribute' is already registered, it will be overridden
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment: [] 0 added, 1 changed, 0 removed
reading sources... [100%] test_data                                                                                                    
WARNING: autodoc: failed to import module u'test_data'; the following exception was raised:
No module named test_data
WARNING: don't know which module to import for autodocumenting u'MyHandleClass' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] test_data                                                                                                     
generating indices... genindex
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, 10 warnings.

The HTML pages are in _build/html.

I like to believe I followed the instructions to a tee. But am I missing something here?

barryhunter
  • 20,886
  • 3
  • 30
  • 43
GeezleGit
  • 23
  • 3
  • I'm the maintainer of the module and will look at it when I have access to a PC. – Jørgen Jun 15 '19 at 12:56
  • The order of extensions is important `'sphinxcontrib-matlabdomain`', should be after `'sphinx.ext.autodoc'`. This should probably be more clear in the documentation. – Jørgen Jun 17 '19 at 07:22

1 Answers1

1

The order of extensions is important, and this might not be entirely clear from the documentation. So the conf.py file should look like this instead.

import os
:
:
extensions = [
    'sphinx.ext.autodoc',
    'sphinxcontrib.matlab',
]
:
:
matlab_src_dir = os.path.abspath('.')
print "matlab_src_dir: ", matlab_src_dir

Note (2019-11-09): In version 0.10.0, this is no longer a problem as Python and MATLAB auto-documentation can co-exist.

Jørgen
  • 853
  • 9
  • 16
  • 1
    Thanks for your quick reply and sorry for my late reply. Just on holiday with intermittent web access. Your suggestion did the job. Cheers!! – GeezleGit Jun 22 '19 at 19:51