@@ -34,6 +34,55 @@ class SidebarParserTest:
34
34
| - page: my-page6/my-page6/my-page6.md
35
35
""" .stripMargin
36
36
37
+ private val sidebarErrorNoTitle =
38
+ """ index: index.md
39
+ |subsection:
40
+ | page: my-page1.md
41
+ | - page: my-page2.md
42
+ | - page: my-page3/subsection
43
+ | - title: Reference
44
+ | subsection:
45
+ | - page: my-page3.md
46
+ | hidden: true
47
+ | - index: my-page4/index.md
48
+ | subsection:
49
+ | - page: my-page4/my-page4.md
50
+ | - title: My subsection
51
+ | index: my-page5/index.md
52
+ | subsection:
53
+ | - page: my-page5/my-page5.md
54
+ | - subsection:
55
+ | - page: my-page7/my-page7.md
56
+ | - index: my-page6/index.md
57
+ | subsection:
58
+ | - index: my-page6/my-page6/index.md
59
+ | subsection:
60
+ | - page: my-page6/my-page6/my-page6.md
61
+ """ .stripMargin
62
+
63
+ private val msg = " Error parsing YAML configuration file: Title is not provided."
64
+
65
+ private def schemaMessage : String =
66
+ s """ Static site YAML configuration file should comply with the following description:
67
+ |The root element of static site needs to be <subsection>
68
+ |`title` and `directory` properties are ignored in root subsection.
69
+ |
70
+ |<subsection>:
71
+ | title: <string> # optional - Default value is file name. Title can be also set using front-matter.
72
+ | index: <string> # optional - If not provided, default empty index template is generated.
73
+ | directory: <string> # optional - By default, directory name is title name in kebab case.
74
+ | subsection: # optional - If not provided, pages are loaded from the index directory
75
+ | - <subsection> | <page>
76
+ | # either index or subsection needs to be present
77
+ |<page>:
78
+ | title: <string> # optional - Default value is file name. Title can be also set using front-matter.
79
+ | page: <string>
80
+ | hidden: <boolean> # optional - Default value is false.
81
+ |
82
+ |For more information visit:
83
+ |https://docs.scala-lang.org/scala3/guides/scaladoc/static-site.html
84
+ | """ .stripMargin
85
+
37
86
@ Test
38
87
def loadSidebar (): Unit = assertEquals(
39
88
Sidebar .Category (
@@ -53,3 +102,16 @@ class SidebarParserTest:
53
102
),
54
103
Sidebar .load(sidebar)(using testContext)
55
104
)
105
+
106
+ @ Test (expected = classOf [IllegalArgumentException ])
107
+ def loadSidebarError (): Unit =
108
+ assertEquals(
109
+ Sidebar .Category (
110
+ None ,
111
+ None ,
112
+ List (),
113
+ None
114
+ ),
115
+ Sidebar .load(sidebarErrorNoTitle)(using testContext)
116
+ )
117
+ throw new IllegalArgumentException (s " $msg\n $schemaMessage" )
0 commit comments