Skip to content

Commit 1ec263e

Browse files
committed
major rewrite
1 parent f5afdeb commit 1ec263e

13 files changed

+275
-932
lines changed

@DocFile/DocFile.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
function file = DocFile(files,varargin)
22
% constructor
33
%
4-
%% Syntax
4+
% Syntax
55
% files = DocFile(path) - recusively adds all files in sub--dirs
66
% files = DocFile({fname,fname,...}) - adds a given cell--array of full--fill names
77
% files = DocFile('function') - add a single function which is on search path
88
%
9-
%% See also
9+
% See also
1010
% getFiles
1111
%
12-
%% Example
12+
% Example
1313
% doc = DocFile(fullfile(docHelpPath,'help','docGuide'))
1414
%
1515

1616
if nargin < 1
1717
error('I need at least one file or path!')
1818
end
1919

20-
if ~iscell(files) && isdir(files)
20+
if ~iscell(files) && isfolder(files)
2121
files = getFiles(files,'*.m',true);
2222
end
2323

@DocFile/deadlink.m

+4-82
Original file line numberDiff line numberDiff line change
@@ -20,90 +20,12 @@ function deadlink(docFiles,outputDir)
2020
found = strfind(source,[links(k).href '.html']);
2121

2222
if ~exist(fullfile(html_path,[links(k).href '.html']))
23-
for l=1:numel(found)
24-
check(end+1).reference = links(k).href;
25-
check(end).inFile = file.sourceFile;
26-
check(end).inFileShort = file.sourceInfo.name;
27-
check(end).inLine = sum(lineBreak<found(l))+1;
23+
for l=1:numel(found)
24+
disp(['<a href="matlab:opentoline(''' ...
25+
file.sourceFile ''',' int2str(sum(lineBreak<found(l))+1) ')">' ...
26+
file.sourceInfo.name ' -> ' links(k).href '</a>'])
2827
end
2928
end
3029
end
31-
32-
3330
end
34-
% page
35-
% html_file = fullfile(html_path, page{:});
36-
% link = regexp(file2cell(html_file),'(href=")(?<href>\S*?)(.html")','names');
37-
% for line = find(~cellfun('isempty',link))
38-
% for href = {link{line}.href}
39-
% if ~any(~cellfun('isempty',strfind(html_page, href{1})))
40-
% p = regexprep(page{:},'.html','');
41-
% if ~exist(p,'file')
42-
% ug = get_ug_filebytopic(ug_files,'test');
43-
% if ~isempty(ug)
44-
% p = ug;
45-
% else
46-
% p = regexprep(p,'_','/');
47-
% end
48-
% end
49-
%
50-
% if isempty(href{1})
51-
% s = ['EMPTY LINK -> <a href="' html_file '">' page{:} ...
52-
% '</a> -> (<a href="matlab:edit ' p '">' p '.m</a>)' ];
53-
% else
54-
% s = ['<a href="' html_file '">' page{:} '</a> -> (<a href="matlab:edit ' p '">' p '.m</a>)' ...
55-
% ' -> link: ' href{1} ];
56-
% end
57-
% disp(s)
58-
% end
59-
% end
60-
% end
61-
end
62-
% check
63-
64-
65-
wzrd = figure('MenuBar','none',...
66-
'Resize','off',...
67-
'Name','DocFiles',... 'Resize','off',...
68-
'NumberTitle','off',...
69-
'tag','docFileViewer',...
70-
'Color',get(0,'defaultUicontrolBackgroundColor'),...
71-
'Position',[100 100 200 500]);
72-
73-
wrzd_list = uicontrol('parent',wzrd,...
74-
'style','listbox',...
75-
'position',[0 0 200 500],...
76-
'backgroundcolor','white',...
77-
'fontsize',10,...
78-
'max',2,...
79-
'tag','docFileList');
80-
81-
82-
for k=1:numel(check)
83-
list{k} = ['<HTML><FONT color="black">' check(k).inFileShort '</FONT> <FONT color="blue">' check(k).reference '</FONT></HTML>'];
8431
end
85-
86-
set(wrzd_list,'String',list)
87-
88-
89-
set(wrzd_list,'Callback',{@fileChanged,check})
90-
91-
92-
function fileChanged(src,evt,check)
93-
94-
pos = get(src,'value');
95-
96-
opentoline(check(pos).inFile,check(pos).inLine);
97-
98-
figure(gcbf);
99-
100-
101-
102-
103-
104-
105-
106-
107-
108-
109-

@DocFile/fgetl.m

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function str = fgetl(file,varargin)
2+
3+
file = file.sourceFile;
4+
5+
fid = fopen(file,'r');
6+
if fid < 0
7+
str = '';
8+
else
9+
str = fgetl(fid,varargin{:});
10+
fclose(fid);
11+
12+
str = regexprep(str,'\r','');
13+
str = strtrim(regexprep(str,'%%',''));
14+
end

@DocFile/getFormatedDoc.m

+21-21
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@
1919
end
2020
% helpStr = regexprep(helpStr,'_','\\\_');
2121

22-
if hasTocFile(file)
23-
24-
tocFiles = getFilesByToc(file,docFiles);
25-
26-
if numel(tocFiles)>0
27-
tocContent = getTableOfContent(tocFiles,'toc');
28-
29-
htmlTable = regexprep(['%% ' char([10 10]) '<html>' char(10) tocContent char(10) '</html>' char(10)],'\n','\n% ');
30-
31-
ipos = regexp(helpStr,'\n%%|\n$','start');
32-
33-
if ~isempty(ipos)
34-
helpStr = [helpStr(1:ipos) ...
35-
htmlTable ...
36-
helpStr(ipos:end)];
37-
else
38-
helpStr = [helpStr char(10) htmlTable];
39-
end
40-
41-
end
42-
end
22+
% if hasTocFile(file)
23+
%
24+
% tocFiles = getFilesByToc(file,docFiles);
25+
%
26+
% if numel(tocFiles)>0
27+
% tocContent = getTableOfContent(tocFiles,'toc');
28+
%
29+
% htmlTable = regexprep(['%% ' char([10 10]) '<html>' newline tocContent newline '</html>' newline],'\n','\n% ');
30+
%
31+
% ipos = regexp(helpStr,'\n%%|\n$','start');
32+
%
33+
% if ~isempty(ipos)
34+
% helpStr = [helpStr(1:ipos) ...
35+
% htmlTable ...
36+
% helpStr(ipos:end)];
37+
% else
38+
% helpStr = [helpStr char(10) htmlTable];
39+
% end
40+
%
41+
% end
42+
% end
4343

4444

4545

0 commit comments

Comments
 (0)