Skip to content

Commit

Permalink
Merge pull request #13170 from romanowski/scaladoc/api-layout
Browse files Browse the repository at this point in the history
Fixes that should go into #13130
  • Loading branch information
nicolasstucki authored Jul 28, 2021
2 parents b902516 + 02b82b6 commit 23be42c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
BooleanSetting("-Ygenerate-inkuire", "Generates InkuireDB and enables Hoogle-like searches", false)

val apiSubdirectory: Setting[Boolean] =
BooleanSetting("-Yapi-subdirectory", "Keep all api member inside `api` directory", false)
BooleanSetting("-Yapi-subdirectory", "Put the API documentation pages inside a directory `api/`", false)

def scaladocSpecificSettings: Set[Setting[_]] =
Set(sourceLinks, syntax, revision, externalDocumentationMappings, socialLinks, skipById, skipByRegex, deprecatedSkipPackages, docRootContent, snippetCompiler, snippetCompilerDebug, generateInkuire)
11 changes: 6 additions & 5 deletions scaladoc/src/dotty/tools/scaladoc/renderers/HtmlRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx
children = Nil
))
case Some(siteContext) =>
// In case that we do not have an index page and we do not have any API entries
// In case that we do not have an index page and we do not have any API entries
// we want to create empty index page, so there is one
val actualIndexTemplate = siteContext.indexTemplates() match
case Nil if effectiveMembers.isEmpty => Seq(siteContext.emptyIndexTemplate)
case templates => templates
val actualIndexTemplate = siteContext.indexTemplate() match {
case None if effectiveMembers.isEmpty => Seq(siteContext.emptyIndexTemplate)
case templates => templates.toSeq
}

(siteContext.orphanedTemplates ++ actualIndexTemplate).map(templateToPage(_, siteContext))
(siteContext.orphanedTemplates ++ actualIndexTemplate).map(templateToPage(_, siteContext))

/**
* Here we have to retrive index pages from hidden pages and replace fake index pages in navigable page tree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ class StaticSiteContext(
if files.size > 1 then
val msg = s"ERROR: Multiple root index pages found: ${files.map(_.getAbsolutePath)}"
report.error(msg)
files

files.headOption

def hasIndexFile = indexFiles.nonEmpty

def emptyIndexTemplate =
val fakeFile = new File(root, "index.html")
LoadedTemplate(emptyTemplate(fakeFile, "index"), List.empty, fakeFile)

def indexTemplates(): Seq[LoadedTemplate] = indexFiles.flatMap(loadTemplate(_, isBlog = false))
def indexTemplate(): Option[LoadedTemplate] =
indexFiles.flatMap(loadTemplate(_, isBlog = false))

lazy val layouts: Map[String, TemplateFile] =
val layoutRoot = new File(root, "_layouts")
Expand Down

0 comments on commit 23be42c

Please sign in to comment.