function printTags(tagStruct, mfileList, tagNameList)
% print information gathered by getTags
%
% THIS IS NO USER FUNCITON

% MDT: MATLAB developement toolbox - for the everyday programmer
%   Copyright (C) 2013 Alexander Reinhold
%
% This program is free software: you can redistribute it and/or modify it 
%   under the terms of the GNU Lesser General Public License as published 
%   by the Free Software Foundation, either version 3 of the License, or 
%   (at your option) any later version.
%
% This program is distributed in the hope that it will be useful, but 
%   WITHOUT ANY WARRANTY; without even the implied warranty of 
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
%   Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public License 
%   along with this program.  If not, see <http://www.gnu.org/licenses/>.

if isempty(tagStruct.mfile)
    return
end

for iSource = unique(tagStruct.mfile)
    % indicate new source
    disp(' ');
    disp(['<a href = "matlab: open(''' mfileList{iSource} ''')">' mfileList{iSource} '</a>']);  
        
    indexVector = find(tagStruct.mfile == iSource);
    % print out comments
    for iTag = indexVector
        if tagStruct.line(iTag) == tagStruct.lineEnd(iTag)
            lineString = ['(line ' num2str(tagStruct.line(iTag)) ')'];
        else
            lineString = ['(lines ' num2str(tagStruct.line(iTag)) ' - ' ...
                                     num2str(tagStruct.lineEnd(iTag)) ')'];
        end
        disp(['<a href="matlab: opentoline(' ...
               mfileList{iSource} ', ' ...
               num2str(tagStruct.line(iTag)) ')">'...
               upper(tagNameList{tagStruct.type(iTag)}{1}) ...
               ' ' lineString '</a>' ...
              ]);
         disp(tagStruct.comment{iTag});
    end
end
