You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by md...@apache.org on 2024/02/14 22:38:32 UTC
(incubator-pekko-sbt-paradox) branch main updated: Revert "use spray-json for search index creation (#35)"
This is an automated email from the ASF dual-hosted git repository.
mdedetrich pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-sbt-paradox.git
The following commit(s) were added to refs/heads/main by this push:
new b80efcf Revert "use spray-json for search index creation (#35)"
b80efcf is described below
commit b80efcf2ecdc7d3c851742aedb39be2d36c417b9
Author: Matthew de Detrich <ma...@aiven.io>
AuthorDate: Thu Feb 15 09:28:40 2024 +1100
Revert "use spray-json for search index creation (#35)"
This reverts commit bca0a155
---
build.sbt | 2 -
.../org/apache/pekko/PekkoParadoxPlugin.scala | 6 --
.../main/scala/org/apache/pekko/SearchIndex.scala | 81 ----------------------
3 files changed, 89 deletions(-)
diff --git a/build.sbt b/build.sbt
index 2d39fc3..7f73934 100644
--- a/build.sbt
+++ b/build.sbt
@@ -73,8 +73,6 @@ lazy val pekkoPlugin = project
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
},
scriptedBufferLog := false,
- libraryDependencies ++= Seq(
- "io.spray" %% "spray-json" % "1.3.6"),
addSbtPlugin(
// When updating the sbt-paradox version,
// remember to also update project/plugins.sbt
diff --git a/plugin/src/main/scala/org/apache/pekko/PekkoParadoxPlugin.scala b/plugin/src/main/scala/org/apache/pekko/PekkoParadoxPlugin.scala
index 5849112..ed9f58f 100644
--- a/plugin/src/main/scala/org/apache/pekko/PekkoParadoxPlugin.scala
+++ b/plugin/src/main/scala/org/apache/pekko/PekkoParadoxPlugin.scala
@@ -70,12 +70,6 @@ object PekkoParadoxPlugin extends AutoPlugin {
def pekkoParadoxSettings(config: Configuration): Seq[Setting[_]] = pekkoParadoxGlobalSettings ++ inConfig(config)(Seq(
paradoxTheme / managedSourceDirectories +=
(Assets / WebKeys.webJarsDirectory).value / (Assets / WebKeys.webModulesLib).value / "paradox-material-theme",
- paradoxMaterialTheme / mappings := Def.taskDyn {
- if (paradoxProperties.value.contains("material.search"))
- Def.task(Seq(org.apache.pekko.SearchIndex.mapping(config).value))
- else
- Def.task(Seq.empty[(File, String)])
- }.value,
// we override some files from paradox-material-theme, so we must solve the ambiguity where to take those duplicates from
paradoxTheme / WebKeys.deduplicators += { (files: Seq[File]) =>
files.find(_.getPath.contains("pekko-theme-paradox"))
diff --git a/plugin/src/main/scala/org/apache/pekko/SearchIndex.scala b/plugin/src/main/scala/org/apache/pekko/SearchIndex.scala
deleted file mode 100644
index 86d564a..0000000
--- a/plugin/src/main/scala/org/apache/pekko/SearchIndex.scala
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copied and adapted from https://github.com/sbt/sbt-paradox-material-theme/blob/2d57fe0567ea9fe7e8de14faef4fa777841d505a/plugin/src/main/scala/io.github.jonas.paradox.material.theme/SearchIndex.scala
-
-package org.apache.pekko
-
-import scala.collection.JavaConverters._
-import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport.paradoxMarkdownToHtml
-import org.jsoup.Jsoup
-import org.jsoup.nodes.Element
-import sbt._
-import sbt.Keys._
-import spray.json._
-
-case class SearchIndex(docs: Seq[SearchIndex.Section])
-
-object SearchIndex {
- case class Section(location: String, title: String, text: String)
- implicit val encoder: JsonFormat[SearchIndex] = {
- import DefaultJsonProtocol._
-
- implicit val sectionFormat: JsonFormat[Section] =
- jsonFormat3(Section.apply _)
-
- jsonFormat1(SearchIndex.apply _)
- }
-
- val Headers = Set("h1", "h2", "h3", "h4", "h5", "h6")
-
- def generate(target: File, mappings: Seq[(File, String)]): File = {
- def readSections(mapping: (File, String)): Seq[Section] = {
- val (file, location) = mapping
- val doc = Jsoup.parse(file, "UTF-8")
- val docTitle = {
- val title = doc.select("head title").text()
- Option(title.lastIndexOf(" ยท "))
- .filter(_ > 0)
- .map(title.substring(0, _))
- .getOrElse(title)
- }
-
- def headerLocation(header: Element) =
- Option(header.select("a[name]").first()) match {
- case Some(anchor) => location + "#" + anchor.attr("name")
- case None => location
- }
-
- def processElement(section: Section, elements: List[Element]): Seq[Section] =
- elements match {
- case header :: tail if Headers(header.tagName) =>
- val location = headerLocation(header)
- val next = Section("/" + location, header.text, "")
- Vector(section) ++ processElement(next, tail)
- case element :: tail =>
- val text =
- if (section.text.isEmpty) element.text
- else section.text + "\n" + element.text
- processElement(section.copy(text = text.trim), tail)
- case Nil =>
- Vector(section)
- }
-
- val elements =
- doc.select("body .md-content__searchable").asScala.flatMap(_.children.asScala).toList
-
- processElement(Section("/" + location, docTitle, ""), elements)
- }
-
- val sections = mappings.flatMap(readSections).toList
- val searchIndex = SearchIndex(sections)
- val json = searchIndex.toJson.compactPrint
- val out = target / "search_index.json"
- IO.write(out, json)
- out
- }
-
- def mapping(config: Configuration) = Def.task {
- val index = generate(
- (config / target).value / "paradox-material-theme",
- (config / paradoxMarkdownToHtml).value)
- index -> "search/search_index.json"
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org