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