Skip to content

Commit fd43076

Browse files
committed
Corrections:
- Change the case match (Overkill) to a if else - Two types of messages : - Error: NoTitle and No index or No page. - Warning: When the parsing is not done correctly. Example: When a title got two pages.
1 parent 80bfcd7 commit fd43076

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

scaladoc/src/dotty/tools/scaladoc/site/SidebarParser.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ object Sidebar:
4444
case RawInput(title, page, index, subsection, dir, hidden) if page.isEmpty && (!subsection.isEmpty() || !index.isEmpty()) =>
4545
Sidebar.Category(Option.when(title.nonEmpty)(title), Option.when(index.nonEmpty)(index), subsection.asScala.map(toSidebar(_, content)).toList, Option.when(dir.nonEmpty)(dir))
4646
case RawInput(title, page, index, subsection, dir, hidden) =>
47-
val errors = (title.isEmpty(), page.isEmpty(), index.isEmpty(), subsection.isEmpty(), dir.isEmpty())
48-
errors match
49-
case (true, _, _, _, _) =>
50-
report.error(s"Title is not provided.\n$schemaMessage")
51-
case (false, true, true, _, _) =>
52-
report.error(s"Index or page path to at least one page is missing.\n$schemaMessage")
53-
case _ => report.error(s"Error parsing YAML configuration file.\n$schemaMessage")
47+
if title.isEmpty() then
48+
val msg = "Error parsing YAML configuration file: Title is not provided."
49+
report.error(s"$msg\n$schemaMessage")
50+
else if title.nonEmpty && (page.isEmpty() || index.isEmpty()) then
51+
val msg = "Error parsing YAML configuration file: Index or page path to at least one page is missing."
52+
report.error(s"$msg\n$schemaMessage")
53+
else
54+
val msg = "The parsing seems not to have been done correctly."
55+
report.warning(s"$msg\n$schemaMessage")
5456
Sidebar.Page(None, page, hidden)
5557

5658
private def schemaMessage: String =

0 commit comments

Comments
 (0)