com.datastax.spark.connector.util.RefBuilder.scala Maven / Gradle / Ivy
The newest version!
package com.datastax.spark.connector.util
import com.datastax.spark.connector.cql.{AuthConfFactory, CassandraConnectionFactory}
object RefBuilder {
val Header =
"""# Configuration Reference
|
|
""".stripMargin
val Footer = "\n"
val HtmlTableHeader =
"""
|Property Name Default Description """.stripMargin
val allConfigs = ConfigCheck.validStaticProperties
def getMarkDown(): String = {
val configBySection = allConfigs.groupBy(x => x.section)
val sections = configBySection.keys.toSeq.sorted
val markdown = for (section <- sections) yield {
val parameters = configBySection(section)
val paramTable = parameters.toList.sortBy(_.name).map { case parameter: ConfigParameter[_] =>
val default = parameter.default match {
case x: CassandraConnectionFactory => x.getClass.getSimpleName.stripSuffix("$")
case x: AuthConfFactory => x.getClass.getSimpleName.stripSuffix("$")
case x: Seq[_] => x.mkString(",")
case Some(defaultValue) => defaultValue
case None => None
case value => value
}
s"""
| ${parameter.name}
| $default
| ${parameter.description}
| """.stripMargin
}.mkString("\n")
s"""
|## $section
|$HtmlTableHeader
|$paramTable
|
""".stripMargin
}
Header + markdown.mkString("\n\n") + Footer
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy