From 687d3f6192412a18ccb60d788dee7952d8e35291 Mon Sep 17 00:00:00 2001 From: JingZhang Chen Date: Thu, 12 Oct 2023 17:37:21 +0800 Subject: [PATCH] simplify generator and build fixes --- build.sbt | 1 + docs/src/main/paradox/index.md | 2 +- .../project/{index.md => project-index.md} | 11 ++++++----- project/ProjectIndexGenerator.scala | 19 ++++++++++--------- 4 files changed, 18 insertions(+), 15 deletions(-) rename docs/src/main/paradox/project/{index.md => project-index.md} (65%) diff --git a/build.sbt b/build.sbt index b98261030f9..29b20e87bbb 100644 --- a/build.sbt +++ b/build.sbt @@ -264,6 +264,7 @@ lazy val docs = pekkoModule("docs") PekkoParadoxPlugin, NoPublish, ParadoxBrowse, + ProjectIndexGenerator, ScaladocNoVerificationOfDiagrams, StreamOperatorsIndexGenerator, Jdk9) diff --git a/docs/src/main/paradox/index.md b/docs/src/main/paradox/index.md index 9aa348384bb..1a37c703fdf 100644 --- a/docs/src/main/paradox/index.md +++ b/docs/src/main/paradox/index.md @@ -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) @@@ diff --git a/docs/src/main/paradox/project/index.md b/docs/src/main/paradox/project/project-index.md similarity index 65% rename from docs/src/main/paradox/project/index.md rename to docs/src/main/paradox/project/project-index.md index ce31d114e00..58574cde845 100644 --- a/docs/src/main/paradox/project/index.md +++ b/docs/src/main/paradox/project/project-index.md @@ -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) diff --git a/project/ProjectIndexGenerator.scala b/project/ProjectIndexGenerator.scala index 3bc3787cd5b..422b0e02660 100644 --- a/project/ProjectIndexGenerator.scala +++ b/project/ProjectIndexGenerator.scala @@ -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) @@ -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", @@ -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)