Cannot generate method documentation for abstract class

I've the following abstract class:
classdef (Abstract) SessionManager < handle
% SESSIONMANAGER Interface for a generic session manager.
% The session manager has the responsibility to manage the sessions that
% are opened for the system. It also allows to perform some operation on
% them.
methods
b = isSessionOpened(this)
% ISSESSIONOPENED Tells if a session is currently opened in the system.
session = getCurrentSession(this)
% The comment for getting current session
loadSession(this, session)
% another comment
clearSession(this)
% You know what's this
end
end
When I try to retrieve the help of the class, I can see the description from the command line:
help SessionManager
But when I click on the link for seeing the documentation page. I cannot see the documentation for methods, they are blank:
This is what I see when I click on a link of a custom method:
What I'm doing wrong? How can I document properly the methods?

 採用された回答

Animesh
Animesh 2024 年 5 月 8 日

0 投票

This seems to be an issue with the way you have declared your functions. The functions should be declared in the following format to generate proper help documentation:
function b = isSessionOpened(this)
% ISSESSIONOPENED Tells if a session is currently opened in the system.
end
You can refer the following MathWorks documentation for more information:
Hope this helps in resolving the issue.

4 件のコメント

Daniele Lupo
Daniele Lupo 2024 年 5 月 8 日
So I need to create the body even if this is an abstract method of an abstract interface? Because it seems to work, but it gives me (correct) warnings about unused parameter and unitialized return values.
Animesh
Animesh 2024 年 5 月 9 日
In case of Abstract methods, you firstly have to mention that the methods being declared are Abstract. Also, in this case the help comments would come above the function declaration.
methods (Abstract) % Abstract is missing from the code provided
% ISSESSIONOPENED Tells if a session is currently opened in the system.
b = isSessionOpened(this)
end
Daniele Lupo
Daniele Lupo 2024 年 5 月 10 日
Thanks, it seems to work. But I don't understand why I need to mark as abstract the methods section if the class is abstract itself... I need to check the documentation.
thanks again.
Steven Lord
Steven Lord 2024 年 5 月 10 日
You can have non-Abstract methods in an Abstract class.
In addition, if your class is defined in an @ directory specifying the method attribute Abstract can help MATLAB distinguish whether those methods are Abstract or defined in a separate file.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

製品

リリース

R2022b

質問済み:

2024 年 5 月 8 日

コメント済み:

2024 年 5 月 10 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by