Skip to content
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

Try to fix doc rendering for old versions of docsite #3700

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions docs/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,31 @@ object `package` extends RootModule {
createFolders = true
)

// Walk all files al render graphviz templates ourselves because the only Antora graphviz
expandDiagramsInDirectoryAdocFile(T.dest, mill.main.VisualizeModule.classpath().map(_.path))

PathRef(T.dest)
}

def expandDiagramsInDirectoryAdocFile(dest: os.Path,
visualizeClassPath: Agg[os.Path])
(implicit ctx: mill.api.Ctx) = {

// Walk all files to render graphviz templates ourselves because the only Antora graphviz
// plugin (Kroki) relies on an online web service that is super slow and flaky
def walkAllFiles(inputs: Map[(os.Path, Int), String]): Map[(os.Path, Int), String] = {
val output = collection.mutable.Map.empty[(os.Path, Int), String]
for (p <- os.walk(T.dest) if p.ext == "adoc"){
for (p <- os.walk(dest) if p.ext == "adoc"){
val outputLines = collection.mutable.ArrayDeque.empty[String]
val graphvizLines = collection.mutable.ArrayDeque.empty[String]
var isGraphViz = false
var isGraphViz0 = false

for((line, i) <- os.read.lines(p).zipWithIndex){
line match{
case "[graphviz]" => isGraphViz0 = true
case "...." if isGraphViz0 => isGraphViz0 = false; isGraphViz = true
case "```graphviz" => isGraphViz = true
case "```" if isGraphViz =>
case "```" | "...." if isGraphViz =>
isGraphViz = false
if (inputs.isEmpty) output((p, i)) = graphvizLines.mkString("\n")
else {
Expand All @@ -129,16 +141,14 @@ object `package` extends RootModule {

mill.util.Jvm.runSubprocess(
"mill.main.graphviz.GraphvizTools",
mill.main.VisualizeModule.classpath().map(_.path),
visualizeClassPath,
mainArgs = orderedDiagrams.map{case (p, i, src, dest) => s"$src;$dest;svg"}
)

walkAllFiles(orderedDiagrams.map{case (p, i, src, dest) => ((p, i), os.read(dest / "out.svg"))}.toMap)

PathRef(T.dest)
}


def supplementalFiles = T.source(millSourcePath / "supplemental-ui")

/**
Expand Down Expand Up @@ -232,6 +242,7 @@ object `package` extends RootModule {
os.proc("git", "checkout", oldVersion).call(cwd = checkout, stdout = os.Inherit)
val outputFolder = checkout / "out" / "docs" / "source.dest"
os.proc("./mill", "-i", "docs.source").call(cwd = checkout, stdout = os.Inherit)
expandDiagramsInDirectoryAdocFile(outputFolder, mill.main.VisualizeModule.classpath().map(_.path))
sanitizeAntoraYml(outputFolder, oldVersion, oldVersion, oldVersion)
PathRef(outputFolder)
}
Expand Down
Loading