@@ -16,6 +16,7 @@ object `package` extends mill.Module {
1616 * API documentation generated with ScalaDoc.
1717 */
1818 object apidocs extends UnidocModule {
19+ def dummy = Task { PathRef(Task.dest) }
1920 def unidocDocumentTitle = Task { "Mill" }
2021
2122 def unidocCompileClasspath =
@@ -389,73 +390,74 @@ object `package` extends mill.Module {
389390 }
390391 }
391392 def githubPages: T[PathRef] = Task {
392- generatePages(authorMode = false).apply().apply(oldDocSources().map(_.path))
393+ generatePages(false, apidocs.unidocSite ).apply().apply(oldDocSources().map(_.path))
393394 }
394395
395396 def localPages: T[PathRef] = Task {
396- val pages = generatePages(authorMode = true).apply().apply(oldDocSources().map(_.path) )
397+ val pages = generatePages(true, apidocs.unidocLocal ).apply().apply(Nil )
397398 Task.log.streams.out.println(
398399 s"You can browse the pages at: ${(pages.path / "index.html").toNIO.toUri()}"
399400 )
400401 pages
401402 }
402403 def fastPages: T[PathRef] = Task {
403- val pages = generatePages(authorMode = true).apply().apply(Nil)
404+ val pages = generatePages(true, apidocs.dummy ).apply().apply(Nil)
404405 Task.log.streams.out.println(
405406 s"You can browse the pages at: ${(pages.path / "index.html").toNIO.toUri()}"
406407 )
407408 pages
408409 }
409410
410- def generatePages(authorMode: Boolean) = Task.Anon { (extraSources: Seq[os.Path]) =>
411- Task.log.streams.err.println("Creating Antora playbook ...")
412- // dependency to sources
413- source()
414- val docSite = Task.dest
415- val playbook = docSite / "antora-playbook.yml"
416- val siteDir = docSite / "site"
417- os.write(
418- target = playbook,
419- data = githubPagesPlaybookText(authorMode).apply().apply(extraSources),
420- createFolders = true
421- )
422- Task.log.streams.err.println("Running Antora ...")
423- runAntora(
424- npmDir = npmBase(),
425- workDir = docSite,
426- args = Seq(
427- playbook.last,
428- "--to-dir",
429- siteDir.toString(),
430- "--attribute",
431- "page-pagination"
432- ) ++
433- Option.when(!authorMode)("--fetch").toSeq
434- )
435- os.write(siteDir / ".nojekyll", "")
436-
437- // sanitize devAntora source URLs
438- Task.log.streams.err.println("Sanitizing links ...")
439- sanitizeDevUrls(
440- siteDir,
441- devAntoraSources().path,
442- BuildCtx.workspaceRoot / "docs",
443- mill.api.BuildCtx.workspaceRoot
444- )
411+ def generatePages(authorMode: Boolean, apiDocTask: Task[PathRef]) =
412+ Task.Anon { (extraSources: Seq[os.Path]) =>
413+ Task.log.streams.err.println("Creating Antora playbook ...")
414+ // dependency to sources
415+ source()
416+ val docSite = Task.dest
417+ val playbook = docSite / "antora-playbook.yml"
418+ val siteDir = docSite / "site"
419+ os.write(
420+ target = playbook,
421+ data = githubPagesPlaybookText(authorMode).apply().apply(extraSources),
422+ createFolders = true
423+ )
424+ Task.log.streams.err.println("Running Antora ...")
425+ runAntora(
426+ npmDir = npmBase(),
427+ workDir = docSite,
428+ args = Seq(
429+ playbook.last,
430+ "--to-dir",
431+ siteDir.toString(),
432+ "--attribute",
433+ "page-pagination"
434+ ) ++
435+ Option.when(!authorMode)("--fetch").toSeq
436+ )
437+ os.write(siteDir / ".nojekyll", "")
438+
439+ // sanitize devAntora source URLs
440+ Task.log.streams.err.println("Sanitizing links ...")
441+ sanitizeDevUrls(
442+ siteDir,
443+ devAntoraSources().path,
444+ BuildCtx.workspaceRoot / "docs",
445+ mill.api.BuildCtx.workspaceRoot
446+ )
445447
446- for (p <- os.walk(siteDir) if p.ext == "html") {
447- // Manually un-substitute ellipses in normal text to reverse the antora unicode
448- // substitution, because the font for the unicode ellipses looks very bad
449- os.write.over(p, os.read(p).replace("…", "..."))
450- }
448+ for (p <- os.walk(siteDir) if p.ext == "html") {
449+ // Manually un-substitute ellipses in normal text to reverse the antora unicode
450+ // substitution, because the font for the unicode ellipses looks very bad
451+ os.write.over(p, os.read(p).replace("…", "..."))
452+ }
451453
452- // only copy the "api" sub-dir; api docs contains a top-level index.html with we don't want
453- val unidocSrc = if (authorMode) apidocs.unidocLocal().path else apidocs.unidocSite ().path
454- Task.log.streams.err.println(s"Copying API docs from ${unidocSrc} ...")
455- os.copy(unidocSrc, siteDir / "api/latest", createFolders = true)
454+ // only copy the "api" sub-dir; api docs contains a top-level index.html with we don't want
455+ val unidocSrc = apiDocTask ().path
456+ Task.log.streams.err.println(s"Copying API docs from ${unidocSrc} ...")
457+ os.copy(unidocSrc, siteDir / "api/latest", createFolders = true)
456458
457- PathRef(siteDir)
458- }
459+ PathRef(siteDir)
460+ }
459461
460462 def sanitizeDevUrls(
461463 dir: os.Path,
@@ -500,7 +502,7 @@ object `package` extends mill.Module {
500502
501503 def allLinksAndAnchors
502504 : T[IndexedSeq[(os.Path, Seq[(String, String)], Seq[(String, String)], Set[String])]] = Task {
503- val base = fastPages ().path
505+ val base = localPages ().path
504506 val validExtensions = Set("html", "scala")
505507 for (path <- os.walk(base) if validExtensions(path.ext))
506508 yield {
0 commit comments