Abstract methods – which have a signature but not a body – are currently not documented. It would be nice to be able to document them though, since they exist to define an interface for users to extend ("if you inherit from this class, you must write a function that...<precise explanation that should live in a docstring>").
The trouble is that these methods are special cases lexically because they aren't bookended by function and end. Here's an example.
classdef My_Class < handle
% Docstring for the class.
methods (Abstract)
% How can we document this method?
val = abstractmethod1(arg)
% Perhaps a docstring here?
% This is also not documented.
[val1, val2] = abstractmethod2(arg1, arg2)
end
methods
function [out] = publicmethod(arg)
% This is documented.
out = 2 * arg;
end
end
end
Now with this RST block somewhere,
.. autoclass:: My_Class
:show-inheritance:
:members:
:undoc-members:
we get documentation for publicmethod() but not abstractmethod1() or abstractmethod2().
This was discussed a little way back in #28. Is this something that can be added without too much trouble? Adding function and end is not allowed for abstract methods, so it would have to be handled as a special case. It seems pretty natural to allow docstrings with this style:
[val1, val2] = abstractmethod2(arg1, arg2)
% This is the docstring.
%
% It may or may not continues for multiple lines.
% But watch out! It won't be followed by an ``end`` statement!
Thanks for writing this extension, it's a huge help for our project.
Abstract methods – which have a signature but not a body – are currently not documented. It would be nice to be able to document them though, since they exist to define an interface for users to extend ("if you inherit from this class, you must write a function that...<precise explanation that should live in a docstring>").
The trouble is that these methods are special cases lexically because they aren't bookended by
functionandend. Here's an example.Now with this RST block somewhere,
we get documentation for
publicmethod()but notabstractmethod1()orabstractmethod2().This was discussed a little way back in #28. Is this something that can be added without too much trouble? Adding
functionandendis not allowed for abstract methods, so it would have to be handled as a special case. It seems pretty natural to allow docstrings with this style:Thanks for writing this extension, it's a huge help for our project.