forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala#11273 from lampepfl/scala3doc/social-links2
Add configurable social links to scala3doc
- Loading branch information
Showing
18 changed files
with
129 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ package dotty.tools.scaladoc | |
|
||
object Main extends App { | ||
Searchbar() | ||
SocialLinks() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dotty.tools.scaladoc | ||
|
||
import org.scalajs.dom._ | ||
import org.scalajs.dom.ext._ | ||
|
||
class SocialLinks: | ||
def addIcon(elem: html.Element) = | ||
val img = document.createElement("img").asInstanceOf[html.Image] | ||
img.src = s"${Globals.pathToRoot}images/${elem.getAttribute("data-icon-path")}" | ||
elem.appendChild(img) | ||
|
||
document.querySelectorAll(".social-icon").collect { case e: html.Element => e }.foreach(addIcon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package dotty.tools.scaladoc | ||
|
||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import dotty.tools.dotc.core.Contexts.Context | ||
|
||
enum SocialLinks(val url: String, val whiteIconName: String, val blackIconName: String): | ||
case Github(ghUrl: String) extends SocialLinks(ghUrl, "github-icon-white.png", "github-icon-black.png") | ||
case Twitter(tUrl: String) extends SocialLinks(tUrl, "twitter-icon-white.png", "twitter-icon-black.png") | ||
case Gitter(gUrl: String) extends SocialLinks(gUrl, "gitter-icon-white.png", "gitter-icon-black.png") | ||
case Discord(dUrl: String) extends SocialLinks(dUrl, "discord-icon-white.png", "discord-icon-black.png") | ||
case Custom(cUrl: String, cWhiteIconName: String, cBlackIconName: String) extends SocialLinks(cUrl, cWhiteIconName, cBlackIconName) | ||
|
||
object SocialLinks: | ||
def parse(s: String): Either[String, SocialLinks] = | ||
val errorPrefix = s"Social links arg $s is invalid: " | ||
val splitted = s.split("::") | ||
splitted.head match { | ||
case "custom" if splitted.size == 4 => Right(Custom(splitted(1), splitted(2), splitted(3))) | ||
case "custom" => Left(errorPrefix + "For 'custom' arg expected three arguments: url, white icon name and black icon name") | ||
case "github" if splitted.size == 2 => Right(Github(splitted(1))) | ||
case "github" => Left(errorPrefix + "For 'github' arg expected one argument: url") | ||
case "twitter" if splitted.size == 2 => Right(Twitter(splitted(1))) | ||
case "twitter" => Left(errorPrefix + "For 'twitter' arg expected one argument: url") | ||
case "gitter" if splitted.size == 2 => Right(Gitter(splitted(1))) | ||
case "gitter" => Left(errorPrefix + "For 'gitter' arg expected one argument: url") | ||
case "discord" if splitted.size == 2 => Right(Discord(splitted(1))) | ||
case "discord" => Left(errorPrefix + "For 'discord' arg expected one argument: url") | ||
case _ => Left(errorPrefix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters