Changes in prextra/prhelp2html.m [29:15]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
prextra/prhelp2html.m
r29 r15 1 1 %PRHELP2HTML Construct HTML file from help part of PRTools routine 2 2 % 3 % S = PRHELP2HTML(COMMAND,RECREATE,HTMLDIR) 4 % S = PRHELP2HTML(TOOLBOX,RECREATE,HTMLDIR) 3 % S = PRHELP2HTML(COMMAND,RECREATE,SUBDIR) 5 4 % 6 5 % INPUT 7 6 % COMMAND String with PRTools command, default: all prtools m-files 8 % TOOLBOX Name of the toolbox to be handled, default PRTOOLS.9 % Toolbox should be in the bath in in this call the last10 % character should be a '/'.11 7 % RECREATE 0/1 flag indicating whether non-existing references 12 8 % in the SEE ALSO section should be created as well 13 % HTMLDIR String with desireddirectory in which the HTML9 % SUBDIR String with desired sub-directory in which the HTML 14 10 % file should be stored 15 11 % … … 60 56 61 57 62 % BEFORE YOU START TO DEBUG, READ THIS 63 % This routine was original intended to work on the prtools dir only. 64 % Later it was somewhat changed in order to handle files in prdatasets, 65 % prdatafiles and possibly distools and dd_tools as well. Only for 66 % prtools the subdir structure (with the @dataset, @datafile, @mapping 67 % sub dirs) is recognized, and only if the first parameter, COMMAND, is 68 % empty. 69 % 70 % The Contents files have a special layout. It is handled by prcontent2html 71 % in case of PRTools, but for other toolboxes it most likely doesn't work. 72 % 73 % The formatting rules of the PRTools help are strict. Don't try to relax 74 % them in the below code, but change the help-text if you are not satisfied 75 % with the result. Especially avoid ' ' (double spaces) where they are not 76 % needed as the conversion jumps into a table-mode as soon as they are 77 % encountered. 78 % 79 % Bob Duin, April 2011 80 81 function out = prhelp2html(name,recreate,htmldir) 82 83 if nargin < 3, htmldir = cd; end 84 if nargin < 2 | isempty(recreate), recreate = 0; end 85 if nargin < 1 | isempty(name) % default is prtools 86 dirs = {'ldc','dataset','datafile','mapping'}; 87 run_all_files(mfilename,dirs,htmldir); 88 s = prcontent2html('prtools',[],htmldir); 58 59 60 function out = prhelp2html(name,recreate,subdir) 61 62 if nargin < 3, subdir = []; end 63 if nargin < 2 || isempty(recreate), recreate = 0; end 64 if nargin < 1 65 run_all_files(mfilename); 66 s = prcontent2html('prtools'); 89 67 if nargout > 0 90 68 out = s; 91 69 end 92 70 return; 93 else94 if strcmp(name(end),'/') & exist(name(1:end-1),'dir') == 795 name = name(1:end-1);96 dirs = {fullfile(name,'Contents.m')};97 run_all_files(mfilename,dirs,htmldir);98 s = prcontent2html(name,[],htmldir); % does not work usually99 if nargout > 0100 out = s;101 end102 return103 end104 71 end 105 72 … … 111 78 end 112 79 %[pp,name] = fileparts(file); 113 if isempty( htmldir)114 [xx, htmldir] = fileparts(fileparts(file));115 end 116 %if isempty(strmatch(subdir,char('prtools','@dataset','@datafile','@mapping'),'exact'))117 % %disp([name ' Not PRTools'])118 %out = [];119 %return120 %end80 if isempty(subdir) 81 [xx,subdir] = fileparts(fileparts(file)); 82 end 83 if isempty(strmatch(subdir,char('prtools','@dataset','@datafile','@mapping'),'exact')) 84 % disp([name ' Not PRTools']) 85 out = []; 86 return 87 end 121 88 122 89 disp(file) … … 328 295 state = 'seealso'; 329 296 if ~single 330 s = [s commandrefs(posttok,recreate ,htmldir)];297 s = [s commandrefs(posttok,recreate)]; 331 298 end 332 299 else % undefined lines 333 300 if examplestate 334 301 if length(u) > 3 && strcmpi(u(1:4),'see ') 335 s = [s '</p>' commandrefs(u(5:end),recreate ,fileparts(htmldir)) '<p>'];302 s = [s '</p>' commandrefs(u(5:end),recreate) '<p>']; 336 303 else 337 304 s = [s strrep(code(strrep(r,' ','#$!'),0,3),'#$!',' ') '<br>']; … … 349 316 s = [s '<strong><font size="4">' findmakecode(u(3:end)) '</font></strong><br>']; 350 317 else 351 s = [s commandrefs(u,recreate ,htmldir)];318 s = [s commandrefs(u,recreate)]; 352 319 end 353 320 elseif tabstartspace && tabstate && (colpos1 > colpos0) ... … … 410 377 s = [s '</p>' content_manual '</body></html>']; 411 378 [qq,name] = fileparts(name); % allows for names like dataset/show 412 % if exist(fullfile(htmldir,name),'file') == 2 413 % htmlname = fullfile(htmldir,name); 414 % else 415 % %htmlname = [tok '.html']; 416 % file = which(name); 417 % pp = fileparts(file); 418 % [qq,subdir] = fileparts(pp); 419 % htmldir = fullfile(fileparts(htmldir),subdir); 420 % htmlname = fullfile(htmldir,name); 421 % end 422 423 if exist([htmldir],'file') ~= 7 424 mkdir(htmldir); 425 end 426 writf([fullfile(htmldir,name) '.html'],s); 379 if exist(['./' subdir],'file') ~= 7 380 mkdir(subdir); 381 end 382 writf([fullfile(subdir,name) '.html'],s); 427 383 disp([int2str(recreate) ' ' name ' html created']) 428 384 if nargout > 0 … … 500 456 end 501 457 502 function s = commandrefs(r,recreate,htmldir) 503 if nargin < 3, htmldir = cd; end 504 if nargin < 2 | isempty(recreate), recreate = 0; end 458 function s = commandrefs(r,recreate) 459 if nargin < 2, recreate = 0; end 505 460 s = []; 506 461 r_debug = r; … … 512 467 pp = fileparts(file); 513 468 [qq,subdir] = fileparts(pp); 514 % htmlname = fullfile(subdir,htmlname); 515 htmlfullname1 = fullfile(htmldir,htmlname); 516 htmlfullname2 = fullfile(fullfile(fileparts(htmldir),subdir),htmlname); 517 if exist(htmlfullname1,'file') == 2 % check whether command is in htmldir 518 s = [s '<a href="./' htmlname '">' tok '</a>, ']; 519 elseif exist(htmlfullname2,'file') == 2 % exists elsewhere? 520 s = [s '<a href="../' fullfile(subdir,htmlname) '">' tok '</a>, ']; 469 htmlname = fullfile(subdir,htmlname); 470 if exist(htmlname,'file') == 2 471 s = [s '<a href="../' htmlname '">' tok '</a>, ']; 521 472 elseif isempty(tok) || ~isempty(regexp(tok,'^ *', 'once' )) 522 473 ; … … 603 554 return 604 555 605 function run_all_files(command ,dirs,subdir)606 607 %dirs = {'ldc','dataset','datafile','mapping'};556 function run_all_files(command) 557 558 dirs = {'ldc','dataset','datafile','mapping'}; 608 559 for n=1:length(dirs) 609 560 prtools_dir = fileparts(which(dirs{n})); … … 613 564 [qq,name] = fileparts(ff{j}); 614 565 if n==1 615 feval(command,name ,[],fullfile(subdir,prtools_dirname)); % prtools main commands566 feval(command,name); % prtools main commands 616 567 else 617 feval(command,fullfile(prtools_dirname,name) ,[],fullfile(subdir,prtools_dirname)); % subdir commands568 feval(command,fullfile(prtools_dirname,name)); % subdir commands 618 569 end 619 570 end
Note: See TracChangeset
for help on using the changeset viewer.