Create Help Summary Files —
What Is a
Contents.m file provides a summary of the programs in a
particular folder. The
ver functions refer to
to display information about folders.
Contents.m files contain only comment lines. The first two
lines are headers that describe the folder. Subsequent lines list the program files
in the folder, along with their descriptions. Optionally, you can group files and
include category descriptions. For example, view the functions available in the
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 file exists in a folder, the
doc functions display a
generated list of all program files in the folder. For example, the folder
myfiles contains five program files and no
Contents.m file. When you call the
function on the folder, it displays the list of program files in the folder and a
brief description for each
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.
If you do not want the
functions to display the generated list, place an empty
Contents.m file in the folder. If a folder contains an empty
Contents.m file, the
doc functions display
there is another folder with the same name, the
foldername is a folder
doc functions display the information for that folder
To customize what the
functions display for a folder, create a customized
In the folder that contains your program files, create a file named
Copy this template into the
% 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
Modify the template to match the contents of your folder. When modifying the template, do not include any spaces in the date field in the second comment line. This comment line enables the
verfunction to detect the version information.
For example, this
Contents.mfile describes the contents of the
% 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
Optionally, you can include
See alsolinks in the
Contents.mfile. To include
See alsolinks, add a line at the end of the file that begins with
% See alsofollowed by a list of function names. If the functions exist on the search path or in the current folder, the
docfunctions display each of these function names as a hyperlink to its help. Otherwise, the
docfunctions print the function names as they appear in the
For example, this code adds
See alsolinks to the files
myfile2.m, which are on the path.
% % See also MYFILE1, MYFILE2
You also can include hyperlinks (in the form of URLs) to websites in your help text. Create hyperlinks by including an HTML
<a></a>anchor element. Within the anchor, use a
matlab:statement to execute a
For example, this code adds a hyperlink to the MathWorks website.
% For more information, see the <a href="matlab: % web('https://www.mathworks.com')">MathWorks website</a>.
Once you have created your
Contents.m file, use the
doc functions to display the
contents of your folder. For example, display the contents of the
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.
To get the version information for your folder, use the
function. For example, get the version information for the
v = ver("myfiles")
v = struct with fields: Name: 'Folder containing my program files' Version: '1.2.0' Release: '' Date: '09-Nov-2022'