-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathisdocumented.m
More file actions
42 lines (33 loc) · 1.18 KB
/
isdocumented.m
File metadata and controls
42 lines (33 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function isdocumented(varargin)
if nargin < 1
folderPath = pwd;
else
folderPath = varargin{1};
end
% Get a list of all files in the folder
log = Log;
files = dir(fullfile(folderPath, '*.m'));
% Initialize a flag to track if any undocumented files are found
isUndocumentedFound = false;
% Loop through each file
for i = 1:numel(files)
filePath = fullfile(folderPath, files(i).name);
% Read the contents of the file
fileContents = fileread(filePath);
% Check if the file contains a documentation block
Name = files(i).name(1:end-2);
if ~contains(fileContents, ['% ', upper(Name)]) && ...
~contains(fileContents, ['%', upper(Name)])
str = sprintf('❌ Undocumented file: %s', files(i).name);
log.warn(str);
isUndocumentedFound = true;
else
str = sprintf('✅ Documented file: %s', files(i).name);
log.info(str);
end
end
% Display a message if all files are documented
if ~isUndocumentedFound
disp('All files are documented. 👏👏');
end
end