private ExtractMetadataInputModel ConvertToInputModel(MetadataJsonItemConfig configModel) { var projects = configModel.Source; var references = configModel.References; var outputFolder = configModel.Destination ?? Constants.DefaultMetadataOutputFolderName; var inputModel = new ExtractMetadataInputModel { PreserveRawInlineComments = configModel?.Raw ?? false, ForceRebuild = configModel?.Force ?? false, ShouldSkipMarkup = configModel?.ShouldSkipMarkup ?? false, FilterConfigFile = configModel?.FilterConfigFile, GlobalNamespaceId = configModel?.GlobalNamespaceId, UseCompatibilityFileName = configModel?.UseCompatibilityFileName ?? false, MSBuildProperties = configModel?.MSBuildProperties, OutputFolder = outputFolder, CodeSourceBasePath = configModel?.CodeSourceBasePath, DisableDefaultFilter = configModel?.DisableDefaultFilter ?? false, }; var expandedFiles = GlobUtility.ExpandFileMapping(EnvironmentContext.BaseDirectory, projects); var expandedReferences = GlobUtility.ExpandFileMapping(EnvironmentContext.BaseDirectory, references); inputModel.Files = expandedFiles.Items.SelectMany(s => s.Files).ToList(); inputModel.References = expandedReferences?.Items.SelectMany(s => s.Files).ToList(); return(inputModel); }
private ExtractMetadataInputModel ConvertToInputModel(MetadataJsonItemConfig configModel) { var projects = configModel.Source; // If Root Output folder is specified from command line, use it instead of the base directory var outputFolder = Path.Combine(Config.OutputFolder ?? Config.BaseDirectory ?? string.Empty, configModel.Destination ?? DocAsCode.Constants.DefaultMetadataOutputFolderName); var inputModel = new ExtractMetadataInputModel { PreserveRawInlineComments = configModel?.Raw ?? false, ForceRebuild = configModel?.Force ?? false, ShouldSkipMarkup = configModel?.ShouldSkipMarkup ?? false, ApiFolderName = string.Empty, FilterConfigFile = configModel?.FilterConfigFile, GlobalNamespaceId = configModel?.GlobalNamespaceId, UseCompatibilityFileName = configModel?.UseCompatibilityFileName ?? false, MSBuildProperties = configModel?.MSBuildProperties }; var expandedFileMapping = GlobUtility.ExpandFileMapping(Config.BaseDirectory, projects); inputModel.Items = new Dictionary <string, List <string> > { [outputFolder] = expandedFileMapping.Items.SelectMany(s => s.Files).ToList(), }; return(inputModel); }
private static MetadataMergeParameters ConfigToParameter(MergeJsonConfig config, string baseDirectory, string outputDirectory) => new MetadataMergeParameters { OutputBaseDir = outputDirectory, Metadata = config.GlobalMetadata?.ToImmutableDictionary() ?? ImmutableDictionary <string, object> .Empty, FileMetadata = ConvertToFileMetadataItem(baseDirectory, config.FileMetadata), Files = GetFileCollectionFromFileMapping( baseDirectory, DocumentType.Article, GlobUtility.ExpandFileMapping(baseDirectory, config.Content)), };
private static DocumentBuildParameters ConfigToParameter(BuildJsonConfig config, TemplateManager templateManager, string baseDirectory, string outputDirectory) { var parameters = new DocumentBuildParameters(); parameters.OutputBaseDir = outputDirectory; if (config.GlobalMetadata != null) { parameters.Metadata = config.GlobalMetadata.ToImmutableDictionary(); } if (config.FileMetadata != null) { parameters.FileMetadata = ConvertToFileMetadataItem(baseDirectory, config.FileMetadata); } parameters.ExternalReferencePackages = GetFilesFromFileMapping( GlobUtility.ExpandFileMapping(baseDirectory, config.ExternalReference)) .ToImmutableArray(); parameters.Files = GetFileCollectionFromFileMapping( baseDirectory, GlobUtility.ExpandFileMapping(baseDirectory, config.Content), GlobUtility.ExpandFileMapping(baseDirectory, config.Overwrite), GlobUtility.ExpandFileMapping(baseDirectory, config.Resource)); var applyTemplateSettings = new ApplyTemplateSettings(baseDirectory, outputDirectory) { TransformDocument = config.DryRun != true, }; applyTemplateSettings.RawModelExportSettings.Export = config.ExportRawModel == true; if (!string.IsNullOrEmpty(config.RawModelOutputFolder)) { applyTemplateSettings.RawModelExportSettings.OutputFolder = Path.Combine(baseDirectory, config.RawModelOutputFolder); } applyTemplateSettings.ViewModelExportSettings.Export = config.ExportViewModel == true; if (!string.IsNullOrEmpty(config.ViewModelOutputFolder)) { applyTemplateSettings.ViewModelExportSettings.OutputFolder = Path.Combine(baseDirectory, config.ViewModelOutputFolder); } parameters.ApplyTemplateSettings = applyTemplateSettings; parameters.TemplateManager = templateManager; if (config.MaxParallelism == null || config.MaxParallelism.Value <= 0) { parameters.MaxParallelism = Environment.ProcessorCount; } else { parameters.MaxParallelism = config.MaxParallelism.Value; } return(parameters); }
private Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataInputModel ConvertToInputModel(MetadataJsonItemConfig configModel) { var projects = configModel.Source; // If Root Output folder is specified from command line, use it instead of the base directory var outputFolder = Path.Combine(Config.OutputFolder ?? Config.BaseDirectory ?? string.Empty, configModel.Destination ?? DocAsCode.Constants.DefaultMetadataOutputFolderName); var inputModel = new Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataInputModel { PreserveRawInlineComments = configModel?.Raw ?? false, ForceRebuild = configModel?.Force ?? false, ApiFolderName = string.Empty, FilterConfigFile = configModel?.FilterConfigFile, }; var expandedFileMapping = GlobUtility.ExpandFileMapping(Config.BaseDirectory, projects); inputModel.Items = new Dictionary<string, List<string>> { [outputFolder] = expandedFileMapping.Items.SelectMany(s => s.Files).ToList(), }; return inputModel; }
private static DocumentBuildParameters ConfigToParameter(BuildJsonConfig config, string baseDirectory, string outputDirectory) { var parameters = new DocumentBuildParameters(); parameters.OutputBaseDir = outputDirectory; if (config.GlobalMetadata != null) { parameters.Metadata = config.GlobalMetadata.ToImmutableDictionary(); } if (config.FileMetadata != null) { parameters.FileMetadata = ConvertToFileMetadataItem(baseDirectory, config.FileMetadata); } parameters.ExternalReferencePackages = GetFilesFromFileMapping(GlobUtility.ExpandFileMapping(baseDirectory, config.ExternalReference)).ToImmutableArray(); parameters.Files = GetFileCollectionFromFileMapping( baseDirectory, Tuple.Create(DocumentType.Article, GlobUtility.ExpandFileMapping(baseDirectory, config.Content)), Tuple.Create(DocumentType.Override, GlobUtility.ExpandFileMapping(baseDirectory, config.Overwrite)), Tuple.Create(DocumentType.Resource, GlobUtility.ExpandFileMapping(baseDirectory, config.Resource))); parameters.ExportViewModel = config.ExportViewModel == true; parameters.ExportRawModel = config.ExportRawModel == true; return(parameters); }
private static IEnumerable <DocumentBuildParameters> ConfigToParameter(BuildJsonConfig config, TemplateManager templateManager, ChangeList changeList, string baseDirectory, string outputDirectory, string templateDir) { var parameters = new DocumentBuildParameters { OutputBaseDir = outputDirectory, ForceRebuild = config.Force ?? false, ForcePostProcess = config.ForcePostProcess ?? false, SitemapOptions = config.SitemapOptions, FALName = config.FALName, DisableGitFeatures = config.DisableGitFeatures, SchemaLicense = config.SchemaLicense, TagParameters = config.TagParameters }; if (config.GlobalMetadata != null) { parameters.Metadata = config.GlobalMetadata.ToImmutableDictionary(); } if (config.FileMetadata != null) { parameters.FileMetadata = ConvertToFileMetadataItem(baseDirectory, config.FileMetadata); } if (config.PostProcessors != null) { parameters.PostProcessors = config.PostProcessors.ToImmutableArray(); } if (config.XRefMaps != null) { parameters.XRefMaps = config.XRefMaps.ToImmutableArray(); } if (config.XRefServiceUrls != null) { parameters.XRefServiceUrls = config.XRefServiceUrls.ToImmutableArray(); } if (!config.NoLangKeyword) { parameters.XRefMaps = parameters.XRefMaps.Add("embedded:docfx/langwordMapping.yml"); } string outputFolderForDebugFiles = null; if (!string.IsNullOrEmpty(config.OutputFolderForDebugFiles)) { outputFolderForDebugFiles = Path.Combine(baseDirectory, config.OutputFolderForDebugFiles); } var applyTemplateSettings = new ApplyTemplateSettings(baseDirectory, outputDirectory, outputFolderForDebugFiles, config.EnableDebugMode ?? false) { TransformDocument = config.DryRun != true, }; applyTemplateSettings.RawModelExportSettings.Export = config.ExportRawModel == true; if (!string.IsNullOrEmpty(config.RawModelOutputFolder)) { applyTemplateSettings.RawModelExportSettings.OutputFolder = Path.Combine(baseDirectory, config.RawModelOutputFolder); } applyTemplateSettings.ViewModelExportSettings.Export = config.ExportViewModel == true; if (!string.IsNullOrEmpty(config.ViewModelOutputFolder)) { applyTemplateSettings.ViewModelExportSettings.OutputFolder = Path.Combine(baseDirectory, config.ViewModelOutputFolder); } parameters.ApplyTemplateSettings = applyTemplateSettings; parameters.TemplateManager = templateManager; if (config.MaxParallelism == null || config.MaxParallelism.Value <= 0) { parameters.MaxParallelism = Environment.ProcessorCount; } else { parameters.MaxParallelism = config.MaxParallelism.Value; ThreadPool.GetMinThreads(out int wt, out int cpt); if (wt < parameters.MaxParallelism) { ThreadPool.SetMinThreads(parameters.MaxParallelism, cpt); } } parameters.MaxHttpParallelism = Math.Max(64, parameters.MaxParallelism * 2); ServicePointManager.DefaultConnectionLimit = parameters.MaxHttpParallelism; if (config.MarkdownEngineName != null) { parameters.MarkdownEngineName = config.MarkdownEngineName; } if (config.MarkdownEngineProperties != null) { parameters.MarkdownEngineParameters = config.MarkdownEngineProperties.ToImmutableDictionary(); } if (config.CustomLinkResolver != null) { parameters.CustomLinkResolver = config.CustomLinkResolver; } parameters.TemplateDir = templateDir; var fileMappingParametersDictionary = GroupFileMappings(config.Content, config.Overwrite, config.Resource); if (config.LruSize == null) { parameters.LruSize = Environment.Is64BitProcess ? 0x2000 : 0xC00; } else { parameters.LruSize = Math.Max(0, config.LruSize.Value); } if (config.KeepFileLink) { parameters.KeepFileLink = true; } if (config.Pairing != null) { parameters.OverwriteFragmentsRedirectionRules = config.Pairing.Select(i => new FolderRedirectionRule(i.ContentFolder, i.OverwriteFragmentsFolder)).ToImmutableArray(); } foreach (var pair in fileMappingParametersDictionary) { var p = parameters.Clone(); if (!string.IsNullOrEmpty(pair.Key)) { p.GroupInfo = new GroupInfo() { Name = pair.Key, }; if (config.Groups != null && config.Groups.TryGetValue(pair.Key, out GroupConfig gi)) { p.GroupInfo.Destination = gi.Destination; p.GroupInfo.Metadata = gi.Metadata; if (!string.IsNullOrEmpty(gi.Destination)) { p.VersionDir = gi.Destination; } } } p.Files = GetFileCollectionFromFileMapping( baseDirectory, GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Content)), GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Overwrite)), GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Resource))); p.VersionName = pair.Key; p.Changes = GetIntersectChanges(p.Files, changeList); p.RootTocPath = pair.Value.RootTocPath; yield return(p); } }
private static IEnumerable <DocumentBuildParameters> ConfigToParameter(BuildJsonConfig config, TemplateManager templateManager, ChangeList changeList, string baseDirectory, string outputDirectory, string templateDir) { var parameters = new DocumentBuildParameters { OutputBaseDir = outputDirectory, ForceRebuild = config.Force ?? false, ForcePostProcess = config.ForcePostProcess ?? false }; if (config.GlobalMetadata != null) { parameters.Metadata = config.GlobalMetadata.ToImmutableDictionary(); } if (config.FileMetadata != null) { parameters.FileMetadata = ConvertToFileMetadataItem(baseDirectory, config.FileMetadata); } if (config.PostProcessors != null) { parameters.PostProcessors = config.PostProcessors.ToImmutableArray(); } parameters.ExternalReferencePackages = GetFilesFromFileMapping( GlobUtility.ExpandFileMapping(baseDirectory, config.ExternalReference)) .ToImmutableArray(); if (config.XRefMaps != null) { parameters.XRefMaps = config.XRefMaps.ToImmutableArray(); } if (!config.NoLangKeyword) { parameters.XRefMaps = parameters.XRefMaps.Add("embedded:docfx/langwordMapping.yml"); } string outputFolderForDebugFiles = null; if (!string.IsNullOrEmpty(config.OutputFolderForDebugFiles)) { outputFolderForDebugFiles = Path.Combine(baseDirectory, config.OutputFolderForDebugFiles); } var applyTemplateSettings = new ApplyTemplateSettings(baseDirectory, outputDirectory, outputFolderForDebugFiles, config.EnableDebugMode ?? false) { TransformDocument = config.DryRun != true, }; applyTemplateSettings.RawModelExportSettings.Export = config.ExportRawModel == true; if (!string.IsNullOrEmpty(config.RawModelOutputFolder)) { applyTemplateSettings.RawModelExportSettings.OutputFolder = Path.Combine(baseDirectory, config.RawModelOutputFolder); } applyTemplateSettings.ViewModelExportSettings.Export = config.ExportViewModel == true; if (!string.IsNullOrEmpty(config.ViewModelOutputFolder)) { applyTemplateSettings.ViewModelExportSettings.OutputFolder = Path.Combine(baseDirectory, config.ViewModelOutputFolder); } parameters.ApplyTemplateSettings = applyTemplateSettings; parameters.TemplateManager = templateManager; if (config.MaxParallelism == null || config.MaxParallelism.Value <= 0) { parameters.MaxParallelism = Environment.ProcessorCount; } else { parameters.MaxParallelism = config.MaxParallelism.Value; int wt, cpt; ThreadPool.GetMinThreads(out wt, out cpt); if (wt < parameters.MaxParallelism) { ThreadPool.SetMinThreads(parameters.MaxParallelism, cpt); } } if (config.MarkdownEngineName != null) { parameters.MarkdownEngineName = config.MarkdownEngineName; } if (config.MarkdownEngineProperties != null) { parameters.MarkdownEngineParameters = config.MarkdownEngineProperties.ToImmutableDictionary(); } if (config.CustomLinkResolver != null) { parameters.CustomLinkResolver = config.CustomLinkResolver; } parameters.TemplateDir = templateDir; var fileMappingParametersDictionary = GroupFileMappings(config.Content, config.Overwrite, config.Resource); if (config.LruSize == null) { parameters.LruSize = Environment.Is64BitProcess ? 0x2000 : 0xC00; } else { parameters.LruSize = Math.Max(0, config.LruSize.Value); } foreach (var pair in fileMappingParametersDictionary) { var p = parameters.Clone(); VersionConfig vi; if (config.Versions != null && config.Versions.TryGetValue(pair.Key, out vi)) { if (!string.IsNullOrEmpty(vi.Destination)) { p.VersionDir = vi.Destination; } } p.Files = GetFileCollectionFromFileMapping( baseDirectory, GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Content)), GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Overwrite)), GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Resource))); p.VersionName = pair.Key; p.Changes = GetIntersectChanges(p.Files, changeList); // TODO: move RootTocPath to VersionInfo p.RootTocPath = pair.Value.RootTocPath; yield return(p); } }
private static IEnumerable <DocumentBuildParameters> ConfigToParameter(BuildJsonConfig config, TemplateManager templateManager, string baseDirectory, string outputDirectory, string templateDir) { var parameters = new DocumentBuildParameters(); parameters.OutputBaseDir = outputDirectory; if (config.GlobalMetadata != null) { parameters.Metadata = config.GlobalMetadata.ToImmutableDictionary(); } if (config.FileMetadata != null) { parameters.FileMetadata = ConvertToFileMetadataItem(baseDirectory, config.FileMetadata); } if (config.PostProcessors != null) { parameters.PostProcessors = config.PostProcessors.ToImmutableArray(); } parameters.ExternalReferencePackages = GetFilesFromFileMapping( GlobUtility.ExpandFileMapping(baseDirectory, config.ExternalReference)) .ToImmutableArray(); if (config.XRefMaps != null) { parameters.XRefMaps = config.XRefMaps.ToImmutableArray(); } if (!config.NoLangKeyword) { parameters.XRefMaps = parameters.XRefMaps.Add("embedded:docfx/langwordMapping.yml"); } var applyTemplateSettings = new ApplyTemplateSettings(baseDirectory, outputDirectory) { TransformDocument = config.DryRun != true, }; applyTemplateSettings.RawModelExportSettings.Export = config.ExportRawModel == true; if (!string.IsNullOrEmpty(config.RawModelOutputFolder)) { applyTemplateSettings.RawModelExportSettings.OutputFolder = Path.Combine(baseDirectory, config.RawModelOutputFolder); } applyTemplateSettings.ViewModelExportSettings.Export = config.ExportViewModel == true; if (!string.IsNullOrEmpty(config.ViewModelOutputFolder)) { applyTemplateSettings.ViewModelExportSettings.OutputFolder = Path.Combine(baseDirectory, config.ViewModelOutputFolder); } parameters.ApplyTemplateSettings = applyTemplateSettings; parameters.TemplateManager = templateManager; if (config.MaxParallelism == null || config.MaxParallelism.Value <= 0) { parameters.MaxParallelism = Environment.ProcessorCount; } else { parameters.MaxParallelism = config.MaxParallelism.Value; } if (config.MarkdownEngineName != null) { parameters.MarkdownEngineName = config.MarkdownEngineName; } if (config.MarkdownEngineProperties != null) { parameters.MarkdownEngineParameters = config.MarkdownEngineProperties.ToImmutableDictionary(); } parameters.TemplateDir = templateDir; ChangeList changeList = null; if (config.ChangesFile != null) { changeList = ChangeList.Parse(config.ChangesFile, config.BaseDirectory); } var fileMappingParametersDictionary = GroupFileMappings(config.Content, config.Overwrite, config.Resource); foreach (var pair in fileMappingParametersDictionary) { parameters.Files = GetFileCollectionFromFileMapping( baseDirectory, GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Content)), GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Overwrite)), GlobUtility.ExpandFileMapping(baseDirectory, pair.Value.GetFileMapping(FileMappingType.Resource))); parameters.VersionName = pair.Key; parameters.Changes = GetIntersectChanges(parameters.Files, changeList); yield return(parameters); } }