Skip to content

Commit e2c3214

Browse files
Simplify api generation via cake+docfx
1 parent 6553e0d commit e2c3214

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

build/Program.cs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -198,46 +198,11 @@ public void RunDocfx(FilePath docfxJson)
198198

199199
var currentDirectory = Directory.GetCurrentDirectory();
200200
Directory.SetCurrentDirectory(docfxJson.GetDirectory().FullPath);
201-
DocfxGenerateMetadata(docfxJson.FullPath);
201+
Microsoft.DocAsCode.Dotnet.DotnetApiCatalog.GenerateManagedReferenceYamlFiles(docfxJson.FullPath).Wait();
202202
Microsoft.DocAsCode.Docset.Build(docfxJson.FullPath).Wait();
203203
Directory.SetCurrentDirectory(currentDirectory);
204204
}
205205

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-
241206
public void GenerateRedirects()
242207
{
243208
var redirectProjectFile = RedirectProjectDirectory.CombineWithFilePath("RedirectGenerator.csproj");

0 commit comments

Comments
 (0)