Skip to content

Commit cb97277

Browse files
committed
feat: add fileNameSuffix key
1 parent c6b30da commit cb97277

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/main/scala/dev/atedeg/Ubidoc.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ import net.steppschuh.markdowngenerator.table.Table
1313
import net.steppschuh.markdowngenerator.table.Table.Builder
1414

1515
object Ubidoc {
16-
private val fileNameSuffix: String = "UbiquitousLanguage"
1716
private val fileNameExtension: String = ".md"
1817
private val scaladocFileNameRegex = "[A-Z].*\\.html"
1918

20-
def apply(sourceDir: JFile, targetDir: JFile, htmlTags: Seq[String], tableHeaders: Seq[String]): Unit =
21-
Internals.ubiquitousScaladocTask(sourceDir, targetDir, htmlTags, tableHeaders)
19+
def apply(sourceDir: JFile, targetDir: JFile, htmlTags: Seq[String], tableHeaders: Seq[String], fileNameSuffix: String): Unit =
20+
Internals.ubiquitousScaladocTask(sourceDir, targetDir, htmlTags, tableHeaders, fileNameSuffix)
2221

2322
private object Internals {
2423

@@ -27,13 +26,14 @@ object Ubidoc {
2726
targetDir: JFile,
2827
htmlTags: Seq[String],
2928
tableHeaders: Seq[String],
29+
fileNameSuffix: String,
3030
): Unit = {
3131
if (htmlTags.length != tableHeaders.length)
3232
throw new IllegalArgumentException("htmlTags and tableHeaders must have the same number of elements")
3333
for {
3434
dir <- directoriesFromDir(sourceDir.toScala)
3535
rows = rowsFromFiles(dir, htmlTags)
36-
} generateMarkdownFile(dir.name, rows, targetDir.toScala, tableHeaders)
36+
} generateMarkdownFile(dir.name, rows, targetDir.toScala, tableHeaders, fileNameSuffix)
3737
}
3838

3939
def directoriesFromDir(sourceDir: File): Iterator[File] = ls(sourceDir) filter (_.isDirectory)
@@ -59,6 +59,7 @@ object Ubidoc {
5959
rows: Iterator[Seq[String]],
6060
targetDir: File,
6161
tableHeaders: Seq[String],
62+
fileNameSuffix: String,
6263
): Unit = {
6364
val table = addConceptsToTable(rows, tableHeaders)
6465
val file = targetDir / s"$dirName$fileNameSuffix$fileNameExtension"

src/main/scala/dev/atedeg/UbiquitousScaladocKeys.scala

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ trait UbiquitousScaladocKeys {
1313
val tableHeaders: SettingKey[Seq[String]] =
1414
settingKey[Seq[String]]("The headers of the markdown table")
1515

16+
val fileNameSuffix: SettingKey[String] =
17+
settingKey[String]("The suffix of the generated file's name")
18+
1619
val sourceHtmlDir: SettingKey[File] =
1720
settingKey[File]("The source directory to generate ubiquitous language markdown tables from")
1821

src/main/scala/dev/atedeg/UbiquitousScaladocPlugin.scala

+2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ object UbiquitousScaladocPlugin extends AutoPlugin {
1111
import autoImport.*
1212

1313
override lazy val buildSettings: Seq[Setting[_]] = Seq(
14+
ubidoc / fileNameSuffix := "UbiquitousLanguage",
1415
ubidoc := Ubidoc(
1516
(ubidoc / sourceHtmlDir).value,
1617
(ubidoc / targetMarkdownDir).value,
1718
(ubidoc / htmlTags).value,
1819
(ubidoc / tableHeaders).value,
20+
(ubidoc / fileNameSuffix).value,
1921
),
2022
)
2123

0 commit comments

Comments
 (0)