diff --git a/.github/workflows/ci-book.yml b/.github/workflows/ci-book.yml new file mode 100644 index 0000000000..6c417ebb19 --- /dev/null +++ b/.github/workflows/ci-book.yml @@ -0,0 +1,30 @@ +# This workflow ensures the book can still be built. +# CI checking of Python code in the book happens in the regular CI pytest. + +name: CI - Book building + +on: + # Trigger the workflow on push or pull request, + # but only for the main branch, and if the book + # has been modified. + push: + branches: + - main + paths: + - docs/book/** + pull_request: + paths: + - docs/book/** + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v2.0.0 + with: + mdbook-version: '0.4.37' + + - run: mdbook build docs/book diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index 8bf9da0348..e5a14457e8 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -49,3 +49,9 @@ jobs: export PYTHONPATH=$(pwd) lit -v tests/filecheck/ lit -v docs/Toy/examples/ + + - name: Execute book tests + run: | + for f in docs/book/**/*.py; do + python "$f"; + done diff --git a/docs/book/book.toml b/docs/book/book.toml index cb6fbd378a..d990b78479 100644 --- a/docs/book/book.toml +++ b/docs/book/book.toml @@ -4,3 +4,6 @@ language = "en" multilingual = false src = "src" title = "The xDSL Book" + +[build] +create-missing = false diff --git a/docs/book/src/starting.md b/docs/book/src/starting.md index df03efe464..dfff932962 100644 --- a/docs/book/src/starting.md +++ b/docs/book/src/starting.md @@ -1,3 +1,7 @@ # Starting an xDSL project TODO: installation steps, environment setup + +```py +{{#include starting.py:test_op}} +``` diff --git a/docs/book/src/starting.py b/docs/book/src/starting.py new file mode 100644 index 0000000000..dbb58ade1f --- /dev/null +++ b/docs/book/src/starting.py @@ -0,0 +1,9 @@ +from xdsl.irdl import IRDLOperation, irdl_op_definition + +# fmt: off + +# ANCHOR: test_op +@irdl_op_definition +class SomeTestOp(IRDLOperation): + name = "some.test" +# ANCHOR_END: test_op