private IEnumerable <ManifestItemWithContext> BuildCore(InnerBuildContext buildContext, DocumentBuildContext context) { var processor = buildContext.Processor; var hostService = buildContext.HostService; Logger.LogVerbose($"Plug-in {processor.Name}: Loading document..."); hostService.SourceFiles = context.AllSourceFiles; foreach (var m in hostService.Models) { if (m.LocalPathFromRepoRoot == null) { m.LocalPathFromRepoRoot = Path.Combine(m.BaseDir, m.File).ToDisplayPath(); } } var steps = string.Join("=>", processor.BuildSteps.OrderBy(step => step.BuildOrder).Select(s => s.Name)); Logger.LogInfo($"Building {hostService.Models.Count} file(s) in {processor.Name}({steps})..."); Logger.LogVerbose($"Plug-in {processor.Name}: Preprocessing..."); Prebuild(processor, hostService); Logger.LogVerbose($"Plug-in {processor.Name}: Building..."); BuildArticle(processor, hostService); Logger.LogVerbose($"Plug-in {processor.Name}: Postprocessing..."); Postbuild(processor, hostService); Logger.LogVerbose($"Plug-in {processor.Name}: Generating manifest..."); return(ExportManifest(buildContext, context)); }
private IEnumerable <ManifestItemWithContext> BuildCore(InnerBuildContext buildContext, DocumentBuildContext context) { var processor = buildContext.Processor; buildContext.HostService.SourceFiles = context.AllSourceFiles; BuildCore(processor, buildContext.HostService, context.MaxParallelism); return(ExportManifest(buildContext, context)); }
private IEnumerable <ManifestItemWithContext> ExportManifest(InnerBuildContext buildContext, DocumentBuildContext context) { var hostService = buildContext.HostService; var processor = buildContext.Processor; var templateProcessor = buildContext.TemplateProcessor; var manifestItems = new List <ManifestItemWithContext>(); hostService.Models.RunAll(m => { if (m.Type != DocumentType.Overwrite) { using (new LoggerFileScope(m.LocalPathFromRepoRoot)) { Logger.LogVerbose($"Plug-in {processor.Name}: Saving..."); m.BaseDir = context.BuildOutputFolder; if (m.PathRewriter != null) { m.File = m.PathRewriter(m.File); } var result = processor.Save(m); if (result != null) { string extension = string.Empty; if (templateProcessor != null) { if (templateProcessor.TryGetFileExtension(result.DocumentType, out extension)) { // For backward-compatibility, will remove ModelFile in v1.9 if (string.IsNullOrEmpty(result.FileWithoutExtension)) { result.FileWithoutExtension = Path.ChangeExtension(result.ModelFile, null); } m.File = result.FileWithoutExtension + extension; } } var item = HandleSaveResult(context, hostService, m, result); item.Extension = extension; manifestItems.Add(new ManifestItemWithContext(item, m, processor, templateProcessor?.GetTemplateBundle(result.DocumentType))); } } } }); return(manifestItems); }
private IEnumerable <ManifestItemWithContext> ExportManifest(InnerBuildContext buildContext, DocumentBuildContext context) { var hostService = buildContext.HostService; var processor = buildContext.Processor; var templateProcessor = buildContext.TemplateProcessor; var manifestItems = new List <ManifestItemWithContext>(); hostService.Models.RunAll(m => { if (m.Type != DocumentType.Override) { using (new LoggerFileScope(m.LocalPathFromRepoRoot)) { Logger.LogVerbose($"Plug-in {processor.Name}: Saving..."); m.BaseDir = context.BuildOutputFolder; if (m.PathRewriter != null) { m.File = m.PathRewriter(m.File); } var result = processor.Save(m); if (result != null) { if (templateProcessor != null) { m.File = templateProcessor.UpdateFileExtension(m.File, result.DocumentType); result.ModelFile = templateProcessor.UpdateFileExtension(result.ModelFile, result.DocumentType); } var item = HandleSaveResult(context, hostService, m, result); manifestItems.Add(new ManifestItemWithContext(item, m, processor)); } } } }); return(manifestItems); }