Home > vbmeg > functions > common > utility > vb_users_manual_info_get.m

vb_users_manual_info_get

PURPOSE ^

Read vbmeg_users_manual.html in the doc directory

SYNOPSIS ^

function [caption_list, url_list] = vb_users_manual_info_get

DESCRIPTION ^

 Read vbmeg_users_manual.html in the doc directory
 and gives caption to retrieve url to access the html file.
 This function is used with vb_help_url_get.m
 [see]
    vb_users_manual_url.m
 
 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [caption_list, url_list] = vb_users_manual_info_get
0002 % Read vbmeg_users_manual.html in the doc directory
0003 % and gives caption to retrieve url to access the html file.
0004 % This function is used with vb_help_url_get.m
0005 % [see]
0006 %    vb_users_manual_url.m
0007 %
0008 % Copyright (C) 2011, ATR All Rights Reserved.
0009 % License : New BSD License(see VBMEG_LICENSE.txt)
0010 
0011 vbmeg_dir = vb_get_file_parts(which('vbmeg.m'));
0012 help_file = fullfile(vbmeg_dir, 'functions', 'doc', 'html', 'static', 'vbmeg_users_manual.html');
0013 
0014 caption_list = cell(0);
0015 url_list  = cell(0);
0016 
0017 %
0018 % --- Read help file
0019 %
0020 fid = fopen(help_file, 'rt');
0021 if fid == -1
0022     error('Can not open users manual.');
0023 end
0024 
0025 contents = cell(0);
0026 l = 1;
0027 while(feof(fid) ~= 1)
0028    line = fgetl(fid);
0029    if is_toc_line(line);
0030        contents{l} = line;
0031        l = l+1;
0032    end
0033 end
0034 fclose(fid);
0035 
0036 for k=1:length(contents)
0037     line = contents{k};
0038     [word, toc_id, add_line] = toc_get_info(line);
0039     if add_line
0040         line = [line, contents{k+1}];
0041         [word, toc_id, add_line] = toc_get_info(line);
0042         k = k+1;
0043     end
0044     caption_list{k} = word;
0045     url_list{k}     = [help_file, toc_id];
0046     %fprintf('word=%s toc_id=%s\n', word, toc_id);
0047 end
0048 caption_list = caption_list';
0049 url_list     = url_list';
0050 
0051 function [word, toc_id, add_line] = toc_get_info(line)
0052 word    = '';
0053 toc_id  = '';
0054 if is_toc_line(line) == false
0055     return;
0056 end
0057 add_line = false;
0058 %
0059 try
0060 pat = '.*href="(.*)"';
0061 [tmp, tokens] = regexp(line, pat, 'match', 'tokens');
0062 toc_id = tokens{1}{1};
0063 
0064 pat = '[!>]*>[!<](*)<';
0065 [tmp, tokens] = regexp(line, '.*href.*?>(.*?)<', 'match', 'tokens');
0066 word = tokens{1}{1};
0067 catch
0068    add_line = true;
0069 end
0070 
0071 function bool_value = is_toc_line(line)
0072 % find href in contents
0073 cond1 = strfind(line, 'href');
0074 cond2 = strfind(line, '#');
0075 cond3 = strfind(lower(line), 'toc');
0076 if ~isempty(cond1) && ~isempty(cond2) && ~isempty(cond3)
0077     bool_value = true;
0078 else
0079     bool_value = false;
0080 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005