Skip to content

Commit

Permalink
Documentation Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamboree committed Mar 8, 2024
1 parent e0f8780 commit f63bd43
Show file tree
Hide file tree
Showing 3 changed files with 886 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/DarkConfig/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,34 @@ public ConfigUnionInlineAttribute(string key) {
/// If the field annotated with inline then we will look for it's properties in the same doc as the parent
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class ConfigInlineAttribute : Attribute { }

/// Name of this type in documentation, for generic types "<0>" indicates the first template parameter, "<1>" the second, and so on
[AttributeUsage(AttributeTargets.Class)]
public class ConfigDocumentationNameAttribute : Attribute {
public readonly string Value;

public ConfigDocumentationNameAttribute(string value) {
Value = value;
}
}

/// Description of this type or field
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property, Inherited = false)]
public class ConfigDocumentationDescriptionAttribute : Attribute {
public readonly string Value;

public ConfigDocumentationDescriptionAttribute(string value) {
Value = value;
}
}

/// Example yaml of this type
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
public class ConfigDocumentationExampleAttribute : Attribute {
public readonly string Value;

public ConfigDocumentationExampleAttribute(string value) {
Value = value;
}
}
}
9 changes: 9 additions & 0 deletions src/DarkConfig/Configs.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using DarkConfig.Internal;
using System;
using System.Collections;
using System.IO;
Expand Down Expand Up @@ -651,5 +652,13 @@ static void DefaultLogCallback(LogVerbosity verbosity, string message) {
Console.Error.WriteLine(message);
}
}

public static void Document(string documentationRoot, params Type[] rootTypes) {
DocumentationGenerator.Document(documentationRoot, new ReflectionCache(), rootTypes);
}

public static string GetDocumentationPath(string documentationRoot, Type type) {
return DocumentationGenerator.GetDocumentationPath(documentationRoot, type);
}
}
}
Loading

0 comments on commit f63bd43

Please sign in to comment.