Skip to content

Commit

Permalink
simplify generator and build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Roiocam committed Oct 12, 2023
1 parent a156cf2 commit 687d3f6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ lazy val docs = pekkoModule("docs")
PekkoParadoxPlugin,
NoPublish,
ParadoxBrowse,
ProjectIndexGenerator,
ScaladocNoVerificationOfDiagrams,
StreamOperatorsIndexGenerator,
Jdk9)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/paradox/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* [index-utilities](index-utilities.md)
* [common/other-modules](common/other-modules.md)
* [additional/deploy](additional/deploy.md)
* [project/index](project/index.md)
* [project/index](project/project-index.md)
* [classic](index-classic.md)

@@@
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
* [scala3](scala3.md)
* [downstream-upgrade-strategy](downstream-upgrade-strategy.md)
* [../common/may-change](../common/may-change.md)
* [ide] (../additional/ide.md)
* [lombok](immutable.md)
* [osgi](../additional/osgi.md)
* [../additional/ide](../additional/ide.md)
* [immutable](immutable.md)
* [../additional/osgi](../additional/osgi.md)
* [migration-guides](migration-guides.md)
* [rolling-update](rolling-update.md)
* [issue-tracking](issue-tracking.md)
* [licenses](licenses.md)
* [faq](../additional/faq.md)
* [books](../additional/books.md)
* [license-report](license-report.md)
* [../additional/faq](../additional/faq.md)
* [../additional/books](../additional/books.md)
* [examples](examples.md)
* [links](links.md)

Expand Down
19 changes: 10 additions & 9 deletions project/ProjectIndexGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object ProjectIndexGenerator extends AutoPlugin {
override val projectSettings: Seq[Setting[_]] = inConfig(Compile)(
Seq(
resourceGenerators +=
generateIndex(sourceDirectory, _ / "paradox" / "project" / "index.md")))
generateIndex(sourceDirectory, _ / "paradox" / "project" / "project-index.md")))

def generateIndex(dir: SettingKey[File], locate: File => File) = Def.task[Seq[File]] {
val file = locate(dir.value)
Expand All @@ -39,6 +39,7 @@ object ProjectIndexGenerator extends AutoPlugin {
"../common/may-change.md",
"../additional/ide.md",
"immutable.md",
"../additional/osgi.md",
"migration-guides.md",
"rolling-update.md",
"issue-tracking.md",
Expand All @@ -49,22 +50,22 @@ object ProjectIndexGenerator extends AutoPlugin {
"examples.md",
"links.md")

CliOptions.generateLicenseReportEnabled.ifTrue(
markdownFilesBeforeLicense ++ "license-report.md")
val markdownFiles = if (CliOptions.generateLicenseReportEnabled.get) {
markdownFilesBeforeLicense ++ Seq("license-report.md") ++ markdownFilesAfterLicense
} else {
markdownFilesBeforeLicense ++ markdownFilesAfterLicense
}

val content = s"""
|# Project Information
val content = s"""# Project Information
|
|@@toc { depth=2 }
|
|@@@ index
|
|${markdownFilesBeforeLicense.map(f => s"* [${f.replace(".md", "")}]($f)").mkString("\n")}
|${markdownFilesAfterLicense.map(f => s"* [${f.replace(".md", "")}]($f)").mkString("\n")}
|${markdownFiles.map(f => s"* [${f.replace(".md", "")}]($f)").mkString("\n")}
|
|@@@
|
""".stripMargin
|""".stripMargin

if (!file.exists || IO.read(file) != content) IO.write(file, content)
Seq(file)
Expand Down

0 comments on commit 687d3f6

Please sign in to comment.