public static List <TemplateManifestItem> Transform(TemplateProcessor processor, List <ManifestItem> manifest, DocumentBuildContext context, ApplyTemplateSettings settings)
{
if (settings.Options == ApplyTemplateOptions.ExportRawModel || processor == null)
{
ExportRawModel(manifest, settings);
return(null);
}
using (new LoggerPhaseScope("Apply Templates"))
{
Logger.LogInfo($"Applying templates to {manifest.Count} model(s)...");
processor.ProcessDependencies(settings.OutputFolder);
if (processor.IsEmpty)
{
Logger.LogWarning("No template is found.");
ExportRawModel(manifest, settings);
return(null);
}
Logger.LogVerbose("Start applying template...");
var outputDirectory = context.BuildOutputFolder;
var templateManifest = processor.Transform(manifest, context, settings);
if (!settings.Options.HasFlag(ApplyTemplateOptions.TransformDocument))
{
Logger.LogInfo("Dryrun, no template will be applied to the documents.");
}
if (templateManifest.Count > 0)
{
// Save manifest from template
// TODO: Keep .manifest for backward-compatability, will remove next sprint
var manifestPath = Path.Combine(outputDirectory ?? string.Empty, Constants.ObsoleteManifestFileName);
JsonUtility.Serialize(manifestPath, templateManifest);
// Logger.LogInfo($"Manifest file saved to {manifestPath}. NOTE: This file is out-of-date and will be removed in version 1.8, if you rely on this file, please change to use {Constants.ManifestFileName} instead.");
var manifestJsonPath = Path.Combine(outputDirectory ?? string.Empty, Constants.ManifestFileName);
var toc = context.GetTocInfo();
var manifestObject = GenerateManifest(context, templateManifest);
JsonUtility.Serialize(manifestJsonPath, manifestObject);
Logger.LogInfo($"Manifest file saved to {manifestJsonPath}.");
}
return(templateManifest);
}
}