@@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.`type`.TypeReference;
7
7
import scala .jdk .CollectionConverters ._
8
8
import java .util .Optional
9
9
import scala .beans ._
10
+ import java .nio .file .{Files , Paths }
10
11
11
12
enum Sidebar :
12
13
case Category (
@@ -32,11 +33,22 @@ object Sidebar:
32
33
33
34
private def toSidebar (r : RawInput )(using CompilerContext ): Sidebar = r match
34
35
case RawInput (title, page, index, subsection, dir, hidden) if page.nonEmpty && index.isEmpty && subsection.isEmpty() =>
36
+ val basePath = Paths .get(" docs/_docs" )
37
+ val pagePath = basePath.resolve(page)
38
+ if ! Files .exists(pagePath) then
39
+ report.error(s " Page $page does not exist. " )
35
40
Sidebar .Page (Option .when(title.nonEmpty)(title), page, hidden)
36
41
case RawInput (title, page, index, subsection, dir, hidden) if page.isEmpty && (! subsection.isEmpty() || ! index.isEmpty()) =>
37
42
Sidebar .Category (Option .when(title.nonEmpty)(title), Option .when(index.nonEmpty)(index), subsection.asScala.map(toSidebar).toList, Option .when(dir.nonEmpty)(dir))
38
43
case RawInput (title, page, index, subsection, dir, hidden) =>
39
- report.error(s " Error parsing YAML configuration file. \n $schemaMessage" )
44
+ val errors = (title.isEmpty(), page.isEmpty(), index.isEmpty(), subsection.isEmpty(), dir.isEmpty())
45
+ println(errors)
46
+ errors match
47
+ case (true , _, _, _, _) =>
48
+ report.error(s " Title is not provided. \n $schemaMessage" )
49
+ case (false , true , true , _, _) =>
50
+ report.error(s " Index or page path to at least one page is missing. \n $schemaMessage" )
51
+ case _ => report.error(s " Error parsing YAML configuration file. \n $schemaMessage" )
40
52
Sidebar .Page (None , page, hidden)
41
53
42
54
private def schemaMessage : String =
0 commit comments