Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeih committed Sep 21, 2023
1 parent 6d5a9bd commit 3042dec
Show file tree
Hide file tree
Showing 12 changed files with 659 additions and 25 deletions.
4 changes: 2 additions & 2 deletions samples/seed/dotnet/solution/CatLibrary/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public void Jump(T ownType, K anotherOwnType, ref bool cheat)
/// <summary>
/// Addition operator of this class.
/// </summary>
/// <param name="lsr">...</param>
/// <param name="rsr">~~~</param>
/// <param name="lsr">..</param>
/// <param name="rsr">~~</param>
/// <returns>Result with <i>int</i> type.</returns>
public static int operator +(Cat<T, K> lsr, int rsr) { return 1; }

Expand Down
1 change: 1 addition & 0 deletions src/Docfx.Dotnet/DotnetApiCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private static ExtractMetadataConfig ConvertConfig(MetadataJsonItemConfig config
IncludePrivateMembers = configModel?.IncludePrivateMembers ?? false,
GlobalNamespaceId = configModel?.GlobalNamespaceId,
MSBuildProperties = configModel?.MSBuildProperties,
OutputFormat = configModel?.OutputFormat ?? default,
OutputFolder = Path.GetFullPath(Path.Combine(outputDirectory, outputFolder)),
CodeSourceBasePath = configModel?.CodeSourceBasePath,
DisableDefaultFilter = configModel?.DisableDefaultFilter ?? false,
Expand Down
2 changes: 2 additions & 0 deletions src/Docfx.Dotnet/ExtractMetadata/ExtractMetadataConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ internal class ExtractMetadataConfig

public string OutputFolder { get; init; }

public MetadataOutputFormat OutputFormat { get; init; }

public bool ShouldSkipMarkup { get; init; }

public string FilterConfigFile { get; init; }
Expand Down
18 changes: 12 additions & 6 deletions src/Docfx.Dotnet/ExtractMetadata/ExtractMetadataWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,15 @@ await LoadCompilationFromProject(project.AbsolutePath) is { } compilation)
return;
}

if (_config.OutputFormat is MetadataOutputFormat.Markdown)
{
MarkdownFormatter.Save(assemblies, _config, _options);
return;
}

var projectMetadataList = new List<MetadataItem>();
var extensionMethods = assemblies.SelectMany(assembly => assembly.Item1.FindExtensionMethods()).ToArray();
var filter = new SymbolFilter(_config, _options);
var extensionMethods = assemblies.SelectMany(assembly => assembly.Item1.FindExtensionMethods()).ToArray();
var allAssemblies = new HashSet<IAssemblySymbol>(assemblies.Select(a => a.Item1), SymbolEqualityComparer.Default);

foreach (var (assembly, compilation) in assemblies)
Expand Down Expand Up @@ -168,7 +174,7 @@ await LoadCompilationFromProject(project.AbsolutePath) is { } compilation)

using (new PerformanceScope("ResolveAndExport"))
{
ResolveAndExportYamlMetadata(allMembers, allReferences);
ResolveAndExport(allMembers, allReferences);
}
}

Expand Down Expand Up @@ -196,7 +202,7 @@ await LoadCompilationFromProject(project.AbsolutePath) is { } compilation)
return await project.GetCompilationAsync();
}

private void ResolveAndExportYamlMetadata(
private void ResolveAndExport(
Dictionary<string, MetadataItem> allMembers, Dictionary<string, ReferenceItem> allReferences)
{
var outputFileNames = new Dictionary<string, int>(FilePathComparer.OSPlatformSensitiveStringComparer);
Expand Down Expand Up @@ -225,12 +231,12 @@ private void ResolveAndExportYamlMetadata(
{
var fileName = memberModel.Name.Replace('`', '-');
var outputFileName = GetUniqueFileNameWithSuffix(fileName + Constants.YamlExtension, outputFileNames);
string itemFilePath = Path.Combine(_config.OutputFolder, outputFileName);
var yamlFilePath = Path.Combine(_config.OutputFolder, outputFileName);
var memberViewModel = memberModel.ToPageViewModel(_config);
memberViewModel.ShouldSkipMarkup = _config.ShouldSkipMarkup;
memberViewModel.MemberLayout = _config.MemberLayout;
YamlUtility.Serialize(itemFilePath, memberViewModel, YamlMime.ManagedReference);
Logger.Log(LogLevel.Diagnostic, $"Metadata file for {memberModel.Name} is saved to {itemFilePath}.");
YamlUtility.Serialize(yamlFilePath, memberViewModel, YamlMime.ManagedReference);
Logger.Log(LogLevel.Diagnostic, $"Metadata file for {memberModel.Name} is saved to {yamlFilePath}.");
AddMemberToIndexer(memberModel, outputFileName, indexer);
}

Expand Down
Loading

0 comments on commit 3042dec

Please sign in to comment.