Skip to content

Commit 4b265ce

Browse files
Fix generation of the docs/api
1 parent 1c55972 commit 4b265ce

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

build/Program.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
using System;
12
using System.IO;
23
using System.Linq;
4+
using System.Reflection;
35
using System.Text;
6+
using System.Threading.Tasks;
47
using Build;
58
using Cake.Common;
69
using Cake.Common.Build;
@@ -195,10 +198,46 @@ public void RunDocfx(FilePath docfxJson)
195198

196199
var currentDirectory = Directory.GetCurrentDirectory();
197200
Directory.SetCurrentDirectory(docfxJson.GetDirectory().FullPath);
201+
DocfxGenerateMetadata(docfxJson.FullPath);
198202
Microsoft.DocAsCode.Docset.Build(docfxJson.FullPath).Wait();
199203
Directory.SetCurrentDirectory(currentDirectory);
200204
}
201205

206+
private void DocfxGenerateMetadata(string configPath)
207+
{
208+
Microsoft.DocAsCode.Common.Logger.RegisterListener(new Microsoft.DocAsCode.Common.ConsoleLogListener());
209+
try
210+
{
211+
string directoryName = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(configPath));
212+
Newtonsoft.Json.Linq.JToken jtoken;
213+
if (!Newtonsoft.Json.Linq.JObject.Parse(File.ReadAllText(configPath)).TryGetValue("metadata", out jtoken))
214+
return;
215+
216+
var dotnetApiCatalogType = typeof(Microsoft.DocAsCode.Dotnet.DotnetApiOptions).Assembly.GetTypes()
217+
.First(t => t.Name == "DotnetApiCatalog");
218+
var dotnetApiCatalogExecMethod = dotnetApiCatalogType.GetMethod("Exec", BindingFlags.Static | BindingFlags.NonPublic);
219+
var metadataJsonConfigType = typeof(Microsoft.DocAsCode.Dotnet.DotnetApiOptions).Assembly.GetTypes()
220+
.First(t => t.Name == "MetadataJsonConfig");
221+
222+
var config = jtoken.ToObject(metadataJsonConfigType, Microsoft.DocAsCode.Common.JsonUtility.DefaultSerializer.Value);
223+
224+
var execTask = (Task)dotnetApiCatalogExecMethod.Invoke(null, new[]
225+
{
226+
config,
227+
new Microsoft.DocAsCode.Dotnet.DotnetApiOptions(),
228+
directoryName,
229+
null
230+
});
231+
execTask.Wait();
232+
}
233+
finally
234+
{
235+
Microsoft.DocAsCode.Common.Logger.Flush();
236+
Microsoft.DocAsCode.Common.Logger.PrintSummary();
237+
Microsoft.DocAsCode.Common.Logger.UnregisterAllListeners();
238+
}
239+
}
240+
202241
public void GenerateRedirects()
203242
{
204243
var redirectProjectFile = RedirectProjectDirectory.CombineWithFilePath("RedirectGenerator.csproj");

docs/docfx.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
"src": [
55
{
66
"files": [
7-
"src/BenchmarkDotNet/*.csproj",
8-
"src/BenchmarkDotNet.Annotations/*.csproj"
9-
],
10-
"exclude": [
11-
"**/obj/**",
12-
"**/bin/**"
7+
"src/BenchmarkDotNet/bin/Release/netstandard2.0/BenchmarkDotNet.dll",
8+
"src/BenchmarkDotNet/bin/Release/netstandard2.0/BenchmarkDotNet.Annotations.dll"
139
],
1410
"src": ".."
1511
}

0 commit comments

Comments
 (0)