Skip to content

Commit 4e337f2

Browse files
committed
Extend Flexmark with doc strings
Remove rest of dokka usages
1 parent 6f39e75 commit 4e337f2

34 files changed

+595
-1584
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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.SomeOtherPackage#]]
35+
* [[tests.commonlinks.SomeOtherEnum!A]]
36+
* @syntax wiki
37+
*/
38+
class OtherPackageMembers
39+
/**
40+
* [[SomeClass]]
41+
* @syntax wiki
42+
*/
43+
class SamePackageLink
44+
45+
/**
46+
* [[SomeClass.method]]
47+
* @syntax wiki
48+
*/
49+
class SamePackageMembers
50+
51+
// It should be exact copy of wikilinks
52+
package mdlinks:
53+
class SomeClass:
54+
def method = 123
55+
56+
/**
57+
* [[AnNonExisitingObject]]
58+
* [[SomeClass!.ala]]
59+
*/
60+
class BrokenLinks
61+
62+
/**
63+
* [[tests.commonlinks.SomeOtherPackage]]
64+
*/
65+
class OtherPackageLink
66+
67+
/**
68+
* [[tests.commonlinks.SomeOtherPackage!method]]
69+
* [[tests.commonlinks.SomeOtherPackage#]]
70+
* [[tests.commonlinks.SomeOtherEnum!A]]
71+
* @syntax wiki
72+
*/
73+
class OtherPackageMembers
74+
/**
75+
* [[SomeClass]]
76+
*/
77+
class SamePackageLink
78+
79+
/**
80+
* [[SomeClass.method]]
81+
*/
82+
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/src/dotty/dokka/DRI.scala

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package dotty.dokka
22

33
import java.nio.file.Path
4-
import org.jetbrains.dokka.links.PointingToDeclaration
54

65
val staticFileSymbolUUID = "___staticFile___"
76

87
val topLevelDri = DRI("/")
98

