sphinx-contrib / matlabdomain

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

Matlab and Python projects #130

Closed FelixBiermann closed 2 years ago

FelixBiermann commented 2 years ago

Hello,

I am having problems with shared Matlab and Python projects. Basically, new Matlab scripts are only included if I set "primary_domain = 'mat" in conf.py, but then obviously no Python file is included in the html page. Without "primary_domain" set, only Python files are included. Do I need to manually add the Matlab entries into modules.rst/index.rst? I am aware, that this bug has been reported and was apparently solved, but I don't get it working...

In the hope, that it is possible, and I am just failing, that's how my project layout looks like: (For demonstration purpose, I am testing with test Matlab files from this repo)

├── base │   ├── Domain.m │   ├── MatlabClass.m │   ├── Monoid.m │   ├── NiceFiniteGroup.m │   ├── PythonClass.py └── docs ├── build ├── make.bat ├── Makefile └── source ├── conf.py ├── index.rst ├── modules.rst

conf.py: sys.path.append(os.path.abspath('../..')) matlab_src_dir = os.path.abspath('../..') extensions = ['sphinxcontrib.matlab', 'sphinx.ext.autodoc', 'sphinx.ext.graphviz', 'sphinx.ext.viewcode', "myst_parser", 'sphinx.ext.inheritance_diagram', 'sphinx.ext.autosectionlabel'] source_suffix = ['.rst', '.md']

Within docs/ I am using sphinx-apidoc (sphinx-apidoc -f -o source/ ../base)

Thanks a lot!

joeced commented 2 years ago

Hi

Would it be possible for you to attach a zip-file with the project? That would make it a lot easier for me to debug it?

FelixBiermann commented 2 years ago

Hi joeced,

Of course! A test project to reproduce this error is attached. I am using the latest versions of this repo (v0.12 and Sphinx (v4.4). Within the docs/ folder, I use the following commands to build the doc:

sphinx-apidoc -f -o source/ ../base
make html 

The scripts are example scripts from this repo.

Thank you for your work in general and for your help!

Regards, Felix

Test_FB.zip

joeced commented 2 years ago

Hi again

Thanks for the test project - it really makes it a lot easier to work with. Ufortunately, sphinx-apidoc does not play well with mixed MATLAB and Python projects as I discovered in #100.

I modified the output the base.rst file to

base package
============

Submodules
----------

base.PythonClass module
-----------------------

.. automodule:: base.PythonClass
   :members:
   :undoc-members:
   :show-inheritance:

Module contents
---------------

.. mat:automodule:: base

.. mat:autoclass:: base.MatlabClass
   :members:
   :undoc-members:
   :show-inheritance:

.. mat:autoclass:: base.Group
   :members:
   :undoc-members:
   :show-inheritance:

and removed the primary_domain in conf.py. Then I can render it to:

billede

FelixBiermann commented 2 years ago

Hi joeced,

thanks for the quick replies! So a solution for bigger, mixed projects would be to run apidoc once with and once without "primary_domain='mat'" and then combine the output files. Of course, some files will be overwritten by the second run and have to be moved somewhere else first, but than it is more of a copy&paste problem, which again could be automated. At least for my purposes.

Thanks for all your effort, Felix

joeced commented 2 years ago

I guess that could work. I have never used sphinx-apidoc at work for any project, so I have very limited experience with it. Can I close the issue?