This is a mdbook
preprocessor that will walk a specified base path and add all
the markdowns to your mdbook
. This is pretty naive and will probably work best
for smaller projects but feel free to give it a go for any folder structure!
The preprocessor can be configured with the following settings:
[preprocessor.all-the-markdowns]
# This will mark all folders generated for a proper index as draft, making them
# non clickable. By default this is false and the content will just be the name
# of the folder as title.
draft-folders = true
# If you want to allow more or other files than `README.md` to be treated as top
# level index files you can specify them in `index-filenames`.
index-filenames = ["README.md", "index.md"]
[[preprocessor.all-the-markdowns.section]]
# The title to use in the index on the left. Can be useful if book also consist
# of static content or if creating multiple sections.
title = "Auto generated"
# The base directory to find markdowns in, this is usually the root of your
# project if you're only creating a single section.
base = "./examples/example-folder-structures/slim"
# Paths to ignore. No matter where you set your base you can always ignore given
# patterns. These needs to be relative to the base since the directory traverser
# will match if a file or director _starts with_ any of these patterns.
ignore = []
Since section
is a list of tables you can add multiple groups by adding
multiple sections.
[preprocessor.all-the-markdowns]
[[preprocessor.all-the-markdowns.section]]
title = "Libraries"
base = "./examples/example-folder-structures/slim/my-libraries"
ignore = []
[[preprocessor.all-the-markdowns.section]]
title = "Services"
base = "./examples/example-folder-structures/slim/my-services"
ignore = []
Given the following folder structure:
.
βββ my-libraries
βΒ Β βββ lib-biz
βΒ Β βββ INSTALLATION.md
βΒ Β βββ README.md
βΒ Β βββ sub-lib-a
βΒ Β βΒ Β βββ CONTRIBUTORS.md
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ USAGE.md
βΒ Β βββ sub-lib-b
βΒ Β βββ README.md
βββ my-services
βββ service-bar
βΒ Β βββ README.md
βΒ Β βββ infra
βΒ Β βββ kubernetes
βΒ Β βββ README.md
βββ service-foo
βββ README.md
Based on the title in each document, combined with the folder names as title case, the preprocessor with the first configuration would render the following:
Result with the first example with one section. | Result with the second example with multiple sections. |
You can test rendering any of the example folders in this directory with the
book found in examples/book1
with mdbook serve examples/book1
.