function createhelpfiles(target) % function createhelpfiles('all|funcbycat|allfunc|allmanual'|mfile) % which files to create if nargin==0, target = 'all'; end dofuncbycat = fn_ismemberstr(target,{'all' 'funcbycat'}); domanual = strcmp(target,'allmanual'); % memorize current working directory swd = pwd; % Create autohelp folder if needed fn_mkdir(fn_cd('brick','helpsource','autohelp')) % All Functions by Category if dofuncbycat, createhelp('funcbycat'), end % m-files switch target case {'all' 'allfunc'} % mfiles = fn_ls(fn_cd('brick','*.m')); % functions described in Contents.m fcontent = fullfile(fn_cd('brick','Contents.m')); txt = fn_readtext(fcontent); contentfun = regexp(txt,'(?<=% [^-]*)\w*(?=.*-)','match'); contentfun = [contentfun{:}]; mfiles = strcat(contentfun,'.m'); case {'funcbycat' 'allmanual'} mfiles = {}; otherwise mfiles = {[target '.m']}; end for i=1:length(mfiles), createhelp(mfiles{i}), end % Manual m-files if domanual fn_cd('brick','helpsource','manualhelp') mfiles = fn_ls('help_*.m'); for i=1:length(mfiles), createhelp(mfiles{i}), end end % restore working directory cd(swd) %--- function createhelp(target) if strcmp(target,'funcbycat') ismanual = false; out = createhelp_funcbycat; targetm = 'helpfuncbycat.m'; elseif strfind(target,'help_') % manual help, publish only ismanual = true; disp(target) targetm = target; else ismanual = false; out = createhelp_mfile(target); if isempty(out), return, end targetm = ['help_' target]; end if ismanual fn_cd('brick','helpsource','manualhelp') else fn_cd('brick','helpsource','autohelp') fn_savetext(out,targetm) end publishopt = struct('outputDir',fn_cd('brick','html')); publish(targetm,publishopt); %--- function out = createhelp_funcbycat disp 'funcbycat' % read Contents.m file content = fn_readtext(fn_cd('brick','Contents.m')); % first lines out = { ... '%% Functions by Categories' ... ['% Brick Toolbox, ' content{2}(3:end)] ... '' ... }; % read [insection insubsection] = deal(false); for k=4:length(content) line = content{k}; % opening a section if ~insection % finished? if k==length(content), break, end head = fn_regexptokens(line,'% (.*)'); if ismember(head,{'RECOMMENDED' 'HIGHLIGHTS'}), break, end % open a new section (header + new table) out = [ out ... ['%% ' head] ... '% ' ... ]; insection = true; continue end % closing a subsection closesection = all(line(2:end)==' '); subhead = fn_regexptokens(line,'% - (.*)'); if insubsection && (~isempty(subhead) || closesection) out = [out ... '% ' ... ]; end % closing a section if closesection out = [ out ... '% ' ... {''} ... ]; [insection insubsection] = deal(false); continue end % opening a subsection if ~isempty(subhead) out = [out ... ['% ' subhead ''] ... '%
' fn_strcat(funs,', ') ' | ' ... '' desc ' | ' ... '