Skip to content
Kotlin extensions for doxia-sink-api
Kotlin Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
.mvn/wrapper
.travis
src
.editorconfig
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
doxia-sink-api-ktx.iml
mvnw
mvnw.cmd
pom.xml

README.md

Kotlin Extensions for Doxia

Build Status Maven Central codecov Known Vulnerabilities

Kotlin extensions for the Apache Doxia is a content generation framework. The main use of these extensions are for generating reports in custom Maven plugins.

This API is currently unstable, no compatibility guarantees are made between versions.

Writing Maven Report Content

This library provides a Kotlin DSL for writing content using Doxia Sink. The following is an extract from the ktlint Maven Plugin:

fun generatorReport(results: CheckResults) {
    sink {
        head {
            title {
                +title
            }
        }
        body {
            section(1) {
                title {
                    +title
                }
                paragraph {
                    +"${bundle["report.ktlint.ktlintlink"]} "
                    link("https://github.com/shyiko/ktlint") {
                        +"ktlint"
                    }
                    if (ktlintVersion != null) {
                        +" $ktlintVersion"
                    }
                    +"."
                }
            }

            section(1) {
                title {
                    +bundle["report.ktlint.summary"]
                }
                table {
                    tableRows {
                        tableRow {
                            tableHeaderCell {
                                +bundle["report.ktlint.files"]
                            }
                            tableHeaderCell {
                                +bundle["report.ktlint.errors"]
                            }
                        }
                        tableRow {
                            tableCell {
                                +"${results.fileCount}"
                            }
                            tableCell {
                                +"${results.errors.size}"
                            }
                        }
                    }
                }
            }

            val errorsByFile =
                results.errors.groupBy(FileLintError::file).toSortedMap()

            if (errorsByFile.isNotEmpty()) {

                section(1) {
                    title {
                        +bundle["report.ktlint.files"]
                    }
                    table {
                        tableRows {
                            tableRow {
                                tableHeaderCell {
                                    +bundle["report.ktlint.file"]
                                }
                                tableHeaderCell {
                                    +bundle["report.ktlint.errors"]
                                }
                            }

                            for ((file, errors) in errorsByFile) {
                                tableRow {
                                    tableCell {
                                        link("#${file.replace('/', '.')}") {
                                            +file
                                        }
                                    }
                                    tableCell {
                                        +"${errors.size}"
                                    }
                                }
                            }
                        }
                    }
                }

                section(1) {
                    title {
                        +bundle["report.ktlint.details"]
                    }
                    for ((file, errors) in errorsByFile) {
                        val sortedErrors = errors.sortedWith(
                            Comparator.comparingInt(FileLintError::line)
                                .thenComparingInt(FileLintError::col)
                                .thenComparing(FileLintError::ruleId)
                        )
                        section(2, id = file.replace('/', '.')) {
                            title {
                                +file
                            }
                        }
                        table {
                            tableRows {
                                tableRow {
                                    tableHeaderCell {
                                        +bundle["report.ktlint.detail"]
                                    }
                                    tableHeaderCell {
                                        +bundle["report.ktlint.ruleId"]
                                    }
                                    tableHeaderCell {
                                        +bundle["report.ktlint.line"]
                                    }
                                }
                                for (error in sortedErrors) {
                                    tableRow {
                                        tableCell {
                                            +error.detail
                                        }
                                        tableCell {
                                            +error.ruleId
                                        }
                                        tableCell {
                                            +"${error.line}"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

License

This software is licensed under the terms in the file named "LICENSE" in the root directory of this project. This project has dependencies that are under different licenses.

Author Information

John Freeman

GantSign Ltd. Company No. 06109112 (registered in England)

You can’t perform that action at this time.