File tree 1 file changed +10
-0
lines changed
scaladoc/src/dotty/tools/scaladoc/renderers 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -47,16 +47,26 @@ trait SiteRenderer(using DocContext) extends Locations:
47
47
resolveLink(pageDri, str.stripPrefix(" /" ))
48
48
)
49
49
def asStaticSite : Option [String ] = tryAsDri(str)
50
+ def asApiLink : Option [String ] =
51
+ {
52
+ val strWithoutHtml = str.stripSuffix(" .html" ).stripPrefix(" /" )
53
+ val sourceDir = Paths .get(" src" , " main" , " scala" )
54
+ val scalaPath = sourceDir.resolve(s " $strWithoutHtml.scala " )
55
+ val scalaDirPath = sourceDir.resolve(strWithoutHtml)
56
+ Option .when(Files .exists(scalaPath)|| Files .exists(scalaDirPath))(resolveLink(pageDri, str))
57
+ }
50
58
51
59
/* Link resolving checks performs multiple strategies with following priority:
52
60
1. We check if the link is a valid URL e.g. http://dotty.epfl.ch
53
61
2. We check if the link leads to other static site
54
62
3. We check if the link leads to existing asset e.g. images/logo.svg -> <static-site-root>/_assets/images/logo.svg
63
+ 4. We check if the link leads to existing API page
55
64
*/
56
65
57
66
asValidURL
58
67
.orElse(asStaticSite)
59
68
.orElse(asAsset)
69
+ .orElse(asApiLink)
60
70
.getOrElse {
61
71
report.warn(s " Unable to resolve link ' $str' " , content.template.templateFile.file)
62
72
str
You can’t perform that action at this time.
0 commit comments