|
| 1 | +function deadlink(docFiles,outputDir) |
| 2 | + |
| 3 | +% html_path = fullfile(mtex_path,'help','html'); |
| 4 | +html_path = outputDir; |
| 5 | +files = dir(fullfile(html_path,'*.html')); |
| 6 | +% html_page = {files.name}; |
| 7 | + |
| 8 | +% ug_files = get_ug_files(fullfile(mtex_path,'help')); |
| 9 | +check = struct; |
| 10 | +for file=docFiles |
| 11 | + htmlFile = fullfile(outputDir,[file.sourceInfo.docName '.html']); |
| 12 | + |
| 13 | + if exist(htmlFile) |
| 14 | + html = read(htmlFile); |
| 15 | + source = read(file); |
| 16 | + links = regexp(html,'(href=")(?<href>\S*?)(.html")','names'); |
| 17 | + lineBreak = regexp(source,'\n'); |
| 18 | + |
| 19 | + for k=1:numel(links) |
| 20 | + found = strfind(source,[links(k).href '.html']); |
| 21 | + |
| 22 | + 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; |
| 28 | + end |
| 29 | + end |
| 30 | + end |
| 31 | + |
| 32 | + |
| 33 | + 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>']; |
| 84 | +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 | + |
0 commit comments