클래스에 대한 도움말 생성하기
doc 명령으로 표시되는 도움말 텍스트
doc
명령을 사용하여 클래스에 대한 도움말을 표시할 때 MATLAB®은 클래스 정의에서 파생된 정보를 자동으로 표시합니다.
예를 들어, 다음과 같이 여러 개의 속성과 메서드를 사용하여 클래스 정의 파일 someClass.m
을 만듭니다.
classdef someClass % someClass Summary of this class goes here % Detailed explanation goes here properties One % First public property Two % Second public property end properties (Access=private) Three % Do not show this property end methods function obj = someClass % Summary of constructor end function myMethod(obj) % Summary of myMethod disp(obj) end end methods (Static) function myStaticMethod % Summary of myStaticMethod end end end
doc
명령을 사용하여 클래스 정의에서 파생된 도움말 텍스트와 세부 정보를 표시합니다.
doc someClass
사용자 지정 도움말 텍스트
doc
명령과 help
명령 둘 다 표시하는 클래스에 대한 정보를 추가할 수 있습니다. doc
명령은 생성된 HTML 페이지의 상단에 도움말 텍스트를 표시하는데 이는 클래스 정의에서 파생된 정보 위에 위치합니다. help
명령은 명령 창에 도움말 텍스트를 표시합니다. 자세한 내용은 다음을 참조하십시오.
클래스
파일 내 classdef
문 바로 다음 라인에 있는 주석을 포함시켜 클래스에 대한 도움말 텍스트를 만듭니다. 예를 들어, 아래와 같이 myClass.m
이라는 파일을 만드십시오.
classdef myClass % myClass Summary of myClass % This is the first line of the description of myClass. % Descriptions can include multiple lines of text. % % myClass Properties: % a - Description of a % b - Description of b % % myClass Methods: % doThis - Description of doThis % doThat - Description of doThat properties a b end methods function obj = myClass end function doThis(obj) end function doThat(obj) end end end
첫 번째 주석 블록에 속성과 메서드의 목록과 설명을 포함하는 것은 선택 사항입니다. 클래스 이름 뒤에 Properties
나 Methods
가 나오고 콜론(:
)이 나오는 주석 라인을 포함시키는 경우, MATLAB은 해당 속성이나 메서드에 대한 도움말의 하이퍼링크를 만듭니다.
help
명령을 사용하여 명령 창에서 클래스에 대한 도움말 텍스트를 확인합니다.
help myClass
myClass Summary of myClass This is the first line of the description of myClass. Descriptions can include multiple lines of text. myClass Properties: a - Description of a b - Description of b myClass Methods: doThis - Description of doThis doThat - Description of doThat
메서드
함수 정의문 바로 뒤에 주석을 삽입하여 메서드에 대한 도움말을 생성합니다. 예를 들어, doThis
메서드에 대한 도움말을 포함하도록 클래스 정의 파일 myClass.m
을 수정하십시오.
function doThis(obj) % doThis Do this thing % Here is some help text for the doThis method. % % See also DOTHAT. disp(obj) end
help
명령을 사용하여 명령 창에서 메서드에 대한 도움말 텍스트를 확인합니다. 클래스 이름과 메서드 이름을 점으로 구분하여 지정합니다.
help myClass.doThis
doThis Do this thing
Here is some help text for the doThis method.
See also doThat.
속성
속성에 대한 도움말을 생성하는 방법에는 다음 두 가지가 있습니다.
속성 정의 위에 주석 라인을 삽입합니다. 여러 라인으로 된 도움말 텍스트의 경우 이 방법을 사용하십시오.
속성 정의 옆에 단일 라인의 주석을 추가합니다.
정의 위에 있는 주석이 정의 옆에 있는 주석보다 우선합니다.
예를 들어, 클래스 정의 파일 myClass.m
에서 속성 정의를 다음과 같이 수정하십시오.
properties a % First property of myClass % b - Second property of myClass % The description for b has several % lines of text. b % Other comment end
help
명령을 사용하여 명령 창에서 속성에 대한 도움말을 확인합니다. 클래스 이름과 속성 이름을 점으로 구분하여 지정합니다.
help myClass.a
a - First property of myClass
help myClass.b
b - Second property of myClass The description for b has several lines of text.
열거형
속성과 마찬가지로, 열거형에 대한 도움말을 생성하는 방법에는 다음 두 가지가 있습니다.
열거형 정의 위에 주석 라인을 삽입합니다. 여러 라인으로 된 도움말 텍스트의 경우 이 방법을 사용하십시오.
열거형 정의 옆에 단일 라인의 주석을 추가합니다.
정의 위에 있는 주석이 정의 옆에 있는 주석보다 우선합니다.
예를 들어, 파일 myEnumeration.m
에 다음과 같이 열거형 클래스를 만드십시오.
classdef myEnumeration enumeration uno, % First enumeration % DOS - Second enumeration % The description for DOS has several % lines of text. dos % A comment (not help text) end end
help
명령을 사용하여 명령 창에서 도움말을 확인합니다. 클래스 이름과 열거형 멤버를 점으로 구분하여 지정합니다.
help myEnumeration.uno
uno - First enumeration
help myEnumeration.dos
dos - Second enumeration The description for dos has several lines of text.
이벤트
속성 및 열거형과 마찬가지로, 이벤트에 대한 도움말을 생성하는 방법에는 다음 두 가지가 있습니다.
이벤트 정의 위에 주석 라인을 삽입합니다. 여러 라인으로 된 도움말 텍스트의 경우 이 방법을 사용하십시오.
이벤트 정의 옆에 단일 라인의 주석을 추가합니다.
정의 위에 있는 주석이 정의 옆에 있는 주석보다 우선합니다.
예를 들어, 파일 hasEvents.m
에 다음과 같이 클래스를 만듭니다.
classdef hasEvents < handle events Alpha % First event % Beta - Second event % Additional text about second event. Beta % (not help text) end methods function fireEventAlpha(h) notify(h,'Alpha') end function fireEventBeta(h) notify(h,'Beta') end end end
help
명령을 사용하여 명령 창에서 도움말을 확인합니다. 클래스 이름과 이벤트를 점으로 구분하여 지정합니다.
help hasEvents.Alpha
Alpha - First event
help hasEvents.Beta
Beta - Second event Additional text about second event.