@@ -20,7 +20,7 @@ import util.Try
20
20
21
21
import scala .collection .JavaConverters ._
22
22
23
- class StaticSiteContext (val root : File , sourceSets : Set [SourceSetWrapper ], args : Args , val sourceLinks : SourceLinks ):
23
+ class StaticSiteContext (val root : File , sourceSets : Set [SourceSetWrapper ], val args : Args , val sourceLinks : SourceLinks ):
24
24
25
25
var memberLinkResolver : String => Option [DRI ] = _ => None
26
26
@@ -81,16 +81,15 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper], args:
81
81
val topLevelFiles = if isBlog then Seq (from, new File (from, " _posts" )) else Seq (from)
82
82
val allFiles = topLevelFiles.filter(_.isDirectory).flatMap(_.listFiles())
83
83
val (indexes, children) = allFiles.flatMap(loadTemplate(_)).partition(_.templateFile.isIndexPage())
84
- if (indexes.size > 1 )
85
- // TODO (https://github.com/lampepfl/scala3doc/issues/238): provide proper error handling
86
- println(s " ERROR: Multiple index pages for $from found in ${indexes.map(_.file)}" )
84
+
87
85
def loadIndexPage (): TemplateFile =
88
- val indexFiles = from.listFiles { file => file.getName == " index.md" || file.getName == " index.html" }
89
- indexFiles.size match
90
- case 0 => emptyTemplate(from, from.getName)
91
- case 1 => loadTemplateFile(indexFiles.head) .copy(file = from)
86
+ val indexFiles = from.listFiles { file => file.getName == " index.md" || file.getName == " index.html" }
87
+ indexes match
88
+ case Nil => emptyTemplate(from, from.getName)
89
+ case Seq (loadedTemplate) => loadedTemplate.templateFile .copy(file = from)
92
90
case _ =>
93
- val msg = s " ERROR: Multiple index pages found under ${from.toPath}"
91
+ // TODO (https://github.com/lampepfl/scala3doc/issues/238): provide proper error handling
92
+ val msg = s " ERROR: Multiple index pages for $from found in ${indexes.map(_.file)}"
94
93
throw new java.lang.RuntimeException (msg)
95
94
96
95
val templateFile = if (from.isDirectory) loadIndexPage() else loadTemplateFile(from)
@@ -101,7 +100,15 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper], args:
101
100
pageSettings.flatMap(_.get(" date" ).collect{ case s : String => s}).getOrElse(" 1900-01-01" ) // blogs without date are last
102
101
children.sortBy(dateFrom).reverse
103
102
104
- Some (LoadedTemplate (templateFile, processedChildren.toList, from))
103
+ val processedTemplate = // Set provided name as arg in page for `docs`
104
+ if from.getParentFile.toPath == docsPath && templateFile.isIndexPage() then
105
+ // TODO (https://github.com/lampepfl/scala3doc/issues/238): provide proper error handling
106
+ if templateFile.title != " index" then println(s " [WARN] title in $from will be overriden " )
107
+ val projectTitle = args.projectTitle.getOrElse(args.name)
108
+ templateFile.copy(title = projectTitle)
109
+ else templateFile
110
+
111
+ Some (LoadedTemplate (processedTemplate, processedChildren.toList, from))
105
112
catch
106
113
case e : RuntimeException =>
107
114
// TODO (https://github.com/lampepfl/scala3doc/issues/238): provide proper error handling
0 commit comments