public class KlynDocComment extends Object
Structured parser and text extractor for KlynDoc documentation comments and Klyn declaration headers.
Provides line-comment stripping outside string literals, top-level comma splitting across nested generic/callable brackets, relative-indentation-preserving doc comment cleaning, summary sentence extraction (aware of backtick code spans), and @param, @return, @throws, and @example tag extraction.
import klyn.code.klyn raw = " *\n * Computes the sum of `a` and `b`.\n *\n * @param a First operand.\n * @return The sum." cleaned = KlynDocComment.cleanDocBlock(raw) assert KlynDocComment.firstSentence(cleaned) == "Computes the sum of `a` and `b`." assert KlynDocComment.singleTagValue(cleaned, "@return") == "The sum."
| Modifier and Type | Member | Description |
|---|---|---|
| public static | cleanDocBlock | Cleans an entire multi-line documentation block, preserving relative indentation inside fenced code blocks. |
| public static | cleanDocLine | Removes leading documentation comment delimiters (*) from a single line while preserving relative indentation for embedded code examples. |
| public static | countLeadingSpaces | Counts the number of leading ASCII space characters (' ') at the start of value. |
| public static | exampleText | Returns the example section of a KlynDoc comment (either explicit @example or trailing fenced code block after @ tags). |
| public static | firstSentence | Extracts the first summary sentence from a cleaned documentation comment. |
| public static | implicitExampleText | Extracts trailing fenced code blocks ( ) placed after @ tags when no explicit @example` tag is used. |
| public static | mainDescription | Extracts the main description body prior to the first @ tag line. |
| public static | paramDescription | Extracts the parameter description from a @param tag value. |
| public static | paramName | Extracts the parameter identifier from a @param tag value (stripping surrounding backticks). |
| public static | readIdentifier | Reads the leading identifier or qualified token from value up to the first whitespace or delimiter character (:, (, ), ,, =, <, >, [, ]). |
| public static | singleTagValue | Extracts the first value of a single-occurrence tag (such as @return). |
| public static | splitTopLevelCommaSeparated | Splits a comma-separated list at top level only, ignoring commas nested inside <...>, (...), [...], or {...}. |
| public static | stripLineComment | Strips a trailing # line comment from value while ignoring # characters inside string, character, or backtick literals. |
| public static | tagBlockValue | Extracts a multi-line block tag (such as @example), preserving fenced code blocks and indentation. |
| public static | tagValues | Extracts all values for a repeatable KlynDoc tag (such as @param or @throws), joining wrapped continuation lines. |