Skip to content

Commit ab3bc41

Browse files
authored
Merge pull request #11183 from romanowski/scala3doc/html-rendering
Migrate away from dokka: Part 1
2 parents c49d6c0 + 81f6a24 commit ab3bc41

File tree

113 files changed

+1918
-3731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1918
-3731
lines changed

project/Build.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,19 +1544,13 @@ object Build {
15441544
def joinProducts(products: Seq[java.io.File]): String =
15451545
products.iterator.map(_.getAbsolutePath.toString).mkString(" ")
15461546

1547-
val dokkaVersion = "1.4.10.2"
15481547
val flexmarkVersion = "0.42.12"
15491548

15501549
project.settings(commonBootstrappedSettings).
15511550
dependsOn(`scala3-compiler-bootstrapped`).
15521551
dependsOn(`scala3-tasty-inspector`).
15531552
settings(
1554-
// Needed to download dokka and its dependencies
1555-
resolvers += Resolver.jcenterRepo,
15561553
libraryDependencies ++= Seq(
1557-
"org.jetbrains.dokka" % "dokka-core" % dokkaVersion,
1558-
"org.jetbrains.dokka" % "dokka-base" % dokkaVersion,
1559-
"org.jetbrains.kotlinx" % "kotlinx-html-jvm" % "0.7.2", // Needs update when dokka version changes
15601554
"com.vladsch.flexmark" % "flexmark" % flexmarkVersion,
15611555
"com.vladsch.flexmark" % "flexmark-html-parser" % flexmarkVersion,
15621556
"com.vladsch.flexmark" % "flexmark-ext-anchorlink" % flexmarkVersion,
@@ -1569,18 +1563,14 @@ object Build {
15691563
"com.vladsch.flexmark" % "flexmark-ext-yaml-front-matter" % flexmarkVersion,
15701564
"nl.big-o" % "liqp" % "0.6.7",
15711565
"org.jsoup" % "jsoup" % "1.13.1", // Needed to process .html files for static site
1572-
"args4j" % "args4j" % "2.33",
15731566
Dependencies.`jackson-dataformat-yaml`,
15741567

1575-
"org.jetbrains.dokka" % "dokka-test-api" % dokkaVersion % "test",
15761568
"com.novocode" % "junit-interface" % "0.11" % "test",
15771569
),
15781570
Test / test := (Test / test).dependsOn(compile.in(Compile).in(`scala3doc-testcases`)).value,
15791571
testcasesOutputDir.in(Test) := joinProducts((`scala3doc-testcases`/Compile/products).value),
15801572
testcasesSourceRoot.in(Test) := (baseDirectory.in(`scala3doc-testcases`).value / "src").getAbsolutePath.toString,
15811573
Compile / mainClass := Some("dotty.dokka.Main"),
1582-
// There is a bug in dokka that prevents parallel tests withing the same jvm
1583-
fork.in(test) := true,
15841574
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
15851575
generateSelfDocumentation := Def.taskDyn {
15861576
generateDocumentation(
@@ -1665,8 +1655,6 @@ object Build {
16651655
BuildInfoPlugin.buildInfoScopedSettings(Test),
16661656
BuildInfoPlugin.buildInfoScopedSettings(Compile),
16671657
BuildInfoPlugin.buildInfoDefaultSettings,
1668-
// Uncomment to debug dokka processing (require to run debug in listen mode on 5005 port)
1669-
// javaOptions.in(run) += "-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y"
16701658
)
16711659
}
16721660

scala3doc-js/src/searchbar/PageEntry.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import scala.scalajs.js
44

55
@js.native
66
trait PageEntryJS extends js.Object {
7-
val name: String = js.native
8-
val description: String = js.native
9-
val location: String = js.native
10-
val searchKeys: js.Array[String] = js.native
7+
val n: String = js.native
8+
val t: String = js.native
9+
val d: String = js.native
10+
val l: String = js.native
1111
}
1212

1313
case class PageEntry(
@@ -23,10 +23,10 @@ object PageEntry {
2323
s.headOption.map(firstLetter => firstLetter.toString ++ s.tail.filter(_.isUpper))
2424

2525
def apply(jsObj: PageEntryJS): PageEntry = PageEntry(
26-
jsObj.name,
27-
jsObj.description,
28-
jsObj.location,
29-
jsObj.searchKeys.head.toLowerCase,
30-
createAcronym(jsObj.searchKeys.head)
26+
jsObj.t,
27+
jsObj.d,
28+
jsObj.l,
29+
jsObj.n.toLowerCase,
30+
createAcronym(jsObj.n)
3131
)
3232
}

scala3doc-js/src/searchbar/engine/SearchbarEngine.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package dotty.dokka
22

33
import math.Ordering.Implicits.seqOrdering
44

5-
class SearchbarEngine(pages: List[PageEntry]) {
6-
def query(query: List[Matchers]): List[PageEntry] = {
5+
class SearchbarEngine(pages: List[PageEntry]):
6+
def query(query: List[Matchers]): List[PageEntry] =
77
pages
88
.map( page =>
99
page -> query.map(matcher => matcher(page))
@@ -17,5 +17,3 @@ class SearchbarEngine(pages: List[PageEntry]) {
1717
.map {
1818
case (page, matchResults) => page
1919
}
20-
}
21-
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package tests
2+
3+
package commonlinks:
4+
class SomeOtherPackage:
5+
def method = 123
6+
7+
object SomeOtherPackage
8+
9+
enum SomeOtherEnum:
10+
case A
11+
case B
12+
13+
14+
15+
package wikilinks:
16+
class SomeClass:
17+
def method = 123
18+
19+
/**
20+
* [[AnNonExisitingObject]]
21+
* [[SomeClass!.ala]]
22+
* @syntax wiki
23+
*/
24+
class BrokenLinks
25+
26+
/**
27+
* [[tests.commonlinks.SomeOtherPackage]]
28+
* @syntax wiki
29+
*/
30+
class OtherPackageLink
31+
32+
/**
33+
* [[tests.commonlinks.SomeOtherPackage!method]]
34+
* [[tests.commonlinks.SomeOtherEnum!A]]
35+
* @syntax wiki
36+
*/
37+
class OtherPackageMembers
38+
/**
39+
* [[SomeClass]]
40+
* @syntax wiki
41+
*/
42+
class SamePackageLink
43+
44+
/**
45+
* [[SomeClass.method]]
46+
* @syntax wiki
47+
*/
48+
class SamePackageMembers
49+
50+
// It should be exact copy of wikilinks
51+
package mdlinks:
52+
class SomeClass:
53+
def method = 123
54+
55+
/**
56+
* [[AnNonExisitingObject]]
57+
* [[SomeClass!.ala]]
58+
*/
59+
class BrokenLinks
60+
61+
/**
62+
* [[tests.commonlinks.SomeOtherPackage]]
63+
*/
64+
class OtherPackageLink
65+
66+
/**
67+
* [[tests.commonlinks.SomeOtherPackage!method]]
68+
* [[tests.commonlinks.SomeOtherEnum!A]]
69+
* @syntax wiki
70+
*/
71+
class OtherPackageMembers
72+
/**
73+
* [[SomeClass]]
74+
*/
75+
class SamePackageLink
76+
77+
/**
78+
* [[SomeClass.method]]
79+
*/
80+
class SamePackageMembers
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package tests.site
2+
3+
4+
package some.other:
5+
class SomeOtherPackage
6+
7+
class SomeClass:
8+
def method(a: Int): Int
9+
= 123 + a
10+
val field =
11+
123
12+
13+
/**
14+
* Broken link, that should result a warning not break compilation
15+
* [[tests.links.AnObject]]
16+
17+
*/
18+
class BrokenLink:
19+
def verifyIfLinksTestIsGenerated(b: Int): Int
20+
= 123
21+
22+
/**
23+
* [[tests.links.some.other.SomeOtherPackage]]
24+
*/
25+
class OtherPackageLink
26+
27+
/**
28+
* [[tests.links.SomeClass]]
29+
*/
30+
class SamePackageLink
31+
32+
33+
/**
34+
* Broken link, that should result a warning not break compilation
35+
* [[tests.links.AnObject]]
36+
37+
*/
38+
class BrokenLinkWiki:
39+
def verifyIfLinksTestIsGenerated(b: Int): Int
40+
= 123
41+
42+
/**
43+
* [[tests.links.some.other.SomeOtherPackage]]
44+
* @syntax wiki
45+
*/
46+
class OtherPackageLinkWiki
47+
48+
/**
49+
* [[tests.links.SomeClass]]
50+
* @syntax wiki
51+
*/
52+
class SamePackageLinkWiki

scala3doc/README.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
Scala3doc (name subject to change) is the documentation tool for
44
[Dotty](https://github.com/lampepfl/dotty), which is scheduled to become
5-
Scala 3. It's based on [Dokka](https://github.com/Kotlin/dokka), the
6-
documentation tool for Kotlin. It uses the TastyInspector to access definitions,
5+
Scala 3. It uses the TastyInspector to access definitions,
76
which is an officially supported way to access Dotty's perspective of a
87
codebase.
98

@@ -48,9 +47,7 @@ CLI command for running our tool is in form: `sbt main -n <name> -o <output> -t
4847
- `<classpath>`: classpath that was used to generate tasty files
4948
- `<sources>`: links to source files of module that are used to link symbols on pages to their source file. They need to be supplied in form:
5049
`local_dir=remote_dir#line_suffix` e.g. `src/main/scala=https://github.com/lampepfl/scala3doc/tree/master/src/main/scala#L`
51-
- `<documentation>`: directory of static documentation that you would like to render with API documentation. This feature is provided by dokka-site plugin:
52-
- [GitHub](https://github.com/VirtusLab/dokka-site)
53-
- [Documentation](https://virtuslab.github.io/dokka-site/index.html)
50+
- `<documentation>`: directory of static documentation that you would like to render with API documentation.
5451

5552
## Developing
5653

@@ -164,16 +161,6 @@ Make sure all the tests pass (simply run `sbt test` to verify that).
164161

165162
## FAQ
166163

167-
### Why depend on Dokka?
168-
169-
We have two primary reasons for depending on Dokka. One of them is division of
170-
labour - Dokka already has a team of maintainers, and it supports an excellent
171-
API which already allowed us to quite easily generate documentation with it. By
172-
depending on Dokka, we will be able to share a large portion of the maintenance
173-
burden. The second reason is very pragmatic - on our own, it'd be difficult for
174-
us to reach even feature parity with Scaladoc, simply because of workforce
175-
constraints. Meanwhile, Dokka maintainers from VirtusLab reached out to us with
176-
an offer of help, which we were happy to take.
177164

178165
### Why use TASTy?
179166

scala3doc/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin

Lines changed: 0 additions & 1 deletion
This file was deleted.

scala3doc/resources/dotty_res/images/scala_logo.svg

Lines changed: 0 additions & 32 deletions
This file was deleted.

scala3doc/src/dotty/dokka/DRI.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dotty.dokka
2+
3+
import java.nio.file.Path
4+
5+
val staticFileSymbolUUID = "___staticFile___"
6+
7+
val topLevelDri = DRI("/")
8+
9+
// we may need target...
10+
final case class DRI(
11+
location: String,
12+
anchor: String = "",
13+
origin: String = "",
14+
symbolUUID: String = ""
15+
):
16+
def withNoOrigin = copy(origin = "")
17+
18+
def isStaticFile = symbolUUID == staticFileSymbolUUID
19+
20+
def asFileLocation: String = location.replace(".","/")
21+
22+
object DRI:
23+
def forPath(path: Path) =
24+
DRI(location = path.toString, symbolUUID = staticFileSymbolUUID)

0 commit comments

Comments
 (0)