mdBook icon indicating copy to clipboard operation
mdBook copied to clipboard

Configuration file & Configuration inheritance

Open carlocorradini opened this issue 6 months ago • 0 comments

Problem

Assume that I am creating the book as a PDF file using the mdbook-pdf plugin and verifying all of the links with the mdbook-linkcheck plugin. The process of validating links and creating the PDF file, which is mostly required only for book releases, takes a significant amount of time, and the development process (using mdbook serve) suffers because the book has to be rebuilt for every change. Removing [output.pdf] and [output.linkcheck] manually from book.toml is the only way to resolve this, and don't forget to add them back before committing! The entire process is excessively error-prone and tedious.

It would be really useful if mdbook had a command line parameter for customizing the configuration file. Furthermore, supports configuration inheritance to prevent needless duplications. This means that all common configurations (such as title, description, author, etc.) can be contained in a base configuration file, and the latter can be extended by additional configuration files based on the context (like development and release).

The entire feature should be similar to TypeScript extends.

Proposed Solution

  1. Custom configuration file

    If omitted defaults to book.toml

    mdbook --config path/to/book.toml
    
  2. Configuration inheritance

    book.dev.toml

    [book]
    title = "Book"
    
    # ...
    

    book.toml

    extends = "./book.dev.toml"
    
    [output.pdf]
    
    [output.linkcheck]
    follow-web-links = true
    warning-policy = "error"
    

Notes

No response

carlocorradini avatar Dec 14 '23 11:12 carlocorradini