如何将文档添加到 matlab 包中?

How do I add documentation to a matlab package?

假设我有以下文件结构:

+mypackage/
  foo.m
  bar.m

如何向 help(mypackage) 的输出添加帮助?

在 python 中,我只是在 __init__.py 中添加一个文档字符串。这里的等价物是什么?

根据 MA​​TLAB 的 toolbox distribution documentation, the MATLAB analog to Python's __init__.py docstring would be a help summary file.

使用上述文件夹结构,我们可以添加一个 contents.m 文件来实现所需的行为:

+mypackage/
  foo.m
  bar.m
  contents.m

给定一个基本的 contents.m 文件:

% This is contents.m
% This package contains:
%     bar - Bar things
%     foo - Foo things

我们实现了以下目标:

>> help mypackage
  This is contents.m
  This package contains:
      bar - Bar things
      foo - Foo things