Skip to content

Commit

Permalink
drop: remove some obsolete features (dotnet#9221)
Browse files Browse the repository at this point in the history
drop: remove obsolete features: paring, xrefTags, tagParameters, versions, homepages
  • Loading branch information
yufeih authored and p-kostov committed Jun 28, 2024
1 parent 62c942b commit 57553be
Show file tree
Hide file tree
Showing 30 changed files with 9 additions and 631 deletions.
58 changes: 1 addition & 57 deletions src/Docfx.App/Config/BuildJsonConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ namespace Docfx;
[Serializable]
internal class BuildJsonConfig
{
[JsonIgnore]
private Dictionary<string, GroupConfig> _versions;

[JsonIgnore]
private Dictionary<string, GroupConfig> _groups;

/// <summary>
/// Contains all the files to generate documentation, including metadata yml files and conceptual md files.
/// </summary>
Expand All @@ -40,19 +34,6 @@ internal class BuildJsonConfig
[JsonProperty("overwrite")]
public FileMapping Overwrite { get; set; }

/// <summary>
/// Specifies pairing that is used for folder redirection rules.
/// </summary>
[Obsolete("May be removed in a future release.")]
[JsonProperty("pairing")]
public List<ContentPairingInfo> Pairing { get; set; }

/// <summary>
/// Specifies the tags of xrefmap.
/// </summary>
[JsonProperty("xrefTags")]
public ListWithStringFallback XrefTags { get; set; }

/// <summary>
/// Specifies the urls of xrefmap used by content files. Supports local file path and HTTP/HTTPS urls.
/// </summary>
Expand Down Expand Up @@ -95,13 +76,6 @@ internal class BuildJsonConfig
[JsonProperty("fileMetadata")]
public Dictionary<string, FileMetadataPairs> FileMetadata { get; set; }

/// <summary>
/// Specify tag parameters that are used by SchemaDrivenDocumentProcessor
/// </summary>
[Obsolete("May be removed in a future release.")]
[JsonProperty("tagParameters")]
public Dictionary<string, JArray> TagParameters { get; set; }

/// <summary>
/// Specify a list of JSON file path containing fileMetadata settings.
/// </summary>
Expand Down Expand Up @@ -204,23 +178,6 @@ internal class BuildJsonConfig
[JsonProperty("customLinkResolver")]
public string CustomLinkResolver { get; set; }

/// <summary>
/// Define versions.
/// </summary>
[Obsolete("Use groups instead.")]
[JsonProperty("versions")]
public Dictionary<string, GroupConfig> Versions
{
get
{
return _versions;
}
set
{
_versions = value;
}
}

/// <summary>
/// Define groups.
/// </summary>
Expand All @@ -229,26 +186,13 @@ public Dictionary<string, GroupConfig> Versions
/// groups:{
/// "v1": {
/// "dest": "v1",
/// "xrefTags: [],
/// "extraMetadata01": {}
/// }
/// }
/// </code>
/// </example>
[JsonProperty("groups")]
public Dictionary<string, GroupConfig> Groups
{
get
{
return _groups ?? _versions;
}
set
{
_groups = value;
_versions = value;
}

}
public Dictionary<string, GroupConfig> Groups { get; set; }

/// <summary>
/// If set to true, docfx does not dereference (aka. copy) file to the output folder.
Expand Down
25 changes: 0 additions & 25 deletions src/Docfx.App/Config/ContentPairingInfo.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/Docfx.App/Config/GroupConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ internal class GroupConfig
[JsonProperty("dest")]
public string Destination { get; set; }

/// <summary>
/// Specifies the tags of xrefmap.
/// </summary>
[JsonProperty("xrefTags")]
public ListWithStringFallback XrefTags { get; set; }

/// <summary>
/// Extension metadata.
/// </summary>
Expand Down
9 changes: 0 additions & 9 deletions src/Docfx.App/Helpers/DocumentBuilderWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ private static List<DocumentBuildParameters> ConfigToParameter(BuildJsonConfig c
OutputBaseDir = outputDirectory,
SitemapOptions = config.SitemapOptions,
DisableGitFeatures = config.DisableGitFeatures,
TagParameters = config.TagParameters,
ConfigureMarkdig = options.ConfigureMarkdig,
};

Expand Down Expand Up @@ -208,13 +207,6 @@ private static List<DocumentBuildParameters> ConfigToParameter(BuildJsonConfig c
parameters.KeepFileLink = true;
}

if (config.Pairing != null)
{
parameters.OverwriteFragmentsRedirectionRules = config.Pairing.Select(i => new FolderRedirectionRule(i.ContentFolder, i.OverwriteFragmentsFolder)).ToImmutableArray();
}

parameters.XRefTags = config.XrefTags;

foreach (var pair in fileMappingParametersDictionary)
{
var p = parameters.Clone();
Expand All @@ -227,7 +219,6 @@ private static List<DocumentBuildParameters> ConfigToParameter(BuildJsonConfig c
if (config.Groups != null && config.Groups.TryGetValue(pair.Key, out GroupConfig gi))
{
p.GroupInfo.Destination = gi.Destination;
p.GroupInfo.XRefTags = gi.XrefTags ?? new List<string>();
p.GroupInfo.Metadata = gi.Metadata;
if (!string.IsNullOrEmpty(gi.Destination))
{
Expand Down
12 changes: 2 additions & 10 deletions src/Docfx.Build.Engine/DocumentBuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ public DocumentBuildContext(string buildOutputFolder)
: this(buildOutputFolder, Enumerable.Empty<FileAndType>(), ImmutableArray<string>.Empty, ImmutableArray<string>.Empty, 1, Directory.GetCurrentDirectory(), string.Empty, null, null) { }

public DocumentBuildContext(string buildOutputFolder, IEnumerable<FileAndType> allSourceFiles, ImmutableArray<string> externalReferencePackages, ImmutableArray<string> xrefMaps, int maxParallelism, string baseFolder, string versionName, ApplyTemplateSettings applyTemplateSetting, string rootTocPath)
: this(buildOutputFolder, allSourceFiles, externalReferencePackages, xrefMaps, maxParallelism, baseFolder, versionName, applyTemplateSetting, rootTocPath, null) { }

public DocumentBuildContext(string buildOutputFolder, IEnumerable<FileAndType> allSourceFiles, ImmutableArray<string> externalReferencePackages, ImmutableArray<string> xrefMaps, int maxParallelism, string baseFolder, string versionName, ApplyTemplateSettings applyTemplateSetting, string rootTocPath, string versionFolder)
: this(buildOutputFolder, allSourceFiles, externalReferencePackages, xrefMaps, maxParallelism, baseFolder, versionName, applyTemplateSetting, rootTocPath, null, null, null) { }
: this(buildOutputFolder, allSourceFiles, externalReferencePackages, xrefMaps, maxParallelism, baseFolder, versionName, applyTemplateSetting, rootTocPath, null, null) { }

public DocumentBuildContext(DocumentBuildParameters parameters)
{
Expand All @@ -33,7 +30,6 @@ public DocumentBuildContext(DocumentBuildParameters parameters)
HrefGenerator = parameters.ApplyTemplateSettings?.HrefGenerator;
AllSourceFiles = GetAllSourceFiles(parameters.Files.EnumerateFiles());
GroupInfo = parameters.GroupInfo;
XRefTags = parameters.XRefTags;
MaxParallelism = parameters.MaxParallelism;

if (parameters.XRefMaps.Length > 0)
Expand Down Expand Up @@ -71,8 +67,7 @@ public DocumentBuildContext(
ApplyTemplateSettings applyTemplateSetting,
string rootTocPath,
string versionFolder,
GroupInfo groupInfo,
List<string> xrefTags)
GroupInfo groupInfo)
{
BuildOutputFolder = buildOutputFolder;
VersionName = versionName;
Expand All @@ -81,7 +76,6 @@ public DocumentBuildContext(
AllSourceFiles = GetAllSourceFiles(allSourceFiles);
ExternalReferencePackages = externalReferencePackages;
GroupInfo = groupInfo;
XRefTags = xrefTags;
MaxParallelism = maxParallelism;
if (xrefMaps.Length > 0)
{
Expand Down Expand Up @@ -113,8 +107,6 @@ from u in xrefMaps

public GroupInfo GroupInfo { get; }

public List<string> XRefTags { get; }

public ApplyTemplateSettings ApplyTemplateSettings { get; set; }

public ImmutableArray<string> ExternalReferencePackages { get; } = ImmutableArray<string>.Empty;
Expand Down
13 changes: 1 addition & 12 deletions src/Docfx.Build.Engine/DocumentBuildParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;
using Docfx.Common;
using Docfx.Plugins;
using Markdig;
using Newtonsoft.Json.Linq;

namespace Docfx.Build.Engine;

public sealed class DocumentBuildParameters : IBuildParameters
public class DocumentBuildParameters
{
public FileCollection Files { get; set; }

public string OutputBaseDir { get; set; }

public IReadOnlyDictionary<string, JArray> TagParameters { get; set; }

public ImmutableArray<string> ExternalReferencePackages { get; set; } = ImmutableArray<string>.Empty;

public ImmutableArray<string> XRefMaps { get; set; } = ImmutableArray<string>.Empty;

public ImmutableDictionary<string, object> Metadata { get; set; } = ImmutableDictionary<string, object>.Empty;
Expand All @@ -43,8 +37,6 @@ public sealed class DocumentBuildParameters : IBuildParameters

public GroupInfo GroupInfo { get; set; }

public List<string> XRefTags { get; set; }

public string RootTocPath { get; set; }

public string TemplateDir { get; set; }
Expand All @@ -57,9 +49,6 @@ public sealed class DocumentBuildParameters : IBuildParameters

public bool DisableGitFeatures { get; set; }

public ImmutableArray<FolderRedirectionRule> OverwriteFragmentsRedirectionRules { get; set; }
= ImmutableArray<FolderRedirectionRule>.Empty;

public DocumentBuildParameters Clone() =>
(DocumentBuildParameters)MemberwiseClone();
}
1 change: 0 additions & 1 deletion src/Docfx.Build.Engine/DocumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ private List<IDocumentProcessor> LoadSchemaDrivenDocumentProcessors(DocumentBuil
schema,
new CompositionContainer(CompositionContainer.DefaultContainer),
markdigMarkdownService,
new FolderRedirectionManager(parameter.OverwriteFragmentsRedirectionRules),
siteHostName);
Logger.LogVerbose($"\t{sdp.Name} with build steps ({string.Join(", ", from bs in sdp.BuildSteps orderby bs.BuildOrder select bs.Name)})");
result.Add(sdp);
Expand Down
5 changes: 1 addition & 4 deletions src/Docfx.Build.Engine/HostService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ internal sealed class HostService : IHostService, IDisposable

#region Properties

public IBuildParameters BuildParameters { get; }

public TemplateProcessor Template { get; set; }

public ImmutableList<FileModel> Models { get; private set; }
Expand All @@ -48,12 +46,11 @@ internal sealed class HostService : IHostService, IDisposable

#region Constructors

public HostService(string baseDir, IEnumerable<FileModel> models, string versionName = null, string versionDir = null, GroupInfo groupInfo = null, IBuildParameters buildParameters = null)
public HostService(string baseDir, IEnumerable<FileModel> models, string versionName = null, string versionDir = null, GroupInfo groupInfo = null)
{
VersionName = versionName;
VersionOutputFolder = versionDir;
GroupInfo = groupInfo;
BuildParameters = buildParameters;

LoadCore(models);
}
Expand Down
13 changes: 1 addition & 12 deletions src/Docfx.Build.Engine/HostServiceCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public virtual HostService CreateHostService(
models,
parameters.VersionName,
parameters.VersionDir,
parameters.GroupInfo,
new BuildParameters(parameters.TagParameters))
parameters.GroupInfo)
{
MarkdownService = markdownService,
Processor = processor,
Expand Down Expand Up @@ -134,14 +133,4 @@ private static ImmutableDictionary<string, object> ApplyFileMetadata(
}
return result.ToImmutableDictionary();
}

private sealed class BuildParameters : IBuildParameters
{
public IReadOnlyDictionary<string, JArray> TagParameters { get; }

public BuildParameters(IReadOnlyDictionary<string, JArray> tagParameters)
{
TagParameters = tagParameters;
}
}
}
8 changes: 2 additions & 6 deletions src/Docfx.Build.Engine/ManifestUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public static Manifest MergeManifest(List<Manifest> manifests)
ArgumentNullException.ThrowIfNull(manifests);

var xrefMaps = (from manifest in manifests
where manifest.XRefMap != null
select manifest.XRefMap).ToList();
where manifest.XRefMap != null
select manifest.XRefMap).ToList();
var manifestGroupInfos = (from manifest in manifests
from g in manifest.Groups ?? Enumerable.Empty<ManifestGroupInfo>()
select g).ToList();
Expand All @@ -54,13 +54,9 @@ public static Manifest MergeManifest(List<Manifest> manifests)
from file in manifest.Files ?? Enumerable.Empty<ManifestItem>()
select file).Distinct())
{
Homepages = (from manifest in manifests
from homepage in manifest.Homepages ?? Enumerable.Empty<HomepageInfo>()
select homepage).Distinct().ToList(),
XRefMap = xrefMaps.Count <= 1 ? xrefMaps.FirstOrDefault() : xrefMaps,
SourceBasePath = manifests.FirstOrDefault()?.SourceBasePath,
Groups = manifestGroupInfos.Count > 0 ? manifestGroupInfos : null,
VersionInfo = manifests.Where(m => m.VersionInfo != null).SelectMany(m => m.VersionInfo).ToDictionary(p => p.Key, p => p.Value)
};
}

Expand Down
26 changes: 1 addition & 25 deletions src/Docfx.Build.Engine/SingleDocumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,8 @@ private Manifest BuildCore(DocumentBuildParameters parameters)

var manifest = new Manifest(context.ManifestItems.Where(m => m.OutputFiles?.Count > 0))
{
Homepages = GetHomepages(context),
XRefMap = ExportXRefMap(parameters, context),
SourceBasePath = StringExtension.ToNormalizedPath(EnvironmentContext.BaseDirectory),
VersionInfo = string.IsNullOrEmpty(context.VersionName) ?
new Dictionary<string, VersionInfo>() :
new Dictionary<string, VersionInfo>
{
{
context.VersionName,
new VersionInfo {VersionFolder = context.VersionFolder}
}
}
};
manifest.Groups = new List<ManifestGroupInfo>
{
Expand Down Expand Up @@ -218,27 +208,13 @@ private void Prepare(
};
}

private static List<HomepageInfo> GetHomepages(DocumentBuildContext context)
{
return (from s in context.GetTocInfo()
where !string.IsNullOrEmpty(s.Homepage)
select new HomepageInfo
{
Homepage = RelativePath.GetPathWithoutWorkingFolderChar(s.Homepage),
TocPath = RelativePath.GetPathWithoutWorkingFolderChar(context.GetFilePath(s.TocFileKey))
}).ToList();
}

/// <summary>
/// Export xref map file.
/// </summary>
private static string ExportXRefMap(DocumentBuildParameters parameters, DocumentBuildContext context)
{
Logger.LogVerbose("Exporting xref map...");
var xrefMap = new XRefMap
{
Tags = context.GroupInfo?.XRefTags ?? context.XRefTags,
};
var xrefMap = new XRefMap();
xrefMap.References =
(from xref in context.XRefSpecMap.Values.AsParallel().WithDegreeOfParallelism(parameters.MaxParallelism)
select new XRefSpec(xref)
Expand Down
4 changes: 0 additions & 4 deletions src/Docfx.Build.Engine/XRefMaps/XRefMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public class XRefMap : IXRefContainer
[JsonProperty("baseUrl")]
public string BaseUrl { get; set; }

[YamlMember(Alias = "tags")]
[JsonProperty("tags")]
public List<string> Tags { get; set; }

[YamlMember(Alias = "redirections")]
[JsonProperty("redirections")]
public List<XRefMapRedirection> Redirections { get; set; }
Expand Down
Loading

0 comments on commit 57553be

Please sign in to comment.