sphinx-contrib / matlabdomain

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

Autodocumentation of class property without default discards following comment. #152

Closed BuildingAtom closed 1 year ago

BuildingAtom commented 1 year ago

When using autoclass with a class that has properties without a default instance associated to it deletes the next comment that appears. As a short term workaround, I can add a trailing comment character.

Quick example

classdef PropertyClass < handle
    properties
        % Document this property
        documented double

        % This line is deleted
        % This line documents another property
        another_property char
    end
end

and the following rst file

.. mat:autoclass:: PropertyClass
   :show-inheritance:
   :members:

This happens with or without any sort of property validation. I can workaround it by adding a trailing comment.

classdef PropertyClass < handle
    properties
        % Document this property
        documented double %

        % This line is no longer deleted
        another_property char %
    end
end
joeced commented 1 year ago

Tanks a lot for the detailed report. I'll look into soon

joeced commented 1 year ago

Hi

I cannot reproduce this. I tried it with test "test_docs" and your example and it renders:

billede

Can you upload a small example project where this happens.

BuildingAtom commented 1 year ago

Hi joeced, sorry for taking a bit to respond.

I put together a mini example and attached it here. It includes a Dockerfile and script to build in that environment, though it's nothing more than just adding the rtd theme and matlab-sphinx on top of the base sphinx docker image. To build, just run ./build-docs.sh html in bash or similar.

example_magic.zip

joeced commented 1 year ago

I tried again - I cannot reproduce the error you are seeing. Could you try to type pip freeze, and post the output. This way I can see the versions of Sphinx you are using.

BuildingAtom commented 1 year ago

Here's the resulting output of pip freeze: requirements.txt

joeced commented 1 year ago

Same result. I cannot reproduce this. Could you try do

make clean
make html

And verify that you are really seeing this error.

BuildingAtom commented 1 year ago

Sure, I took a screenshot with the project I shared earlier. Both src.PropertyClass and src.PropertyClassMagic should render the exact same documentation. src.PropertyClassMagic shows the expected output for both. It uses the workaround where % is appended as a discarded comment so that the previously discarded comment appears. image

Some additional environment details: I'm running Windows 11, with a WSL2 Ubuntu 20.04.5 environment. I have docker installed in this environment and am running with the build_script I provided. This build script runs make, so I ran ./build_script.sh clean and ./build_script.sh html for the same effect. The output when run is as follows: image

Running from the WSL filesystem or from mounted windows filesystem doesn't seem to have an effect, nor does the EOL type being CRLF or LF.

joeced commented 1 year ago

OMG... massive 🤦‍♂️🤦‍♂️🤦‍♂️. I can confirm it's not working correctly. Working on it now.