Add orx readme generator, update readmes

This commit is contained in:
Abe Pazos
2020-05-18 11:54:18 +02:00
committed by Edwin Jakobs
parent 274af989c3
commit 540e8b0498
39 changed files with 206 additions and 84 deletions

View File

@@ -58,7 +58,6 @@ allprojects {
group 'org.openrndr.extra'
repositories {
mavenCentral()
jcenter()
@@ -107,6 +106,69 @@ allprojects {
}
}
task buildMainReadme {
doFirst {
def subProjects = project.subprojects
//.findAll { !it.name.contains("kinect-common") && !it.name.contains
// ("kinect-v1-") }
// Load README.md and find [begin, end] section to replace
def mainReadme = file("README.md")
def lines = mainReadme.readLines()
def begin = lines.findIndexOf { it == "<!-- __orxListBegin__ -->" }
def end = lines.findIndexOf { it == "<!-- __orxListEnd__ -->" }
if (begin == -1 || end == -1) {
println("Comments for orx list generation not found in README.md!")
return
}
def header = lines.subList(0, begin + 1)
def footer = lines.subList(end, lines.size())
def newReadme = []
for (line in header) {
newReadme.add(line)
}
newReadme.add("| name | description |")
// Search for the description at the top of the readme.
// Skip the hash character from the headline, then start
// on the next line and continue until the next empty line.
// Don't fall into Windows line breaks.
def descriptionRx = ~/(?s)\#.*?\n(.+?)\n\r?\n/
// Note: the readme needs an empty line after the description
// Build orx list
for (sub in subProjects) {
def orxReadmeFile = sub.file("README.md")
if (orxReadmeFile.exists()) {
def orxReadmeText = orxReadmeFile.getText()
orxReadmeText.find(descriptionRx) {
description ->
def trimmedDescription = description[1].strip()
.replace("\n", " ").replace("\r", "")
newReadme.add("| [`${sub.name}`](${sub.name}/README.md) " +
"| $trimmedDescription |")
}
} else {
println("${sub.name}/README.md not found!")
}
}
for (line in footer) {
newReadme.add(line)
}
// Write result
if (mainReadme.exists()) {
mainReadme.delete()
}
mainReadme.write(newReadme.join("\n"))
}
}
task collectScreenshots {
doFirst {
def demoProjects = project.subprojects.findAll { it.sourceSets.hasProperty("demo") }