Skip to content

Commit 9713aad

Browse files
committed
Add project-url to settings for dottydoc
1 parent c625f86 commit 9713aad

File tree

8 files changed

+50
-10
lines changed

8 files changed

+50
-10
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,12 @@ class ScalaSettings extends Settings.SettingGroup {
130130
""
131131
)
132132

133+
val projectUrl = StringSetting (
134+
"-project-url",
135+
"project repository homepage",
136+
"The source repository of your project",
137+
""
138+
)
139+
133140
val wikiSyntax = BooleanSetting("-Xwiki-syntax", "Retains the Scala2 behavior of using Wiki Syntax in Scaladoc")
134141
}

doc-tool/resources/_includes/toolbar.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,14 @@
66
<h1 id="project-name">{{ site.project }} Documentation</h1>
77
<h2 id="project-version">{{ site.version }}</h2>
88
</div>
9+
10+
{% if site.projectUrl %}
11+
<a title="Project repository" id="github-link" href="{{ site.projectUrl }}">
12+
{% if site.projectUrl contains "github" %}
13+
<i class="fa fa-github" aria-hidden="true"></i>
14+
{% else %}
15+
<i class="fa fa-code" aria-hidden="true"></i>
16+
{% endif %}
17+
</a>
18+
{% endif %}
919
</div>

doc-tool/resources/_layouts/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<link
2121
rel="stylesheet"
22-
href="{{ site.baseurl }}/css/font-awesome.min.css"
22+
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
2323
>
2424

2525
<link

doc-tool/resources/css/toolbar.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@ div#toolbar > div#project-details > h2#project-version {
5454
margin-left: 1px;
5555
}
5656

57+
div#toolbar > a#github-link {
58+
color: #fff;
59+
position: absolute;
60+
top: 7px;
61+
right: 15px;
62+
font-size: 40px;
63+
}

doc-tool/src/dotty/tools/dottydoc/DocDriver.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ class DocDriver extends Driver {
4646
val siteRoot = new java.io.File(ctx.settings.siteRoot.value)
4747
val projectName = ctx.settings.projectName.value
4848
val projectVersion = ctx.settings.projectVersion.value
49+
val projectUrl = ctx.settings.projectUrl.value
4950

5051
if (!siteRoot.exists || !siteRoot.isDirectory)
5152
ctx.error(s"Site root does not exist: $siteRoot")
5253
else {
53-
Site(siteRoot, projectName, projectVersion, ctx.docbase.packages)
54+
Site(siteRoot, projectName, projectVersion, projectUrl, ctx.docbase.packages)
5455
.generateApiDocs()
5556
.copyStaticFiles()
5657
.generateHtmlFiles()

doc-tool/src/dotty/tools/dottydoc/staticsite/DefaultParams.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ case class DefaultParams(
3535
"baseurl" -> site.baseurl,
3636
"posts" -> site.posts.map(_.toMap),
3737
"project" -> site.projectTitle,
38-
"version" -> site.projectVersion
38+
"version" -> site.projectVersion,
39+
"projectUrl" -> site.projectUrl
3940
).asJava,
4041

4142
"sidebar" -> sidebar.titles.asJava
@@ -50,7 +51,8 @@ case class DefaultParams(
5051
}
5152

5253
def withPosts(posts: Array[BlogPost]): DefaultParams =
53-
copy(site = SiteInfo(site.baseurl, site.projectTitle, site.projectVersion, posts))
54+
copy(site = SiteInfo(
55+
site.baseurl, site.projectTitle, site.projectVersion, site.projectUrl, posts))
5456

5557
def withUrl(url: String): DefaultParams =
5658
copy(page = PageInfo(url))
@@ -68,6 +70,7 @@ case class SiteInfo(
6870
baseurl: String,
6971
projectTitle: String,
7072
projectVersion: String,
73+
projectUrl: String,
7174
posts: Array[BlogPost]
7275
)
7376

doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ import io.{ AbstractFile, VirtualFile, File }
2828
import scala.collection.mutable.ArrayBuffer
2929
import util.syntax._
3030

31-
case class Site(val root: JFile, val projectTitle: String, val projectVersion: String, val documentation: Map[String, Package]) extends ResourceFinder {
31+
case class Site(
32+
val root: JFile,
33+
val projectTitle: String,
34+
val projectVersion: String,
35+
val projectUrl: String,
36+
val documentation: Map[String, Package]
37+
) extends ResourceFinder {
3238
/** Documentation serialized to java maps */
3339
private val docs: JList[_] = {
3440
import model.JavaConverters._
@@ -157,7 +163,11 @@ case class Site(val root: JFile, val projectTitle: String, val projectVersion: S
157163
"../" * (assetLen - rootLen - 1 + additionalDepth) + "."
158164
}
159165

160-
DefaultParams(docs, documentation, PageInfo(pathFromRoot), SiteInfo(baseUrl, projectTitle, projectVersion, Array()), sidebar)
166+
DefaultParams(
167+
docs, documentation, PageInfo(pathFromRoot),
168+
SiteInfo(baseUrl, projectTitle, projectVersion, projectUrl, Array()),
169+
sidebar
170+
)
161171
}
162172

163173
/* Creates output directories if allowed */

project/Build.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ object Build {
2727
val scalacVersion = "2.11.11" // Do not rename, this is grepped in bin/common.
2828

2929
val dottyOrganization = "ch.epfl.lamp"
30+
val dottyGithubUrl = "https://github.com/lampepfl/dotty"
3031
val dottyVersion = {
3132
val baseVersion = "0.1.1"
3233
val isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
@@ -86,7 +87,7 @@ object Build {
8687
organization := dottyOrganization,
8788
organizationName := "LAMP/EPFL",
8889
organizationHomepage := Some(url("http://lamp.epfl.ch")),
89-
homepage := Some(url("https://github.com/lampepfl/dotty")),
90+
homepage := Some(url(dottyGithubUrl)),
9091

9192
scalacOptions ++= Seq(
9293
"-feature",
@@ -283,6 +284,7 @@ object Build {
283284
"-siteroot", "docs",
284285
"-project", "Dotty",
285286
"-project-version", dottyVersion,
287+
"-project-url", dottyGithubUrl,
286288
"-classpath", s"$dottyLib:$dottyInterfaces:$otherDeps"
287289
)
288290
(runMain in Compile).toTask(
@@ -887,12 +889,12 @@ object DottyInjectedPlugin extends AutoPlugin {
887889
Some("releases" at nexus + "service/local/staging/deploy/maven2")
888890
},
889891
publishArtifact in Test := false,
890-
homepage := Some(url("https://github.com/lampepfl/dotty")),
892+
homepage := Some(url(dottyGithubUrl)),
891893
licenses += ("BSD New",
892-
url("https://github.com/lampepfl/dotty/blob/master/LICENSE.md")),
894+
url("$dottyGithubUrl/blob/master/LICENSE.md")),
893895
scmInfo := Some(
894896
ScmInfo(
895-
url("https://github.com/lampepfl/dotty"),
897+
url(dottyGithubUrl),
896898
"scm:git:[email protected]:lampepfl/dotty.git"
897899
)
898900
),

0 commit comments

Comments
 (0)