mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[examples] Add compilable code snippets (#7909)
This enables frc-docs to use RLIs for things that are currently in-line code blocks, and ensures they compile, which is important with the 2027 breaking changes coming. They are kept separate from the examples to ensure they don't polute the VSCode examples finder. Adds the Encoder snippets used in the frc-docs Encoder article as the first instance of this.
This commit is contained in:
@@ -103,6 +103,24 @@ task checkExamples(type: Task) {
|
||||
}
|
||||
}
|
||||
|
||||
task checkSnippets(type: Task) {
|
||||
doLast {
|
||||
def parsedJson = new groovy.json.JsonSlurper().parseText(snippetsFile.text)
|
||||
fileCheck(parsedJson, snippetsDirectory)
|
||||
parsedJson.each {
|
||||
assert it.name != null
|
||||
assert it.description != null
|
||||
assert it.tags != null
|
||||
assert it.tags.findAll { !tagList.contains(it) }.empty
|
||||
assert it.foldername != null
|
||||
assert it.gradlebase != null
|
||||
if (it.gradlebase == 'java') {
|
||||
assert it.mainclass != null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task checkCommands(type: Task) {
|
||||
doLast {
|
||||
def parsedJson = new groovy.json.JsonSlurper().parseText(commandFile.text)
|
||||
@@ -127,3 +145,4 @@ task checkCommands(type: Task) {
|
||||
check.dependsOn checkTemplates
|
||||
check.dependsOn checkExamples
|
||||
check.dependsOn checkCommands
|
||||
check.dependsOn checkSnippets
|
||||
|
||||
Reference in New Issue
Block a user