-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scaladoc generate flatten structure for API rather then put everything in api
directory
#13130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
05f7310
8f78f33
8a2325d
49f2d03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package docs.tests | ||
|
||
class Adoc: | ||
def foo = 123 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package resources.tests | ||
|
||
class Adoc: | ||
def foo = 123 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,19 +58,18 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx | |
|
||
val hiddenPages: Seq[Page] = | ||
staticSite match | ||
case None => | ||
Seq(navigablePage.copy( // Add index page that is a copy of api/index.html | ||
link = navigablePage.link.copy(dri = docsRootDRI), | ||
children = Nil | ||
)) | ||
case None => Nil | ||
romanowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case Some(siteContext) => | ||
(siteContext.orphanedTemplates :+ siteContext.indexTemplate()).map(templateToPage(_, siteContext)) | ||
val actualIndexTemplate = siteContext.indexTemplates() match | ||
case Nil if effectiveMembers.isEmpty => Seq(siteContext.emptyIndexTemplate) | ||
case templates => templates | ||
|
||
(siteContext.orphanedTemplates ++ actualIndexTemplate).map(templateToPage(_, siteContext)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a comment explaining what this does? I’m a bit lost. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems it just a rewrite (no new logic is added here). Before: Now: Can you @romanowski explain if I get something wrong here? The only thing is granularity (we have more designated functions to call), but on the other hand main misconception here is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will rewrite to Option |
||
|
||
/** | ||
* Here we have to retrive index pages from hidden pages and replace fake index pages in navigable page tree. | ||
*/ | ||
private def getAllPages: Seq[Page] = | ||
|
||
val allPages: Seq[Page] = | ||
def traversePages(page: Page): (Page, Seq[Page]) = | ||
val (newChildren, newPagesToRemove): (Seq[Page], Seq[Page]) = page.children.map(traversePages(_)).foldLeft((Seq[Page](), Seq[Page]())) { | ||
case ((pAcc, ptrAcc), (p, ptr)) => (pAcc :+ p, ptrAcc ++ ptr) | ||
|
@@ -83,9 +82,22 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx | |
|
||
val (newNavigablePage, pagesToRemove) = traversePages(navigablePage) | ||
|
||
newNavigablePage +: hiddenPages.filterNot(pagesToRemove.contains) | ||
val all = newNavigablePage +: hiddenPages.filterNot(pagesToRemove.contains) | ||
// We need to check for conflicts only if we have top-level member called blog or docs | ||
val hasPotentialConflict = | ||
rootPackage.members.exists(m => m.name.startsWith("docs") || m.name.startsWith("blog")) | ||
|
||
if hasPotentialConflict then | ||
def walk(page: Page): Unit = | ||
if page.link.dri.isStaticFile then | ||
val dest = absolutePath(page.link.dri) | ||
if apiPaths.contains(dest) then | ||
report.error(s"Conflict between static page and API member for $dest") | ||
page.children.foreach(walk) | ||
|
||
all.foreach (walk) | ||
|
||
val allPages = getAllPages | ||
all | ||
|
||
def renderContent(page: Page) = page.content match | ||
case m: Member => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,17 +19,21 @@ class StaticSiteContext( | |
|
||
var memberLinkResolver: String => Option[DRI] = _ => None | ||
|
||
def indexTemplate(): LoadedTemplate = | ||
private def indexFiles = | ||
val files = List(new File(root, "index.html"), new File(root, "index.md")).filter { _.exists() } | ||
|
||
if files.size > 1 then | ||
val msg = s"ERROR: Multiple root index pages found: ${files.map(_.getAbsolutePath)}" | ||
report.error(msg) | ||
files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be |
||
|
||
files.flatMap(loadTemplate(_, isBlog = false)).headOption.getOrElse { | ||
val fakeFile = new File(root, "index.html") | ||
LoadedTemplate(emptyTemplate(fakeFile, "index"), List.empty, fakeFile) | ||
} | ||
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)) | ||
|
||
lazy val layouts: Map[String, TemplateFile] = | ||
val layoutRoot = new File(root, "_layouts") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Trying to override a api page! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><body>I am causing conflicts!</body></html> |
Uh oh!
There was an error while loading. Please reload this page.