Skip to content

Commit d74ed77

Browse files
authored
Show data tables in tabs, and examples before usage (#187)
1 parent 86ec459 commit d74ed77

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt

+37-20
Original file line numberDiff line numberDiff line change
@@ -1131,12 +1131,11 @@ import TabItem from '@theme/TabItem';
11311131

11321132
writeSourceLinks(recipeDescriptor, origin)
11331133
writeOptions(recipeDescriptor)
1134-
writeLicense(origin)
11351134
writeDefinition(recipeDescriptor, origin)
1135+
writeExamples(recipeDescriptor)
11361136
writeUsage(recipeDescriptor, origin)
11371137
writeModerneLink(recipeDescriptor)
11381138
writeDataTables(recipeDescriptor)
1139-
writeExamples(recipeDescriptor)
11401139
writeContributors(recipeDescriptor)
11411140
}
11421141
}
@@ -1199,6 +1198,25 @@ import TabItem from '@theme/TabItem';
11991198
)
12001199
}
12011200
}
1201+
1202+
writeLicense(origin)
1203+
}
1204+
1205+
private fun BufferedWriter.writeLicense(origin: RecipeOrigin) {
1206+
val licenseText = when (origin.license) {
1207+
Licenses.Unknown -> "The license for this recipe is unknown."
1208+
Licenses.Apache2, Licenses.Proprietary, Licenses.MSAL -> "This recipe is available under the ${origin.license.markdown()}."
1209+
else -> "This recipe is available under the ${origin.license.markdown()} License, as defined by the recipe authors."
1210+
}
1211+
1212+
//language=markdown
1213+
writeln(
1214+
"""
1215+
1216+
$licenseText
1217+
1218+
""".trimIndent()
1219+
)
12021220
}
12031221

12041222
private fun BufferedWriter.writeOptions(recipeDescriptor: RecipeDescriptor) {
@@ -1263,38 +1281,23 @@ import TabItem from '@theme/TabItem';
12631281
}
12641282
}
12651283

1266-
private fun BufferedWriter.writeLicense(origin: RecipeOrigin) {
1267-
val licenseText = when (origin.license) {
1268-
Licenses.Unknown -> "The license for this recipe is unknown."
1269-
Licenses.Apache2, Licenses.Proprietary, Licenses.MSAL -> "This recipe is available under the ${origin.license.markdown()}."
1270-
else -> "This recipe is available under the ${origin.license.markdown()} License, as defined by the recipe authors."
1271-
}
1272-
1273-
//language=markdown
1274-
writeln(
1275-
"""
1276-
## License
1277-
1278-
$licenseText
1279-
1280-
""".trimIndent()
1281-
)
1282-
}
1283-
12841284
private fun BufferedWriter.writeDataTables(recipeDescriptor: RecipeDescriptor) {
12851285
if (recipeDescriptor.dataTables.isNotEmpty()) {
12861286
writeln(
12871287
//language=markdown
12881288
"""
12891289
## Data Tables
12901290
1291+
<Tabs groupId="data-tables">
12911292
""".trimIndent()
12921293
)
12931294

12941295
for (dataTable in recipeDescriptor.dataTables) {
12951296
//language=markdown
12961297
writeln(
12971298
"""
1299+
<TabItem value="${dataTable.name}" label="${dataTable.name.substringAfterLast('.')}">
1300+
12981301
### ${dataTable.displayName}
12991302
**${dataTable.name}**
13001303
@@ -1314,8 +1317,22 @@ import TabItem from '@theme/TabItem';
13141317
)
13151318
}
13161319

1320+
writeln(
1321+
"""
1322+
1323+
</TabItem>
1324+
""".trimIndent()
1325+
)
1326+
13171327
newLine()
13181328
}
1329+
1330+
writeln(
1331+
//language=markdown
1332+
"""
1333+
</Tabs>
1334+
""".trimIndent()
1335+
)
13191336
}
13201337
}
13211338

0 commit comments

Comments
 (0)