Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ lazy val alleycatsLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)

// Optional accent color override for Cats Scaladoc (see issue #1835)
lazy val catsScaladocExternalCss = settingKey[Option[File]]("Optional custom CSS for Cats Scaladoc")

lazy val unidocs = project
.enablePlugins(TypelevelUnidocPlugin)
.settings(
Expand All @@ -252,7 +255,30 @@ lazy val unidocs = project
alleycatsLaws.jvm,
testkit.jvm
),
ScalaUnidoc / unidoc / scalacOptions ++= Seq("-groups", "-diagrams")
ScalaUnidoc / unidoc / scalacOptions ++= Seq("-groups", "-diagrams"),

catsScaladocExternalCss := {
val css = (ThisBuild / baseDirectory).value / "project" / "scaladoc-style.css"
if (css.exists()) Some(css) else None
},

ScalaUnidoc / unidoc := {
val docDir = (ScalaUnidoc / unidoc).value

catsScaladocExternalCss.value.foreach { cssFile =>
val templateCss = docDir / "lib" / "template.css"
if (templateCss.exists()) {
val currentContent = IO.read(templateCss)
// Idempotency check using the header comment from our CSS file
if (!currentContent.contains("Optional accent color override")) {
val customCss = IO.read(cssFile)
IO.append(templateCss, s"\n$customCss")
}
}
}

docDir
}
)

// bench is currently JVM-only
Expand Down
63 changes: 63 additions & 0 deletions project/scaladoc-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2015 Typelevel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* Optional accent color override for Cats Scaladoc.
* Added to address readability and visual distinction concerns (see issue #1835).
*/
/* Typelevel Cats custom Scaladoc styling */
/* Opt-in accent color override */

:root {
--cats-accent-color: #ea4b60;
--cats-accent-color-hover: #d42a3f;
}

/* Links */
#template a,
#template a:link,
#template a:visited {
color: var(--cats-accent-color);
}

#template a:hover,
#template a:active {
color: var(--cats-accent-color-hover);
}

/* Navigation / selected items */
#template .selected {
background-color: var(--cats-accent-color);
}

/* Focus states for accessibility */
#template a:focus {
outline-color: var(--cats-accent-color);
}

/* Member signatures */
#template .signature a {
color: var(--cats-accent-color);
}

#template .signature a:hover {
color: var(--cats-accent-color-hover);
}
Loading