Skip to content

Commit

Permalink
chore: dead code elimination
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeih committed Nov 8, 2023
1 parent 61a9a3c commit 8896961
Show file tree
Hide file tree
Showing 19 changed files with 15 additions and 333 deletions.
9 changes: 0 additions & 9 deletions src/Docfx.App/Helpers/Constants.cs

This file was deleted.

4 changes: 1 addition & 3 deletions src/Docfx.App/RunBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

namespace Docfx;

#pragma warning disable CS0618 // Type or member is obsolete

/// <summary>
/// Helper class to build document.
/// </summary>
Expand All @@ -20,7 +18,7 @@ public static string Exec(BuildJsonConfig config, BuildOptions options, string c
{
if (config.Template == null || config.Template.Count == 0)
{
config.Template = new ListWithStringFallback { Constants.DefaultTemplateName };
config.Template = new ListWithStringFallback { "default" };
}

var baseDirectory = Path.GetFullPath(string.IsNullOrEmpty(configDirectory) ? Directory.GetCurrentDirectory() : configDirectory);
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.Build/HostServiceCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Docfx.Build.Engine;

internal class HostServiceCreator : IHostServiceCreator
class HostServiceCreator
{
private readonly DocumentBuildContext _context;

Expand Down
32 changes: 0 additions & 32 deletions src/Docfx.Build/IHostServiceCreator.cs

This file was deleted.

8 changes: 4 additions & 4 deletions src/Docfx.Build/LinkPhaseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ private InternalManifestItem HandleSaveResult(
SaveResult result)
{
Context.SetFilePath(model.Key, ((RelativePath)model.File).GetPathFromWorkingFolder());
DocumentException.RunAll(
() => CheckFileLink(model, hostService, result),
() => HandleUids(result),
() => RegisterXRefSpec(result));

CheckFileLink(model, hostService, result);
HandleUids(result);
RegisterXRefSpec(result);

return GetManifestItem(model, result);
}
Expand Down
27 changes: 0 additions & 27 deletions src/Docfx.Build/OSPlatformSensitiveDictionary.cs

This file was deleted.

9 changes: 3 additions & 6 deletions src/Docfx.Build/PostProcessors/ValidateBookmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ public sealed class ValidateBookmark : HtmlDocumentHandler
/// <summary>
/// bookmarks mapping from output file -> bookmarks
/// </summary>
private readonly OSPlatformSensitiveDictionary<HashSet<string>> _registeredBookmarks =
new();
private readonly Dictionary<string, HashSet<string>> _registeredBookmarks = new(FilePathComparer.OSPlatformSensitiveStringComparer);
/// <summary>
/// file mapping from output file -> src file
/// </summary>
private readonly OSPlatformSensitiveDictionary<string> _fileMapping =
new();
private readonly OSPlatformSensitiveDictionary<List<LinkItem>> _linksWithBookmark =
new();
private readonly Dictionary<string, string> _fileMapping = new(FilePathComparer.OSPlatformSensitiveStringComparer);
private readonly Dictionary<string, List<LinkItem>> _linksWithBookmark = new(FilePathComparer.OSPlatformSensitiveStringComparer);

#region IHtmlDocumentHandler members

Expand Down
5 changes: 2 additions & 3 deletions src/Docfx.Build/SingleDocumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ public Manifest Build(DocumentBuildParameters parameters, IMarkdownService markd

// Start building document...
List<HostService> hostServices = null;
IHostServiceCreator hostServiceCreator = null;
try
{
using var templateProcessor = parameters.TemplateManager?.GetTemplateProcessor(context, parameters.MaxParallelism)
?? new TemplateProcessor(new EmptyResourceReader(), context, 16);

hostServiceCreator = new HostServiceCreator(context);
var hostServiceCreator = new HostServiceCreator(context);
hostServices = GetInnerContexts(parameters, Processors, templateProcessor, hostServiceCreator, markdownService);

templateProcessor.CopyTemplateResources(context.ApplyTemplateSettings);
Expand Down Expand Up @@ -100,7 +99,7 @@ private List<HostService> GetInnerContexts(
DocumentBuildParameters parameters,
IEnumerable<IDocumentProcessor> processors,
TemplateProcessor templateProcessor,
IHostServiceCreator creator,
HostServiceCreator creator,
IMarkdownService markdownService)
{
var files = (from file in parameters.Files.EnumerateFiles().AsParallel().WithDegreeOfParallelism(parameters.MaxParallelism)
Expand Down
11 changes: 0 additions & 11 deletions src/Docfx.Common/Git/GitException.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Docfx.Common/Git/RepoType.cs

This file was deleted.

22 changes: 0 additions & 22 deletions src/Docfx.Common/HashUtility.cs

This file was deleted.

11 changes: 3 additions & 8 deletions src/Docfx.Common/Loggers/LoggerFileScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Docfx.Common;

public sealed class LoggerFileScope : IDisposable
{
private static readonly AsyncLocal<string> t_fileName = new();
private readonly string _originFileName;

public LoggerFileScope(string fileName)
Expand All @@ -22,13 +23,7 @@ public void Dispose()
SetFileName(_originFileName);
}

internal static string GetFileName()
{
return LogicalCallContext.GetData(nameof(LoggerFileScope)) as string;
}
internal static string GetFileName() => t_fileName.Value;

private static void SetFileName(string fileName)
{
LogicalCallContext.SetData(nameof(LoggerFileScope), fileName);
}
private static void SetFileName(string fileName) => t_fileName.Value = fileName;
}
19 changes: 0 additions & 19 deletions src/Docfx.Common/LogicalCallContext.cs

This file was deleted.

28 changes: 0 additions & 28 deletions src/Docfx.Common/Path/FilePathComparerWithEnvironmentVariable.cs

This file was deleted.

17 changes: 0 additions & 17 deletions src/Docfx.Common/StringExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,6 @@ public static string ToDelimitedString(this IEnumerable<string> input, string de
return string.Join(delimiter, input);
}

public static string GetNormalizedFullPathKey(this IEnumerable<string> list)
{
if (list == null) return null;

// make sure the order consistent
var normalizedPaths = GetNormalizedFullPathList(list);
return normalizedPaths.ToDelimitedString();
}

public static IEnumerable<string> GetNormalizedFullPathList(this IEnumerable<string> paths)
{
if (paths == null) return null;
return (from p in paths
where !string.IsNullOrEmpty(p)
select ToNormalizedFullPath(p)).Distinct().OrderBy(s => s);
}

/// <summary>
/// Should not convert path to lower case as under Linux/Unix, path is case sensitive
/// Also, Website URL should be case sensitive consider the server might be running under Linux/Unix
Expand Down
Loading

0 comments on commit 8896961

Please sign in to comment.