How to do method documentation for Classes/Handles just as normal functions in m files?
조회 수: 7 (최근 30일)
이전 댓글 표시
When working with many methods in a given class or handle class it would be convenient to be able to see the list of inputs i.e. the documentation of the method. If I have an instance of a handle class called "C2" with method "RunAnalysis", then when I press the "F1" key, the help menu will say:
" MATLAB File Help
C2.RunAnalysis
No help found for C2.RunAnalysis.
Search for C2.RunAnalysis in documentation "
How do I do method documentation for Classes/Handles just as normal they would appear when I press "F1" key for normal functions in m files?
댓글 수: 0
답변 (1개)
Suraj Mankulangara
2018년 4월 2일
Hello Yasen
You can provide help text for a function or class by doing the following:
1) Below the class or function definition line (i.e. below the lines containing the "classdef" or "function" declarations), add a line with "%%" followed by a space, and write your help text there 2) If you would like to spread the help text over multiple lines, you could add "%" lines below (followed by space), and they will be shown in the description of the class or function.
The following link should give you a better idea of how to go about this:
For your quick reference, I have created a dummy class called testClass (whether it is a handle class or not does not matter), with a property and function, and some dummy comments:
classdef testClass < handle
%%Test class
% More information about test class
properties
% Some value is stored in this property
testProperty
end
methods
function check()
%%This is a function that does so and so
% It also does something else..
disp('Hello');
end
end
end
The help text can be accessed by running:
>> help testClass
Test class
More information about test class
Reference page for testClass
>> help testClass.testProperty
Some value is stored in this property
>> help testClass.check
This is a function that does so and so
It also does something else..
Sincerely
Suraj Mankulangara
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!