Skip to content

Private methods defined in separate .m files but listed under methods (Access = private) in the class file are still shown in the generated documentation. #299

Description

@manuel1801

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

  • Sphinx version: 5.0.2

  • sphinxcontrib-matlabdomain version: 0.22.1

  • MATLAB version: R2025b

  • OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions