Skip to content

Commit

Permalink
fiixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVollmers committed May 6, 2024
1 parent bb083be commit 26cc519
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Doki.Abstractions/AssemblyDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public NamespaceDocumentation[] Namespaces

public AssemblyDocumentation()
{
Content = DocumentationContentType.Assembly;
ContentType = DocumentationContentType.Assembly;
}
}
2 changes: 1 addition & 1 deletion src/Doki.Abstractions/CodeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public sealed record CodeBlock : DocumentationObject

public CodeBlock()
{
Content = DocumentationContentType.CodeBlock;
ContentType = DocumentationContentType.CodeBlock;
}
}
4 changes: 2 additions & 2 deletions src/Doki.Abstractions/DocumentationObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract record DocumentationObject
/// <summary>
/// Gets the content type of the documentation object.
/// </summary>
public DocumentationContentType Content { get; protected set; }
public DocumentationContentType ContentType { get; protected init; }

protected DocumentationObject()
{
Expand All @@ -30,6 +30,6 @@ protected DocumentationObject(DocumentationObject obj)

Id = obj.Id ?? throw new ArgumentException("DocumentationObject.Id cannot be null.", nameof(obj));
Parent = obj.Parent;
Content = obj.Content;
ContentType = obj.ContentType;
}
}
2 changes: 1 addition & 1 deletion src/Doki.Abstractions/DocumentationObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class DocumentationObjectExtensions
var parent = obj.Parent;
while (parent != null)
{
if (parent is T t && (expectedContent == null || t.Content == expectedContent)) return t;
if (parent is T t && (expectedContent == null || t.ContentType == expectedContent)) return t;

parent = parent.Parent;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Doki.Abstractions/DocumentationRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public AssemblyDocumentation[] Assemblies
public DocumentationRoot()
{
Id = "root";
Content = DocumentationContentType.Root;
ContentType = DocumentationContentType.Root;
}
}
2 changes: 1 addition & 1 deletion src/Doki.Abstractions/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public sealed record Link : DocumentationObject

public Link()
{
Content = DocumentationContentType.Link;
ContentType = DocumentationContentType.Link;
}
}
2 changes: 1 addition & 1 deletion src/Doki.Abstractions/NamespaceDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public TypeDocumentation[] Types

public NamespaceDocumentation()
{
Content = DocumentationContentType.Namespace;
ContentType = DocumentationContentType.Namespace;
}
}
2 changes: 1 addition & 1 deletion src/Doki.Abstractions/TextContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public sealed record TextContent : DocumentationObject

public TextContent()
{
Content = DocumentationContentType.Text;
ContentType = DocumentationContentType.Text;
}
}
2 changes: 1 addition & 1 deletion src/Doki.Abstractions/XmlDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public DocumentationObject[] Contents

public XmlDocumentation()
{
Content = DocumentationContentType.Xml;
ContentType = DocumentationContentType.Xml;
}
}
6 changes: 3 additions & 3 deletions src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static void BuildAssemblyDocumentation(AssemblyDocumentation assemblyDoc
FileName = "{{assemblyDocumentation.FileName}}",
Version = "{{assemblyDocumentation.Version}}",
PackageId = "{{assemblyDocumentation.PackageId}}",
Items =
Namespaces =
[
""");

Expand All @@ -101,11 +101,11 @@ private static void BuildNamespaceDocumentation(NamespaceDocumentation namespace
var i = new string(' ', indent * 4);

content.AppendLine($$"""
{{i}}new ContentList
{{i}}new NamespaceDocumentation
{{i}}{
{{i}} Name = "{{namespaceDocumentation.Name}}",
{{i}} Description = "{{namespaceDocumentation.Description}}",
{{i}} Items =
{{i}} Types =
{{i}} [
""");

Expand Down
10 changes: 5 additions & 5 deletions src/Doki.Output.Markdown/InternalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public static Text BuildBreadcrumbs(this MarkdownBuilder builder, DocumentationO

public static Text BuildText(this MarkdownBuilder builder, DocumentationObject obj)
{
if (obj is not ContentList { Content: DocumentationContentType.XmlDocumentation } contentList)
if (obj is not XmlDocumentation { ContentType: DocumentationContentType.Xml } xmlDocumentation)
throw new ArgumentException("DocumentationObject must be a ContentList with XmlDocumentation content.",
nameof(obj));

var text = Text.Empty;

foreach (var item in contentList.Items)
foreach (var content in xmlDocumentation.Contents)
{
switch (item)
switch (content)
{
case TextContent textContent:
text.Append(textContent.Text);
Expand All @@ -59,7 +59,7 @@ public static Text BuildText(this MarkdownBuilder builder, DocumentationObject o
break;
default:
throw new NotSupportedException(
$"Unsupported {nameof(DocumentationObject)} type: {item.GetType().Name}");
$"Unsupported {nameof(DocumentationObject)} type: {content.GetType().Name}");
}
}

Expand All @@ -74,7 +74,7 @@ public static string BuildRelativePath(this MarkdownBuilder builder, Documentati

public static Element BuildLinkTo(this MarkdownBuilder builder, DocumentationObject to, string? text = null)
{
var indexFile = to.Content is DocumentationContentType.Assemblies or DocumentationContentType.Assembly
var indexFile = to.ContentType is DocumentationContentType.Root or DocumentationContentType.Assembly
or DocumentationContentType.Namespace;

var asText = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Doki.Output.Markdown/MarkdownOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private static IEnumerable<Element> BuildInheritanceChain(MarkdownBuilder markdo
if (!file.Directory!.Exists) file.Directory.Create();

var heading = new Heading(name, 1);
if (documentationObject.Content == DocumentationContentType.Namespace) heading.Append(" Namespace");
if (documentationObject.ContentType == DocumentationContentType.Namespace) heading.Append(" Namespace");

var markdown = new MarkdownBuilder(documentationObject.GetPath()).Add(heading);

Expand Down

0 comments on commit 26cc519

Please sign in to comment.