66 lines
2.0 KiB
C#
Generated
66 lines
2.0 KiB
C#
Generated
// This file is auto-generated by alef. DO NOT EDIT.
|
|
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
|
#nullable enable
|
|
|
|
using System;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Kreuzberg;
|
|
/// <summary>
|
|
/// Content rendering mode for code extraction.
|
|
///
|
|
/// Controls how extracted code content is represented in the `content` field
|
|
/// of `ExtractionResult`.
|
|
/// </summary>
|
|
[JsonConverter(typeof(CodeContentModeJsonConverter))]
|
|
public enum CodeContentMode
|
|
{
|
|
/// <summary>
|
|
/// Use TSLP semantic chunks as content (default).
|
|
/// </summary>
|
|
[JsonPropertyName("chunks")]
|
|
Chunks,
|
|
/// <summary>
|
|
/// Use raw source code as content.
|
|
/// </summary>
|
|
[JsonPropertyName("raw")]
|
|
Raw,
|
|
/// <summary>
|
|
/// Emit function/class headings + docstrings (no code bodies).
|
|
/// </summary>
|
|
[JsonPropertyName("structure")]
|
|
Structure,
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Custom JSON converter for <see cref="CodeContentMode"/> that respects explicit variant names.
|
|
/// </summary>
|
|
internal sealed class CodeContentModeJsonConverter : JsonConverter<CodeContentMode>
|
|
{
|
|
public override CodeContentMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
var value = reader.GetString();
|
|
return value switch
|
|
{
|
|
"chunks" => CodeContentMode.Chunks,
|
|
"raw" => CodeContentMode.Raw,
|
|
"structure" => CodeContentMode.Structure,
|
|
_ => throw new JsonException($"Unknown CodeContentMode value: {value}")
|
|
};
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, CodeContentMode value, JsonSerializerOptions options)
|
|
{
|
|
var str = value switch
|
|
{
|
|
CodeContentMode.Chunks => "chunks",
|
|
CodeContentMode.Raw => "raw",
|
|
CodeContentMode.Structure => "structure",
|
|
_ => throw new JsonException($"Unknown CodeContentMode value: {value}")
|
|
};
|
|
writer.WriteStringValue(str);
|
|
}
|
|
}
|