Skip to content

Commit

Permalink
Tweak doc watch mode handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Feb 17, 2025
1 parent 4aaf4a1 commit 96b5d99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
16 changes: 13 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,19 @@ object docs extends ScalaModule {
}
def mkdocsServe() = T.command[Unit] {
mdoc()()
os.proc("mkdocs", "serve", mkdocsConfigArgs())
.call(cwd = millModuleBasePath.value, stdin = os.Inherit, stdout = os.Inherit)

val docsDir = T.workspace / "docs"
val serveProc = os.proc("mkdocs", "serve", mkdocsConfigArgs())
.spawn(cwd = docsDir, stdin = os.Inherit, stdout = os.Inherit)
val mdocProc = os.proc("java", "-cp", compileClasspath().map(_.path).mkString(File.pathSeparator), mainClass().getOrElse(???), mdocWatchArgs().value)
.spawn(cwd = docsDir, stdin = os.Inherit, stdout = os.Inherit)

while (serveProc.isAlive && mdocProc.isAlive)
Thread.sleep(1000L)

val serveRetCode = serveProc.waitFor()
val mdocRetCode = mdocProc.waitFor()
if (serveRetCode != 0 || mdocRetCode != 0)
sys.error(s"Got exit code $serveRetCode for mkdocs serve and $mdocRetCode for mdoc")
()
}
def mkdocsBuild() = T.command[Unit] {
Expand Down
9 changes: 2 additions & 7 deletions docs/pages/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@

### Watch mode

In a first terminal, run
Run
```text
$ ./mill -i -w docs.mdocWatch
```

Leave it running, and run in a second terminal
```text
$ ./mill -i -w docs.mkdocsServe
$ ./mill -i docs.mkdocsServe
```

Then open the URL printed in the console in your browser (it should be
Expand Down

0 comments on commit 96b5d99

Please sign in to comment.