Comment Extractor
object CommentExtractor
Extracts @Comment annotations from data class constructor parameters and builds a dot-separated path map of comment metadata.
This object recursively walks the primary constructor of a configuration data class, collecting any Comment annotations and mapping them to their fully qualified dot-notation paths (e.g., "database.connection.host").
Example:
data class DatabaseConfig(
@Comment(["The database host"], placement = CommentPlacement.INLINE)
val host: String = "localhost",
@Comment(["The database port"])
val port: Int = 5432
)
data class AppConfig(
val database: DatabaseConfig = DatabaseConfig()
)
val comments = CommentExtractor.extract(AppConfig::class)
// Returns:
// {
// "database.host" -> CommentData(["The database host"], INLINE),
// "database.port" -> CommentData(["The database port"], ABOVE)
// }Content copied to clipboard
Since
1.0