When documenting MATLAB classes using sphinxcontrib-matlabdomain, private methods defined in separate .m files (but declared as private inside the class file) are still included in the generated documentation.
According to the documentation’s statement only public members should appear when using :members:.
Example
Folder structure:
+package1
└─ +package2
└─ @MyClass
├─ MyClass.m
└─ helper1.m
In MyClass.m:
classdef MyClass
methods
function obj = MyClass()
end
end
methods (Access = private)
helper1(obj)
end
end
In helper1.m:
function helper1(obj)
% Private helper function
disp("Private method");
end
In index.rst:
.. mat:autoclass:: package1.package2.MyClass
:members:
Expected behavior
Private methods declared with (Access = private) should be excluded from the generated documentation, consistent with MATLAB’s visibility rules and the behavior for inline private methods.
Actual behavior
The private method helper1 is still included in the generated documentation.
Environment
When documenting MATLAB classes using sphinxcontrib-matlabdomain, private methods defined in separate .m files (but declared as private inside the class file) are still included in the generated documentation.
According to the documentation’s statement only public members should appear when using
:members:.Example
Folder structure:
In MyClass.m:
In helper1.m:
In index.rst:
Expected behavior
Private methods declared with (Access = private) should be excluded from the generated documentation, consistent with MATLAB’s visibility rules and the behavior for inline private methods.
Actual behavior
The private method helper1 is still included in the generated documentation.
Environment
Sphinx version: 5.0.2
sphinxcontrib-matlabdomain version: 0.22.1
MATLAB version: R2025b
OS: Windows 11