classdef DependencyFormatter
    %methods for use from Java

%   Copyright 2014-2020 The MathWorks, Inc.
    
    methods(Static)
        % return flattened lists of all dependencies for a toolbox project
        % formatError is true when there was an
        % invalid formatting somewhere within demos.xml. This may
        % cause some examples to have been read incorrectly or not at all.
        function [categorizedExamples,  apps, docFile, demosFile, demosFileHadError, demosFileWasAutoGenerated] = toolboxPackagingDependenciesFlattened(toolboxRoot, demosHeader)
            [toolboxDependencies] =  matlab.depfun.internal.format.ToolboxPackaging.findDependencies(toolboxRoot, demosHeader);
            categorizedExamples = toolboxDependencies.CategorizedExamples;
            demosFileHadError = toolboxDependencies.DemosFileHadError;
            demosFileWasAutoGenerated = toolboxDependencies.DemosWasAutoGenerated;
            apps = toolboxDependencies.AppsList;
            docFile =  toolboxDependencies.DocFile;
            demosFile = toolboxDependencies.DemosFile;
        end
        
        %return flattened lists of all dependencies for an apptool project
        function [depfileslist, productName, productVersion, productNumber, platforms]= apptoolDependenciesFlattened(varargin)
            [depfileslist, products, platforms] = matlab.depfun.internal.format.AppsPackaging.findDependencies(varargin);
            productName = cellfun(@(x) char(x), {products(:).Name}, 'UniformOutput',false);
            productVersion = cellfun(@(x) char(x), {products(:).Version}, 'UniformOutput',false);
            productNumber = cellfun(@(x) mat2str(x), {products(:).Number}, 'UniformOutput',false);
        end
        
        %find all dependencies and support packages for a deploytool project
        function [depfileslist, depsupportpackagelist]= deploytoolDependencies(varargin)
            [depfileslist, depsupportpackagelist]= matlab.depfun.internal.format.DeploymentPackaging.findDependencies(varargin);
        end
        
        %returns all the dependencies that are not within the toolbox folder
        function [externalDependencies, productName, productVersion, productNumber, supportPackages] = findExternalDependenciesTopOnly(toolboxRoot,UseTopOnly,varargin)
            [externalDependencies, productName, productVersion, productNumber, supportPackages]= matlab.depfun.internal.format.ToolboxPackaging.findExternalDependenciesTopOnly(toolboxRoot,UseTopOnly,varargin{:});
        end
        
    end
end
