sphinx-contrib / matlabdomain

A Sphinx extension for documenting Matlab code
http://sphinxcontrib-matlabdomain.readthedocs.io/
Other
70 stars 45 forks source link

Fail to generate matlab documentation #100

Closed andreasdoll closed 4 years ago

andreasdoll commented 4 years ago

Hello,

I want to document python and Matlab code together using autodoc, but I'm having trouble getting sphinx to work with Matlab at all. I suppose there is an obvious mistake from my side, but I cannot pinpoint it.

My structure is as follows:

Code is located at:

project/src/foo.py (with docstrings)
project/src/add.m (with docstrings)

Documentation and documentation config is located at project/docs, and in there I have (I give only the relevant parts):

# conf.py
sys.path.insert(0, os.path.abspath('../src'))
matlab_src_dir = os.path.abspath('../src')
primary_domain = None
extensions = ['sphinx.ext.autodoc', 'sphinxcontrib.matlab']

Now when I run

$ sphinx-build -b html docs/ docs/_build; sphinx-apidoc -o docs/ src/

the documentation for the python file is generated, but not for Matlab. I've read on stackoverflow that in conf.py I should comment sys.path.insert(0, os.path.abspath('../src')), but then neither python nor Matlab documentation is generated.

I'm using sphinxcontrib-matlab 0.11.0. Any help welcome!

joeced commented 4 years ago

Hi. I haven't used sphinx-apidoc myself, so I'm not sure if it's compatible with the MATLAB sources. Can you show the output of the call to sphinx-apidoc.

Alternatively, provide a minimal file structure in a zip-file, then I'll look at it.

bembel commented 4 years ago

Hi, I'm having a similar issue though I want to generate documentation for Matlab-code only. sphinx-apidoc generates a list of all necessary toc-entries in source/modules.rst (assuming you split build and source during set-up of sphinx-quickstart). For python code, if you assume I only have a main.py file and one module the source/modules.rst after running sphinx-apidoc looks like this:

.. toctree::
   :maxdepth: 4

   main
   test_module

And the files main.rst and test_module.rst are created as well. How do you do this for Matlab-code?

The output for the sphinx-apidoc call is Creating file source\modules.rst. but this file only contains

my_project
====================

.. toctree::
   :maxdepth: 4

I am aware this is not really a bug but more a question about usage but I am new to sphinx and could not find any answers anywhere. Any help would be greatly appreciated 😉

joeced commented 4 years ago

I just tried sphinx-apidoc, and reading the documentation, it's clear it's only for Python source files.

If you need help writing the rst-files for Matlab source, try looking at the example code https://github.com/joeced/sphinx-docs-matlab-example-1, or post another issue.

shervinsafavi commented 4 years ago

First of all, thanks to @joeced for putting the effort into creating sphinx for MATLAB domain. I just wanted to share a similar experience with sphinx-apidoc. I also think it can be extremely helpful to have sphinx-apidoc working for MATLAB codes. If you think it makes sense, I'll create a new issue (for a new feature).

joeced commented 4 years ago

That's quite ok with me. Will you post the issue on the sphinx-apidoc board?

andreasdoll commented 4 years ago

Sorry for the late reply, but thanks @joeced for investigating the issue!