All Downloads are FREE. Search and download functionalities are using the official Maven repository.

grails.doc.internal.LegacyTocStrategy.groovy Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
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
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy