Skip to content

Commit 71a62ba

Browse files
feat(codegen): improve API for java users
1 parent c9d4a20 commit 71a62ba

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

  • codegen/src/main/kotlin/tools/samt/codegen

codegen/src/main/kotlin/tools/samt/codegen/Codegen.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,23 @@ import tools.samt.semantic.SemanticModel
1212
object Codegen {
1313
private val generators: MutableList<Generator> = mutableListOf()
1414

15+
/**
16+
* Register the [generator] to be used when generating code.
17+
* The generator is called when a user configures it within their `samt.yaml` configuration, where the generator is referenced by its [Generator.name].
18+
* Only generators registered here will be considered when calling [generate].
19+
*/
20+
@JvmStatic
1521
fun registerGenerator(generator: Generator) {
1622
generators += generator
1723
}
1824

1925
private val transports: MutableList<TransportConfigurationParser> = mutableListOf()
2026

27+
/**
28+
* Register the [parser] as a transport configuration, which will be used to parse the `transport` section of a SAMT provider.
29+
* Only transport configurations registered here will be considered when calling [generate].
30+
*/
31+
@JvmStatic
2132
fun registerTransportParser(parser: TransportConfigurationParser) {
2233
transports += parser
2334
}
@@ -43,6 +54,12 @@ object Codegen {
4354
}
4455
}
4556

57+
/**
58+
* Run the appropriate generator for the given [configuration], using the given [semanticModel].
59+
* To ensure binary compatibility, the types within the [semanticModel] will be mapped to their [tools.samt.api] equivalents.
60+
* @return a list of generated files
61+
*/
62+
@JvmStatic
4663
fun generate(
4764
semanticModel: SemanticModel,
4865
configuration: SamtGeneratorConfiguration,

0 commit comments

Comments
 (0)