Microsoft.DocAsCode.Build.Engine.TemplateProcessor.Process C# (CSharp) Method

Process() private method

private Process ( List manifest, DocumentBuildContext context, ApplyTemplateSettings settings, object>.IDictionary globals = null ) : List
manifest List
context DocumentBuildContext
settings ApplyTemplateSettings
globals object>.IDictionary
return List
        internal List<ManifestItem> Process(List<InternalManifestItem> manifest, DocumentBuildContext context, ApplyTemplateSettings settings, IDictionary<string, object> globals = null)
        {
            using (new LoggerPhaseScope("Apply Templates", true))
            {
                if (globals == null)
                {
                    globals = Tokens.ToDictionary(pair => pair.Key, pair => (object)pair.Value);
                }

                var documentTypes = manifest.Select(s => s.DocumentType).Distinct();
                var notSupportedDocumentTypes = documentTypes.Where(s => s != "Resource" && _templateCollection[s] == null);
                if (notSupportedDocumentTypes.Any())
                {
                    Logger.LogWarning($"There is no template processing document type(s): {TypeForwardedToStringExtension.ToDelimitedString(notSupportedDocumentTypes)}");
                }
                Logger.LogInfo($"Applying templates to {manifest.Count} model(s)...");

                if (settings.Options.HasFlag(ApplyTemplateOptions.TransformDocument))
                {
                    var templatesInUse = documentTypes.Select(s => _templateCollection[s]).Where(s => s != null).ToList();
                    ProcessDependencies(settings.OutputFolder, templatesInUse);
                }
                else
                {
                    Logger.LogInfo("Dryrun, no template will be applied to the documents.");
                }

                var templateManifest = ProcessCore(manifest, context, settings, globals);
                return templateManifest;
            }
        }

Usage Example

Example #1
0
        private List <ManifestItem> ProcessTemplate()
        {
            // Register global variables after href are all updated
            IDictionary <string, object> globalVariables;

            using (new LoggerPhaseScope("FeedGlobalVariables", LogLevel.Verbose))
            {
                globalVariables = FeedGlobalVariables();
            }

            // processor to add global variable to the model
            return(_templateProcessor.Process(_manifestWithContext.Select(s => s.Item).ToList(), _context, _context.ApplyTemplateSettings, globalVariables));
        }
All Usage Examples Of Microsoft.DocAsCode.Build.Engine.TemplateProcessor::Process