Skip to content

Commit

Permalink
Ensure all website/reference docs are included in sclicheck.DocTests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gedochao committed Nov 28, 2022
1 parent 4ef3475 commit bd9f46a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,13 @@ To just check the documents, run:
./mill -i docs-tests.test 'sclicheck.DocTests.*'
```

You can also check all root docs, commands, guides or cookbooks:
You can also check all root docs, commands, reference docs, guides or cookbooks:
```bash
./mill -i docs-tests.test 'sclicheck.DocTests.root*'
./mill -i docs-tests.test 'sclicheck.DocTests.guide*'
./mill -i docs-tests.test 'sclicheck.DocTests.command*'
./mill -i docs-tests.test 'sclicheck.DocTests.cookbook*'
./mill -i docs-tests.test 'sclicheck.DocTests.reference*'
```

Similarly, you can check single files:
Expand Down
17 changes: 10 additions & 7 deletions modules/docs-tests/src/test/scala/sclicheck/DocTests.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package sclicheck

class DocTests extends munit.FunSuite {
case class DocTestEntry(name: String, path: os.Path, depth: Int = Int.MaxValue)

val docsRootPath: os.Path = os.pwd / "website" / "docs"
val dirs: Seq[(String, os.Path)] = Seq(
"cookbook" -> docsRootPath / "cookbooks",
"command" -> docsRootPath / "commands",
"guide" -> docsRootPath / "guides"
val entries: Seq[DocTestEntry] = Seq(
DocTestEntry("root", docsRootPath, depth = 1),
DocTestEntry("cookbook", docsRootPath / "cookbooks"),
DocTestEntry("command", docsRootPath / "commands"),
DocTestEntry("guide", docsRootPath / "guides"),
DocTestEntry("reference", docsRootPath / "reference")
)

val options: Options = Options(scalaCliCommand = Seq(TestUtil.scalaCliPath))
Expand All @@ -19,9 +23,8 @@ class DocTests extends munit.FunSuite {
os.read.lines(f).exists(lineContainsAnyChecks)

for {
(tpe, dir) <- dirs :+ ("root", docsRootPath)
maxDepth = if dir == docsRootPath then 1 else Int.MaxValue
inputs = os.walk(dir, maxDepth = maxDepth)
DocTestEntry(tpe, dir, depth) <- entries
inputs = os.walk(dir, maxDepth = depth)
.filter(_.last.endsWith(".md"))
.filter(os.isFile(_))
.filter(fileContainsAnyChecks)
Expand Down
6 changes: 3 additions & 3 deletions website/docs/reference/scala-command/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ There are two recommended ways to test and use Scala CLI:

- with brew:

```bash
```bash ignore
brew install virtuslab/scala-experimental/scala
```

- with coursier:

```bash
```bash ignore
cs setup
cs install scala-experimental ← this command will replace the default scala runner
```

Alternatively, you can rename your `scala-cli` executable or alias it as `scala`
Alternatively, you can rename your `scala-cli` executable or alias it as `scala`

0 comments on commit bd9f46a

Please sign in to comment.