Code covered by the BSD License  

Highlights from
publish2latex

image thumbnail

publish2latex

by

 

09 Apr 2013 (Updated )

Using full Latex markup in m-files to generate high quality documentation. Version 1.3

RequiredFilesClass
classdef RequiredFilesClass < handle
    %
    % Purpose : this object contains all the information required about the
    % files to be processed. It is also used as a container for the file
    % contents
    %
    % Author :  Matther Harker and Paul O'Leary
    % Date :    29. Jan 2013
    % Version : 1.0
    %
    % (c) 2013 Matther Harker and Paul O'Leary
    % url: www.harkeroleary.org
    % email: office@harkeroleary.org
    %
    % History:
    %   Date:           Comment:
    %
    
    %
    properties (GetAccess = public, SetAccess = public );
        latexDefsName
        latexDefsPath
        latexDefsFile
        latexDefsSet = false;
        %
        mName
        mPath
        mSet = false;
        mFile
        %
        publishName
        %
        resultLatexName
        resultLatexPath
        resultSet = false;
        resultFile
        %
        TOCRequired
    end
    %
    methods
        function obj = RequiredFilesClass()
            obj.TOCRequired = true;
            obj.setMFile();
            if obj.mName == 0
                return;
            end;
            %
            [~,fName,~] = fileparts(obj.mName);
            %
            % Use the Library directory as the source of the macro
            % definitions
            %
            source = mfilename('fullpath');
            [sDir, ~, ~] = fileparts( source );
            
            obj.latexDefsName = ['LatexDefinitions.tex'];
            obj.latexDefsPath = [sDir,'\'];
            obj.latexDefsSet = true;
            %
            obj.publishName = fName;
            %
            obj.resultLatexName = [fName, '.tex'];
            obj.resultLatexPath = obj.mPath;
            obj.resultSet = true;
            %
            obj.loadFiles;
        end
        %
        function setMFile( obj )
            [obj.mName, obj.mPath] = uigetfile( '*.m', 'select M file to publish');
            if obj.mName == 0
                error('File open canceled');
            end;
            obj.mSet = true;
        end
        %
        function loadFiles( obj )
            if obj.latexDefsSet ~= 0
                obj.latexDefsPath;
                obj.latexDefsFile = readInTextFile( obj.latexDefsPath, obj.latexDefsName );
            end
            %
            if obj.mName ~= 0
                obj.mFile = readInTextFile( obj.mPath, obj.mName );
            end
        end;
        %
    end;
    methods (Static)
        function saveObj( obj )
            save( 'filesData', 'obj');
        end;
        %
        function loadObj
            load( 'filesData');
        end;
        
    end
end

Contact us