10-
type DDRI = org.jetbrains.dokka.links.DRI
11-
129
// we may need target...
13-
case class DRI(
10+
final case class DRI(
1411
location: String,
1512
anchor: String = "",
1613
origin: String = "",
@@ -20,25 +17,5 @@ case class DRI(
2017

2118
def isStaticFile = symbolUUID == staticFileSymbolUUID
2219

23-
def asDokka: DDRI = new DDRI(
24-
location,
25-
anchor,
26-
null,
27-
PointingToDeclaration.INSTANCE,
28-
origin + ":" + symbolUUID
29-
)
30-
3120
object DRI:
3221
def forPath(path: Path) = DRI(location = path.toString, symbolUUID = staticFileSymbolUUID)
33-
34-
extension (dokkaDri: DDRI)
35-
def asScala: DRI =
36-
val elements = dokkaDri.getExtra.split(":")
37-
val origin = elements.headOption.getOrElse("")
38-
val symbolUUID = elements.drop(1).mkString(":")
39-
DRI(
40-
dokkaDri.getPackageName,
41-
dokkaDri.getClassNames,
42-
origin,
43-
symbolUUID
44-
)

scala3doc/src/dotty/dokka/DocContext.scala

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package dotty.dokka
22

3-
import org.jetbrains.dokka._
4-
import org.jetbrains.dokka.plugability.DokkaContext
53
import java.io.File
64
import java.nio.file.Files
75
import java.nio.file.Path
@@ -25,9 +23,6 @@ type CompilerContext = dotty.tools.dotc.core.Contexts.Context
2523
given compilerContext(using docContext: DocContext): CompilerContext =
2624
docContext.compilerContext
2725

28-
given docContextFromDokka(using dokkaContext: DokkaContext): DocContext =
29-
dokkaContext.getConfiguration.asInstanceOf[DocContext]
30-
3126
val report = dotty.tools.dotc.report
3227

3328
def relativePath(p: Path)(using Context): Path =
@@ -73,34 +68,16 @@ extension (r: report.type)
7368

7469
case class NavigationNode(name: String, dri: DRI, nested: Seq[NavigationNode])
7570

76-
case class DocContext(args: Scala3doc.Args, compilerContext: CompilerContext)
77-
extends DokkaConfiguration:
78-
override def getOutputDir: File = args.output
79-
override def getCacheRoot: File = null
80-
override def getOfflineMode: Boolean = false
81-
override def getFailOnWarning: Boolean = false
82-
override def getSourceSets: JList[DokkaSourceSet] = JNil
83-
override def getModules: JList[DokkaConfiguration.DokkaModuleDescription] = JNil
84-
override def getPluginsClasspath: JList[File] = JNil
85-
override def getModuleName(): String = "ModuleName"
86-
override def getModuleVersion(): String = ""
87-
88-
lazy val sourceLinks: SourceLinks = SourceLinks.load(using this)
89-
90-
lazy val displaySourceSets = getSourceSets.toDisplaySourceSet
91-
92-
// Nasty hack but will get rid of it once we migrate away from dokka renderer
93-
var navigationNode: Option[NavigationNode] = None
94-
95-
val logger = new Scala3DocDokkaLogger(using compilerContext)
71+
case class DocContext(args: Scala3doc.Args, compilerContext: CompilerContext):
72+
lazy val sourceLinks: SourceLinks = SourceLinks.load(using this)
9673

97-
lazy val staticSiteContext = args.docsRoot.map(path => StaticSiteContext(
98-
File(path).getAbsoluteFile(),
99-
args,
100-
sourceLinks
101-
)(using compilerContext))
74+
// Nasty hack but will get rid of it once we migrate away from dokka renderer
75+
var navigationNode: Option[NavigationNode] = None
10276

103-
val externalDocumentationLinks = args.externalMappings
77+
lazy val staticSiteContext = args.docsRoot.map(path => StaticSiteContext(
78+
File(path).getAbsoluteFile(),
79+
args,
80+
sourceLinks
81+
)(using compilerContext))
10482

105-
override def getPluginsConfiguration: JList[DokkaConfiguration.PluginConfiguration] =
106-
JNil
83+
val externalDocumentationLinks = args.externalMappings

scala3doc/src/dotty/dokka/Scala3doc.scala

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

3-
import org.jetbrains.dokka._
4-
import org.jetbrains.dokka.utilities._
5-
import org.jetbrains.dokka.plugability._
63
import java.util.ServiceLoader
74
import java.io.File
85
import java.util.jar._
@@ -15,31 +12,6 @@ import dotty.tools.dotc.config.Settings._
1512
import dotty.tools.dotc.config.CommonScalaSettings
1613
import dotty.tools.dotc.reporting.Reporter
1714

18-
19-
class Scala3DocDokkaLogger(using CompilerContext) extends DokkaLogger:
20-
def debug(msg: String): Unit = report.debuglog(msg)
21-
22-
// We do not want errors from dokka (that are) not critical to fail our runs
23-
def error(msg: String): Unit =
24-
errors += 1
25-
report.warning(msg)
26-
27-
def info(msg: String): Unit = report.inform(msg)
28-
def progress(msg: String): Unit = report.informProgress(msg)
29-
30-
private val dokkaAlphaWarning = "Dokka 1.4.* is an alpha project"
31-
def warn(msg: String): Unit =
32-
if msg != dokkaAlphaWarning then
33-
warnings += 1
34-
report.warning(msg)
35-
36-
private var errors = 0
37-
private var warnings = 0
38-
def getErrorsCount(): Int = errors
39-
def getWarningsCount(): Int = warnings
40-
def setErrorsCount(count: Int): Unit = errors = count
41-
def setWarningsCount(count: Int): Unit = warnings = count
42-
4315
object Scala3doc:
4416
enum CommentSyntax:
4517
case Wiki
@@ -94,21 +66,10 @@ object Scala3doc:
9466

9567

9668
private [dokka] def run(args: Args)(using ctx: CompilerContext): DocContext =
97-
9869
given docContext: DocContext = new DocContext(args, ctx)
99-
10070
val module = ScalaModuleProvider.mkModule()
101-
given dokkaContext: DokkaContext =
102-
DokkaContext.Companion.create(docContext, docContext.logger, JList())
103-
val dokkaRenderer = new DokkaScalaHtmlRenderer
104-
105-
val renderer = new dotty.dokka.renderers.HtmlRenderer(
106-
module.rootPackage,
107-
module.members,
108-
dri => c => dokkaRenderer.buildWithKotlinx(c, FakeContentPage(dri.asDokka, c), null)
109-
)
110-
dokkaRenderer.init(renderer)
111-
renderer.render()
71+
72+
new dotty.dokka.renderers.HtmlRenderer(module.rootPackage, module.members).render()
11273
report.inform("generation completed successfully")
11374
docContext
11475

scala3doc/src/dotty/dokka/ScalaModuleCreator.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package dotty.dokka
22

33
import dotty.dokka.tasty.DokkaTastyInspector
44
import dotty.dokka.model.api._
5-
import org.jetbrains.dokka.base.parsers.MarkdownParser
65
import collection.JavaConverters._
76
import kotlin.coroutines.Continuation
87

98
case class Module(rootPackage: Member, members: Map[DRI, Member])
109

1110
object ScalaModuleProvider:
1211
def mkModule()(using ctx: DocContext): Module =
13-
val (result, rootDoc) = DokkaTastyInspector(new MarkdownParser(_ => null)).result()
12+
val (result, rootDoc) = DokkaTastyInspector().result()
1413
val (rootPck, rest) = result.partition(_.name == "API")
1514
val packageMembers = (rest ++ rootPck.flatMap(_.members)).sortBy(_.name)
1615

0 commit comments

Comments
 (0)