Skip to content

feat(mdbook): allow default configuration - #4207

Open
tomatotomata wants to merge 3 commits into
bazelbuild:mainfrom
tomatotomata:codex/mdbook-default-config
Open

feat(mdbook): allow default configuration#4207
tomatotomata wants to merge 3 commits into
bazelbuild:mainfrom
tomatotomata:codex/mdbook-default-config

Conversation

@tomatotomata

Copy link
Copy Markdown

Summary

  • make the book attribute optional for the mdbook rule
  • generate an empty book.toml so mdBook uses its documented default configuration
  • add a build test covering a book with only src/SUMMARY.md and chapter sources

This addresses #4194. The issue discussion asked for a PR that demonstrates mdBook can run without a user-provided book.toml; an empty configuration parses to mdBook's defaults, including src as the source directory. I kept the generated file in the package staging tree so the existing input mapping and mdbook_server provider continue to use the same config path. Let me know what you think.

Validation

  • git diff --check passed
  • inspected mdBook 0.4.44 configuration defaults: an empty TOML file loads src as the source directory
  • Bazel execution was not available in this Windows environment, so the new build target is left for the repository CI matrix

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I had just one question

doc = "Information about a `mdbook` target.",
fields = {
"config": "File: The `book.toml` file.",
"config_dest": "String: The path of the configuration file in the staged book.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this added to the provider? Is it not inferred by config still? The only difference (which one could consider an existing bug) is if config was ever generated the dirname call would be wrong, right? If that's the case I would make a heuristic on owner or short_path to get the right location.

@tomatotomata tomatotomata Aug 11, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this too. For an explicitly supplied book.toml, config is enough and _src_dest_path(book_info.config) matches the existing staged path. The generated default is different: its declared output short_path is under Bazel output, so deriving the server --config path from config would point outside the staged book directory. The provider config_dest keeps both cases explicit and avoids an owner/short_path heuristic. I also pushed 95bbe23 to match buildifier formatting for the doc string. Let me know what you think about keeping the provider field for that generated-file case.

Signed-off-by: ahmadalguydi <ahmadalgaidy@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants