Skip to content

Commit bfcac1a

Browse files
committed
do also something for classes ...
1 parent 77f92a0 commit bfcac1a

File tree

7 files changed

+64
-16
lines changed

7 files changed

+64
-16
lines changed

@DocFile/copy.m

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
function copy(docFile,destination)
22
% copy all docFiles to the given destination folder
33

4-
if isempty(dir(destination))
4+
[~,~,ext] = fileparts(destination);
5+
6+
if isempty(dir(destination)) && isempty(ext)
57
mkdir(destination);
68
end
79

810
for k=1:numel(docFile)
911
copyfile(docFile(k).sourceFile,destination);
10-
end
12+
end

@DocFile/exclude.m

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function docFile = exclude(docFile,varargin)
2+
% remove directories or files from docfile
3+
4+
for i = 1:nargin-1
5+
6+
docFile = docFile(cellfun('isempty',strfind({docFile.sourceFile},varargin{i})));
7+
8+
end

@DocFile/getFormatedRef.m

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
function helpStr = getFormatedRef( file ,varargin)
22
% returns a processed string for function file
33
%
4-
%% Input
4+
% Input
55
% file - current file
66
%
7-
%% Output
7+
% Output
88
% helpString - a string for publishing
99
%
10-
%% Remarks !TODO
10+
% Remarks !TODO
1111
% 'input', 'output', 'example', 'see also', 'description', 'syntax', 'view code'
1212
%
13-
%% See also
13+
% See also
1414
% DocFile/getFormatedDoc DocFile/publish
1515

1616
options = parseArguments(varargin);
@@ -61,15 +61,32 @@
6161
function sections = help2struct(file,options)
6262
% struct('title','sectioname','content','descriptive text')
6363

64-
6564
helpStr = helpfunc(file.sourceFile);
65+
66+
if isempty(helpStr)
67+
process = helpUtils.helpProcess(0,1, {file.sourceFile});
68+
69+
process.getHelpText;
70+
71+
helpStr = process.helpStr;
72+
73+
end
74+
75+
76+
6677
docName = file.sourceInfo.docName;
6778
Title = regexprep(docName,'(\w*)\.(\w*)', ...
6879
['$2' char(10) ' \(method of [[$1_index.html,$1]]\)' char(10) ' % ']);
6980

7081
helpStr = [' % ' Title char(10) helpStr];
7182

7283
helpStr = regexprep(helpStr,'(?<=^|\n) ','%');
84+
85+
keyWords = {'Input','Output','Syntax','Options','Flags','See also','Description'};
86+
for i = 1:numel(keyWords)
87+
helpStr = regexprep(helpStr,['\n\%\s*' keyWords{i}],['\n\%\% ' keyWords{i}]);
88+
end
89+
7390
helpStr = globalReplacements(helpStr,options.outputDir);
7491
m = m2struct(helpStr);
7592

@DocFile/isClass.m

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function isCl = isClass(file)
2+
% checks whether docFile is a class file
3+
%
4+
%% Input
5+
% file - a @DocFile
6+
%
7+
%% Output
8+
% isCl - |true| / |false|
9+
10+
str = read(file);
11+
12+
isCl = any(strfind(str,'classdef'));

@DocFile/isFunction.m

+5-6
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,18 @@
1919
lineBreak = regexp(str,'\n');
2020
if hasKeyword(1) == 1
2121
Syntax = str(10:lineBreak(1));
22+
isFun = true;
2223
else
2324
lastLineBreak = lineBreak(lineBreak<hasKeyword(1));
2425
lineTillFuncStr = str(lastLineBreak+1:hasKeyword(1)+7);
2526

26-
if isempty(strfind(lineTillFuncStr,'%'))
27-
nextLineBreak = lineBreak(lineBreak > hasKeyword(1));
28-
Syntax = str(hasKeyword(1)+9:nextLineBreak(1));
29-
end
27+
nextLineBreak = lineBreak(lineBreak > hasKeyword(1));
28+
Syntax = str(hasKeyword(1)+9:nextLineBreak(1));
29+
if isempty(strfind(lineTillFuncStr,'%')), isFun = true; end
3030
end
3131

3232
if exist('Syntax','var')
3333
Syntax = strtrim(Syntax);
34-
Syntax = regexprep(Syntax,'varargin','...,param,val,...');
35-
isFun = true;
34+
Syntax = regexprep(Syntax,'varargin','''param1'',val1,''param2'',val2');
3635
end
3736
end

@DocFile/publish.m

+5-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@
8787

8888

8989

90-
% if ~isfield(options,'publishSettings')
90+
if ~isfield(options,'publishSettings')
91+
options.publishSettings = struct;
92+
end
9193

9294
switch options.format
9395
case {'latex','tex'}
@@ -105,7 +107,7 @@
105107
end
106108

107109
% end
108-
options.publishSettings = struct;
110+
109111
options.publishSettings.useNewFigure = true;
110112
if ~isfield(options.publishSettings,'format')
111113
options.publishSettings.format = format;
@@ -176,7 +178,7 @@ function prepareFilesToPublish(docFiles,options)
176178
% end
177179

178180
try
179-
if isFunction(docFile)
181+
if isFunction(docFile) || isClass(docFile)
180182
text = getFormatedRef(docFile,'outputDir',outputDir);
181183
else
182184
text = getFormatedDoc(docFile,docFiles);

resources/style/toolbox.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<mytoolbox>
3+
<name>MTEX</name>
4+
<fullname>&lt;b&gt;MTEX&lt;/b&gt; - A MATLAB Toolbox for Quantitative Texture Analysis</fullname>
5+
<versionname>MTEX 4.0.0</versionname>
6+
<procuctpage>mtex_product_page.html</procuctpage>
7+
<icon>$toolbox/matlab/icons/book_mat.gif</icon>
8+
</mytoolbox>

0 commit comments

Comments
 (0)