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

Tweak doc watch mode handling #597

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
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
20 changes: 18 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,25 @@ 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