Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: source code improvements #10073

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Docfx.Build/CompilePhaseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Handle(List<HostService> hostServices, int maxParallelism)
Prepare(hostServices, maxParallelism);
hostServices.RunAll(hostService =>
{
var steps = string.Join("=>", hostService.Processor.BuildSteps.OrderBy(step => step.BuildOrder).Select(s => s.Name));
var steps = string.Join("=>", hostService.Processor.BuildSteps.OrderBy(static step => step.BuildOrder).Select(static s => s.Name));
Logger.LogInfo($"Building {hostService.Models.Count} file(s) in {hostService.Processor.Name}({steps})...");
Logger.LogVerbose($"Processor {hostService.Processor.Name}: Prebuilding...");
Prebuild(hostService);
Expand Down Expand Up @@ -144,7 +144,7 @@ private static void RunBuildSteps(IEnumerable<IDocumentBuildStep> buildSteps, Ac
{
if (buildSteps != null)
{
foreach (var buildStep in buildSteps.OrderBy(step => step.BuildOrder))
foreach (var buildStep in buildSteps.OrderBy(static step => step.BuildOrder))
{
action(buildStep);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Docfx.Build/DocumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ public void Build(IList<DocumentBuildParameters> parameters, string outputDirect

if (parameter.Files.Count == 0)
{
manifests.Add(new Manifest() { SourceBasePath = StringExtension.ToNormalizedPath(EnvironmentContext.BaseDirectory) });
manifests.Add(new Manifest { SourceBasePath = StringExtension.ToNormalizedPath(EnvironmentContext.BaseDirectory) });
}
else
{
if (!parameter.Files.EnumerateFiles().Any(s => s.Type == DocumentType.Article))
if (!parameter.Files.EnumerateFiles().Any(static s => s.Type == DocumentType.Article))
{
if (!string.IsNullOrEmpty(parameter.GroupInfo?.Name))
{
Expand Down
7 changes: 5 additions & 2 deletions src/Docfx.Dotnet/DotnetApiCatalog.ApiPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,18 +602,21 @@ void EnumFields(INamedTypeSymbol type)
return;

if (config.EnumSortOrder is EnumSortOrder.Alphabetic)
items = items.OrderBy(m => m.Name).ToList();
items = items.OrderBy(static m => m.Name).ToList();

body.Add((Heading)new H2 { h2 = "Fields" });
body.Add(new Parameters { parameters = items.Select(ToParameter).ToArray() });

return;

Parameter ToParameter(IFieldSymbol item)
{
var docs = Comment(item, compilation) is { } comment ? string.Join("\n\n", comment.Summary, comment.Remarks) : null;

return new()
{
name = item.Name, @default = $"{item.ConstantValue}",
name = item.Name,
@default = $"{item.ConstantValue}",
deprecated = Deprecated(item),
preview = Preview(item),
description = docs,
Expand Down
3 changes: 3 additions & 0 deletions src/Docfx.Dotnet/DotnetApiCatalog.ManagedReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ private static void CreateManagedReference(List<(IAssemblySymbol symbol, Compila

ResolveAndExportYamlMetadata(allMembers, allReferences);

return;


void ResolveAndExportYamlMetadata(
Dictionary<string, MetadataItem> allMembers, Dictionary<string, ReferenceItem> allReferences)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Docfx.Dotnet/DotnetApiCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ private static ExtractMetadataConfig ConvertConfig(MetadataJsonItemConfig config
MemberLayout = configModel?.MemberLayout ?? default,
EnumSortOrder = configModel?.EnumSortOrder ?? default,
AllowCompilationErrors = configModel?.AllowCompilationErrors ?? false,
Files = expandedFiles.Items.SelectMany(s => s.Files).ToList(),
References = expandedReferences?.Items.SelectMany(s => s.Files).ToList(),
Files = expandedFiles.Items.SelectMany(static s => s.Files).ToList(),
References = expandedReferences?.Items.SelectMany(static s => s.Files).ToList()
};
}
}