Main Content

도움말 요약 파일 생성하기 — Contents.m

Contents.m 파일이란?

Contents.m 파일은 특정 폴더에 있는 프로그램에 대한 정보를 요약하여 제공합니다. help 함수와 doc 함수는 Contents.m 파일을 참조하여 폴더에 대한 정보를 표시합니다.

Contents.m 파일에는 주석 라인만 들어 있습니다. 처음 두 줄의 라인은 폴더에 대해 설명하는 헤더입니다. 이후 라인에는 폴더의 프로그램 파일이 설명과 함께 나열됩니다. 선택적으로, 파일을 그룹화하고 범주 설명을 포함할 수 있습니다. 예를 들어, codetools 폴더에서 사용할 수 있는 함수를 보겠습니다.

help codetools
  Commands for creating and debugging code
  MATLAB Version 9.14 (R2023a) 19-Nov-2022 
 
  Editing and publishing
    edit                   - Edit or create a file
    grabcode               - Copy MATLAB code from published HTML
    checkcode              - Check files for possible problems
    publish                - Publish file containing cells to output file
    snapnow                - Force snapshot of image for published document
  
  Directory tools
    mlintrpt               - Run mlint for file or folder, reporting results in browser
    visdiff                - Compare two files (text, MAT, or binary) or folders

   ...

폴더에 Contents.m 파일이 없으면, helpdoc 함수가 폴더에 있는 모든 프로그램 파일에 대해 생성된 목록을 표시합니다. 예를 들어, 폴더 myfiles에는 5개의 프로그램 파일이 들어 있고 Contents.m 파일은 없습니다. 이 폴더에 대해 help 함수를 호출하면, 폴더에 있는 프로그램 파일의 목록과 각각에 대한 간략한 설명이 표시됩니다.

help myfiles
Contents of myfiles:

    estimatePanelOutput - Calculate Solar Time
           lengthofline - Calculates the length of a line object
        solarCorrection - The function solarCorrection calculates the difference between local and
SolarPanelEstimatorForm - is a live script.
       WeatherDashboard - is a live script.

helpdoc 함수가 생성된 목록을 표시하지 않도록 하려면 폴더에 비어 있는 Contents.m 파일을 넣으십시오. 폴더에 비어 있는 Contents.m 파일이 들어 있으면 helpdoc 함수는 foldername is a folder를 표시합니다. 동일한 이름을 가진 또 다른 폴더가 있는 경우에는 helpdoc 함수가 대신 이 폴더의 정보를 표시합니다.

Contents.m 파일 만들기

helpdoc 함수가 폴더에 대해 표시하는 내용을 사용자 지정하려면 사용자 지정된 Contents.m 파일을 만듭니다.

  1. 프로그램 파일이 포함된 폴더에서 Contents.m 파일을 생성합니다.

  2. 다음 템플릿을 Contents.m 파일에 복사합니다.

    % Folder summary
    % Version xxx dd-mmm-yyyy 
    %
    % Description of first group of files
    %   file1                   - file1 description
    %   file2                   - file2 description
    % 
    % Description of second group of files
    %   file3                   - file3 description
    %   file4                   - file4 description
  3. 폴더의 내용과 일치하도록 템플릿을 수정합니다. 템플릿을 수정할 때 두 번째 주석 라인의 날짜 필드에 공백을 포함하지 마십시오.

    예를 들어, 다음 Contents.m 파일은 myfiles 폴더의 내용을 설명합니다.

    % Folder containing my program files
    % Version 1.2.0 09-Nov-2022 
    %
    % My Functions
    %   estimatePanelOutput            - Calculate solar time
    %   lengthofline                   - Calculate the length of a line object
    %   solarCorrection                - Calculate the difference between local and solar time
    % 
    % My Live Scripts
    %   SolarPanelEstimatorForm        - Estimate solar panel output
    %   WeatherDashboard               - Display weather data for Natick, MA
  4. 선택 사항으로 Contents.m 파일에 See also 링크를 포함시킬 수 있습니다. See also 링크를 추가하려면 % See also로 시작되고 다음에 함수 이름 목록이 오는 라인을 파일 끝에 추가하십시오. 함수가 검색 경로 또는 현재 폴더에 있는 경우 helpdoc 함수는 이러한 함수 이름 각각을 해당 도움말에 대한 하이퍼링크로 표시합니다. 그렇지 않을 경우, helpdoc 함수는 함수 이름을 Contents.m 파일에 나타나는 그대로 출력합니다.

    예를 들어, 다음 코드는 파일 myfile1.mmyfile2.m에 대한 See also 링크를 추가합니다.

    % 
    % See also MYFILE1, MYFILE2

    도움말 텍스트에 웹사이트에 대한 하이퍼링크(URL 형태)를 포함시킬 수도 있습니다. HTML <a></a> 앵커 요소를 포함시켜 하이퍼링크를 생성합니다. 앵커 내에서 matlab: 문을 사용하여 web 명령을 실행합니다.

    예를 들어, 다음 코드는 MathWorks 웹사이트에 대한 하이퍼링크를 추가합니다.

    % For more information, see the <a href="matlab: 
    % web('https://www.mathworks.com')">MathWorks website</a>.
    

Contents.m 파일을 생성한 후에는 helpdoc 함수를 사용하여 폴더의 내용을 표시합니다. 예를 들어, myfiles 폴더의 내용을 표시해 보겠습니다.

help myfiles
  Folder containing my program files
  Version 1.2.0 09-Nov-2022 
 
  My Functions
    estimatePanelOutput            - Calculate solar time
    lengthofline                   - Calculate the length of a line object
    solarCorrection                - Calculate the difference between local and solar time
  
  My Live Scripts
    SolarPanelEstimatorForm        - Estimate solar panel output
    WeatherDashboard               - Display weather data for Natick, MA

  See also myfile1, myfile2

  For more information, see the MathWorks website.

참고 항목

| |

관련 항목