diff --git a/src/Microsoft.DocAsCode.Build.Engine/DocumentBuildParameters.cs b/src/Microsoft.DocAsCode.Build.Engine/DocumentBuildParameters.cs index 313401482ce..118c1fd270e 100644 --- a/src/Microsoft.DocAsCode.Build.Engine/DocumentBuildParameters.cs +++ b/src/Microsoft.DocAsCode.Build.Engine/DocumentBuildParameters.cs @@ -4,13 +4,16 @@ namespace Microsoft.DocAsCode.Build.Engine { using System; + using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.DocAsCode.Build.Engine.Incrementals; using Microsoft.DocAsCode.Common; using Microsoft.DocAsCode.Plugins; - public sealed class DocumentBuildParameters : MarshalByRefObject + using Newtonsoft.Json.Linq; + + public sealed class DocumentBuildParameters : MarshalByRefObject, IBuildParameters { [IncrementalIgnore] public FileCollection Files { get; set; } @@ -18,6 +21,9 @@ public sealed class DocumentBuildParameters : MarshalByRefObject [IncrementalIgnore] public string OutputBaseDir { get; set; } + [IncrementalIgnore] + public IReadOnlyDictionary TagParameters { get; set; } + public ImmutableArray ExternalReferencePackages { get; set; } = ImmutableArray.Empty; public ImmutableArray XRefMaps { get; set; } = ImmutableArray.Empty; diff --git a/src/Microsoft.DocAsCode.Build.Engine/HostService.cs b/src/Microsoft.DocAsCode.Build.Engine/HostService.cs index 388d7e620bb..017af5621c4 100644 --- a/src/Microsoft.DocAsCode.Build.Engine/HostService.cs +++ b/src/Microsoft.DocAsCode.Build.Engine/HostService.cs @@ -30,6 +30,8 @@ internal sealed class HostService : IHostService, IDisposable #region Properties + public IBuildParameters BuildParameters { get; } + public TemplateProcessor Template { get; set; } public ImmutableList Models { get; private set; } @@ -63,16 +65,20 @@ internal sealed class HostService : IHostService, IDisposable #region Constructors public HostService(string baseDir, IEnumerable models) - : this(baseDir, models, null, null, 0) { } + : this(baseDir, models, null, null, 0, null) { } public HostService(string baseDir, IEnumerable models, string versionName, string versionDir, int lruSize) - : this(baseDir, models, versionName, versionDir, lruSize, null) { } + : this(baseDir, models, versionName, versionDir, lruSize, null, null) { } public HostService(string baseDir, IEnumerable models, string versionName, string versionDir, int lruSize, GroupInfo groupInfo) + : this(baseDir, models, versionName, versionDir, lruSize, groupInfo, null) { } + + public HostService(string baseDir, IEnumerable models, string versionName, string versionDir, int lruSize, GroupInfo groupInfo, IBuildParameters buildParameters) { VersionName = versionName; VersionOutputFolder = versionDir; GroupInfo = groupInfo; + BuildParameters = buildParameters; // Disable LRU, when Content.get, it is possible that the value is Serialized before the modification on the content does not complete yet //if (lruSize > 0) diff --git a/src/Microsoft.DocAsCode.Build.Engine/HostServiceCreator.cs b/src/Microsoft.DocAsCode.Build.Engine/HostServiceCreator.cs index d209bd12b82..2b430f839b0 100644 --- a/src/Microsoft.DocAsCode.Build.Engine/HostServiceCreator.cs +++ b/src/Microsoft.DocAsCode.Build.Engine/HostServiceCreator.cs @@ -12,6 +12,7 @@ namespace Microsoft.DocAsCode.Build.Engine using Microsoft.DocAsCode.Common; using Microsoft.DocAsCode.Plugins; + using Newtonsoft.Json.Linq; internal class HostServiceCreator : IHostServiceCreator { @@ -46,7 +47,8 @@ public virtual HostService CreateHostService( parameters.VersionName, parameters.VersionDir, parameters.LruSize, - parameters.GroupInfo) + parameters.GroupInfo, + new BuildParameters(parameters.TagParameters)) { MarkdownService = markdownService, Processor = processor, @@ -123,5 +125,15 @@ private static ImmutableDictionary ApplyFileMetadata( } return result.ToImmutableDictionary(); } + + private sealed class BuildParameters : IBuildParameters + { + public IReadOnlyDictionary TagParameters { get; } + + public BuildParameters(IReadOnlyDictionary tagParameters) + { + TagParameters = tagParameters; + } + } } } diff --git a/src/Microsoft.DocAsCode.Plugins/IBuildParameters.cs b/src/Microsoft.DocAsCode.Plugins/IBuildParameters.cs new file mode 100644 index 00000000000..a15032e04e3 --- /dev/null +++ b/src/Microsoft.DocAsCode.Plugins/IBuildParameters.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.DocAsCode.Plugins +{ + using System.Collections.Generic; + + using Newtonsoft.Json.Linq; + + public interface IBuildParameters + { + IReadOnlyDictionary TagParameters { get; } + } +} diff --git a/src/Microsoft.DocAsCode.Plugins/IHostService.cs b/src/Microsoft.DocAsCode.Plugins/IHostService.cs index f7895befe3e..bcff0513346 100644 --- a/src/Microsoft.DocAsCode.Plugins/IHostService.cs +++ b/src/Microsoft.DocAsCode.Plugins/IHostService.cs @@ -8,6 +8,8 @@ namespace Microsoft.DocAsCode.Plugins public interface IHostService { + IBuildParameters BuildParameters { get; } + ImmutableList TableOfContentRestructions { get; set; } /// diff --git a/src/docfx/Models/BuildJsonConfig.cs b/src/docfx/Models/BuildJsonConfig.cs index ecc51468d8f..d26c0cd5f22 100644 --- a/src/docfx/Models/BuildJsonConfig.cs +++ b/src/docfx/Models/BuildJsonConfig.cs @@ -10,6 +10,7 @@ namespace Microsoft.DocAsCode using Microsoft.DocAsCode.Plugins; using Newtonsoft.Json; + using Newtonsoft.Json.Linq; [Serializable] public class BuildJsonConfig @@ -64,6 +65,9 @@ public class BuildJsonConfig [JsonProperty("fileMetadata")] public Dictionary FileMetadata { get; set; } + [JsonProperty("tagParameters")] + public Dictionary TagParameters { get; set; } + [JsonProperty("fileMetadataFiles")] public ListWithStringFallback FileMetadataFilePaths { get; set; } = new ListWithStringFallback(); diff --git a/src/docfx/SubCommands/DocumentBuilderWrapper.cs b/src/docfx/SubCommands/DocumentBuilderWrapper.cs index 0a2dc96ab18..fda75bb99f4 100644 --- a/src/docfx/SubCommands/DocumentBuilderWrapper.cs +++ b/src/docfx/SubCommands/DocumentBuilderWrapper.cs @@ -226,6 +226,7 @@ private static IEnumerable ConfigToParameter(BuildJsonC FALName = config.FALName, DisableGitFeatures = config.DisableGitFeatures, SchemaLicense = config.SchemaLicense, + TagParameters = config.TagParameters }; if (config.GlobalMetadata != null) {