async Task WriteConstructor(ProgrammableBlockApi api, ApiEntry overload, MarkdownWriter writer, ConstructorInfo constructorInfo) { await writer.BeginCodeBlockAsync(); await writer.WriteLineAsync(overload.ToString(ApiEntryStringFlags.Modifiers | ApiEntryStringFlags.GenericParameters | ApiEntryStringFlags.ParameterTypes | ApiEntryStringFlags.ParameterNames | ApiEntryStringFlags.ReturnValue | ApiEntryStringFlags.Accessors)); await writer.EndCodeBlockAsync(); if (overload.Documentation?.Summary != null) { await WriteDocumentation(api, overload.Documentation?.Summary, writer); } var parameters = constructorInfo.GetParameters(); if (parameters.Length > 0) { await writer.WriteHeaderAsync(3, "Parameters"); foreach (var parameter in parameters) { var returnEntry = api.GetEntry(parameter.GetActualParameterType(), true); await writer.WriteAsync("* "); await writer.WriteAsync(LinkTo(returnEntry.ToString(ApiEntryStringFlags.ShortDisplayName), returnEntry)); await writer.WriteAsync(" "); await writer.WriteAsync(parameter.Name); await writer.WriteLineAsync(); } } if (overload.Documentation?.Example != null) { await writer.WriteHeaderAsync(3, "Example"); await WriteDocumentation(api, overload.Documentation?.Example, writer); } if (overload.Documentation?.Remarks != null) { await writer.WriteHeaderAsync(3, "Remarks"); await WriteDocumentation(api, overload.Documentation?.Remarks, writer); } }
async Task WriteField(ProgrammableBlockApi api, ApiEntry overload, MarkdownWriter writer, FieldInfo fieldInfo) { await writer.BeginCodeBlockAsync(); await writer.WriteLineAsync(overload.ToString(ApiEntryStringFlags.Modifiers | ApiEntryStringFlags.GenericParameters | ApiEntryStringFlags.ParameterTypes | ApiEntryStringFlags.ParameterNames | ApiEntryStringFlags.ReturnValue | ApiEntryStringFlags.Accessors)); await writer.EndCodeBlockAsync(); if (overload.Documentation?.Summary != null) { await WriteDocumentation(api, overload.Documentation?.Summary, writer); } await writer.WriteHeaderAsync(3, "Returns"); var returnEntry = api.GetEntry(fieldInfo.FieldType, true); await writer.BeginParagraphAsync(); await writer.WriteAsync(LinkTo(returnEntry.ToString(ApiEntryStringFlags.ShortDisplayName), returnEntry)); await writer.EndParagraphAsync(); if (overload.Documentation?.Returns != null) { await WriteDocumentation(api, overload.Documentation?.Returns, writer); } if (overload.Documentation?.Example != null) { await writer.WriteHeaderAsync(3, "Example"); await WriteDocumentation(api, overload.Documentation?.Example, writer); } if (overload.Documentation?.Remarks != null) { await writer.WriteHeaderAsync(3, "Remarks"); await WriteDocumentation(api, overload.Documentation?.Remarks, writer); } }
async Task GeneratePage(ProgrammableBlockApi api, DirectoryInfo directory, ApiEntry entry) { var fileName = Path.Combine(directory.FullName, entry.SuggestedFileName); Debug.WriteLine(entry.FullName + " " + fileName); using (var file = File.CreateText(fileName)) { var writer = new MarkdownWriter(file); await writer.BeginParagraphAsync(); await writer.WriteAsync($"← {MarkdownInline.HRef("Index", "Api-Index")} ← {MarkdownInline.HRef("Namespace Index", "Namespace-Index")}"); await writer.EndParagraphAsync(); await writer.WriteHeaderAsync(4, $"{WebUtility.HtmlEncode(entry.ToString(ApiEntryStringFlags.GenericParameters))} {ConstructOf(entry)}"); await writer.BeginCodeBlockAsync(); await writer.WriteLineAsync(entry.ToString(ApiEntryStringFlags.Modifiers | ApiEntryStringFlags.GenericParameters | ApiEntryStringFlags.Inheritance)); await writer.EndCodeBlockAsync(); if (entry.Documentation?.Summary != null) { await WriteDocumentation(api, entry.Documentation?.Summary, writer); } await writer.BeginParagraphAsync(); await writer.WriteLineAsync($"{MarkdownInline.Strong("Namespace:")} {MarkdownInline.HRef(entry.NamespaceName, Path.GetFileNameWithoutExtension(ToMdFileName(entry.NamespaceName)))}"); await writer.WriteLineAsync($"{MarkdownInline.Strong("Assembly:")} {entry.AssemblyName}.dll"); await writer.EndParagraphAsync(); if (entry.BaseEntry != null) { await WriteInheritance(entry, writer); } if (entry.InheritedEntries.Count > 0) { await WriteInterfaces(entry, writer); } if (entry.InheritorEntries.Count > 0) { await WriteInheritors(entry, writer); } await WriteTypeDefinitions(entry, writer); var obsoleteAttribute = entry.Member.GetCustomAttribute <ObsoleteAttribute>(false); if (obsoleteAttribute != null) { await writer.WriteHeaderAsync(2, "Obsolete"); await writer.BeginParagraphAsync(); await writer.WriteLineAsync("This type should no longer be used and may be removed in the future. If you're using it, you should replace it as soon as possible. "); await writer.WriteAsync(obsoleteAttribute.Message); await file.WriteLineAsync(); } if (entry.Documentation?.Example != null) { await writer.WriteHeaderAsync(4, "Example"); await WriteDocumentation(api, entry.Documentation?.Example, writer); } if (entry.Documentation?.Remarks != null) { await writer.WriteHeaderAsync(4, "Remarks"); await WriteDocumentation(api, entry.Documentation?.Remarks, writer); } await WriteMembers(api, entry, writer); await writer.FlushAsync(); } }