public override async Task Generate(DirectoryInfo directory, ProgrammableBlockApi api) { var fileName = Path.Combine(directory.FullName, "Namespace-Index.md"); using (var file = File.CreateText(fileName)) { var writer = new MarkdownWriter(file); await writer.BeginParagraphAsync(); await writer.WriteAsync($"← {MarkdownInline.HRef("Index", "Api-Index")}"); await writer.EndParagraphAsync(); await writer.WriteHeaderAsync(3, "Assemblies"); await writer.BeginParagraphAsync(); await writer.WriteLineAsync("These are the game assemblies used by programmable block scripts."); await writer.WriteLineAsync(); foreach (var assembly in api.Entries.Select(e => e.AssemblyName).Distinct().OrderBy(n => n)) await writer.WriteLineAsync($"{assembly}.dll "); await writer.EndParagraphAsync(); await writer.WriteHeaderAsync(3, "Types"); await writer.BeginParagraphAsync(); await writer.WriteAsync("This index contains all types and members available to ingame scripting - with exception to the .NET types, because including those would have made the listing far too big. There will be links to Microsoft's own documentation for those types where appropriate."); await writer.EndParagraphAsync(); foreach (var blockGroup in api.Entries.Where(e => e.Member is Type).GroupBy(e => e.Member.GetNamespace()).OrderBy(g => g.Key)) { await writer.WriteHeaderAsync(3, blockGroup.Key); await writer.BeginParagraphAsync(); foreach (var type in blockGroup.OrderBy(e => e.ToString(ApiEntryStringFlags.ShortDisplayName | ApiEntryStringFlags.DeclaringTypes))) await writer.WriteLineAsync(MemberGenerator.LinkTo(WebUtility.HtmlEncode(type.ToString(ApiEntryStringFlags.ShortDisplayName | ApiEntryStringFlags.DeclaringTypes)), type)); await writer.EndParagraphAsync(); } await writer.FlushAsync(); } }
async Task GenerateNamespaceDoc(DirectoryInfo directory, IGrouping <string, ApiEntry> ns) { var fileName = Path.Combine(directory.FullName, ToMdFileName(ns.Key)); 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(1, ns.Key); await writer.BeginParagraphAsync(); foreach (var typeGroup in ns.GroupBy(e => e.DeclaringEntry ?? e).OrderBy(g => g.Key.FullName)) { await writer.WriteLineAsync(MarkdownInline.Strong(MemberGenerator.LinkTo(typeGroup.Key.Name, typeGroup.Key))); } await writer.EndParagraphAsync(); await writer.FlushAsync(); } }
async Task GeneratePage(ProgrammableBlockApi api, DirectoryInfo directory, IGrouping <string, ApiEntry> entries) { var fileName = Path.Combine(directory.FullName, entries.Key); using (var file = File.CreateText(fileName)) { var writer = new MarkdownWriter(file); var firstEntry = entries.First(); await writer.BeginParagraphAsync(); await writer.WriteAsync($"← {MarkdownInline.HRef("Index", "Api-Index")} ← {MarkdownInline.HRef("Namespace Index", "Namespace-Index")} ← {LinkTo(firstEntry.DeclaringEntry.ToString(ApiEntryStringFlags.ShortDisplayName), firstEntry.DeclaringEntry)}"); await writer.EndParagraphAsync(); foreach (var overload in entries) { await writer.WriteHeaderAsync(3, "Summary"); switch (overload.Member) { case ConstructorInfo constructorInfo: await WriteConstructor(api, overload, writer, constructorInfo); break; case FieldInfo fieldInfo: await WriteField(api, overload, writer, fieldInfo); break; case PropertyInfo propertyInfo: await WriteProperty(api, overload, writer, propertyInfo); break; case EventInfo eventInfo: await WriteEvent(api, overload, writer, eventInfo); break; case MethodInfo methodInfo: await WriteMethod(api, overload, writer, methodInfo); break; } } await writer.FlushAsync(); } }
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(); } }