File tree Expand file tree Collapse file tree
extensions/mdbook/test/stitched Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ load ("@bazel_skylib//rules:build_test.bzl" , "build_test" )
2+ load ("//:defs.bzl" , "mdbook" )
3+
4+ # This shows how mdBook can include sources from anywhere in the
5+ # repository. However, because mdBook only processes files located
6+ # under the 'src' directory (as configured in book.toml), any files
7+ # from outside the book's package must be rebased into the 'src'
8+ # directory using genrules or other means. The rule's process_wrapper
9+ # ensures that the relative directory structure of these "stitched"
10+ # files is preserved in the temporary build directory.
11+
12+ mdbook (
13+ name = "stitched" ,
14+ srcs = [
15+ # The main navigation file for the book.
16+ "//test/stitched/src:SUMMARY.md" ,
17+ # A file rebased from a sibling directory into the book's src/
18+ # directory.
19+ "//test/stitched/src:rebased" ,
20+ # A file generated within a subpackage and placed in the
21+ # book's src/ directory.
22+ "//test/stitched/src:generated" ,
23+ ],
24+ book = "book.toml" ,
25+ )
26+
27+ build_test (
28+ name = "stitched_test" ,
29+ targets = [":stitched" ],
30+ )
Original file line number Diff line number Diff line change 1+ [book ]
2+ authors = [" Stitched Test" ]
3+ language = " en"
4+ src = " src"
5+ title = " Stitched Test Book"
Original file line number Diff line number Diff line change 1+ exports_files (["chapter_2.md" ])
Original file line number Diff line number Diff line change 1+ # Chapter 2
2+ Other source.
Original file line number Diff line number Diff line change 1+ exports_files (["SUMMARY.md" ])
2+
3+ # Rebase a file from a different directory into the book's source
4+ # directory. This is necessary because mdBook only processes files
5+ # located under the 'src' directory (as configured in book.toml).
6+ genrule (
7+ name = "rebased" ,
8+ srcs = ["//test/stitched/other_srcs:chapter_2.md" ],
9+ outs = ["chapter_2.md" ],
10+ cmd = "cp $< $@" ,
11+ visibility = ["//test/stitched:__pkg__" ],
12+ )
13+
14+ genrule (
15+ name = "generated" ,
16+ outs = ["chapter_3.md" ],
17+ cmd = "echo '# Chapter 3\n Generated source.' > $@" ,
18+ visibility = ["//test/stitched:__pkg__" ],
19+ )
Original file line number Diff line number Diff line change 1+ # Summary
2+
3+ - [ Chapter 1 (Local source)] ( chapter_1.md )
4+ - [ Chapter 2 (Rebased from sibling directory)] ( chapter_2.md )
5+ - [ Chapter 3 (Generated in subpackage)] ( chapter_3.md )
Original file line number Diff line number Diff line change 1+ # Chapter 1
2+ Local source.
You can’t perform that action at this time.
0 commit comments