grails.doc.internal.LegacyTocStrategy.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grails-docs Show documentation
Show all versions of grails-docs Show documentation
Grails Web Application Framework
package grails.doc.internal
class LegacyTocStrategy {
def generateToc(files) {
// Compares two gdoc filenames based on the section number in the
// form x.y.z...
def sectionNumberComparator = [
compare: {o1, o2 ->
def idx1 = o1.name[0..o1.name.indexOf(' ') - 1]
def idx2 = o2.name[0..o2.name.indexOf(' ') - 1]
def nums1 = idx1.split(/\./).findAll { it.trim() != ''}*.toInteger()
def nums2 = idx2.split(/\./).findAll { it.trim() != ''}*.toInteger()
// pad out with zeros to ensure accurate comparison
while (nums1.size() < nums2.size()) {
nums1 << 0
}
while (nums2.size() < nums1.size()) {
nums2 << 0
}
def result = 0
for (i in 0.. node.children[-1] }
section.parent = parent
parent.children << section
}
return book
}
}