Skip to content

Ignore files listed in .mdbookignore during build - #3229

Open
Chocorean wants to merge 1 commit into
rust-lang:mainfrom
Chocorean:dev_ignore
Open

Chocorean wants to merge 1 commit into
rust-lang:mainfrom
Chocorean:dev_ignore

Conversation

@Chocorean

@Chocorean Chocorean commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1187
Fixes #2224
Fixes #1156
Fixes #2246

Hopefully this is not just another duplicate and will act as a summary for the state of the "ignore" feature of mdbook.

This is a merge of #1908 onto main, with conflicts fixed.

As far as I have found, it would:

  1. close:
  1. supersede:

EDIT:

This PR adds the support for a .mdbookignore file, found under src/, which acts as a ignore system to prevent the inclusion of specific files in the output directory.

I believe all the comments from #1908 were addressed

@rustbot ready

@Chocorean Chocorean changed the title Ignore files listed in .mdbookignore during build - #1908 Ignore files listed in .mdbookignore during build Sep 27, 2026

@Chocorean Chocorean Sep 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't .mdbookignore be ignored by default? seems odd to me to include it

View changes since the review

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Sep 28, 2026
@Chocorean
Chocorean marked this pull request as ready for review September 28, 2026 01:31

@DanielEScherzer DanielEScherzer left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

community review: some suggestions

View changes since this review

Comment thread crates/mdbook-core/src/utils/fs.rs Outdated
Comment thread crates/mdbook-core/src/utils/fs.rs
Comment thread guide/src/format/configuration/renderers.md Outdated
@Chocorean

Copy link
Copy Markdown
Contributor Author

@DanielEScherzer Hello there, thanks for the review! I agree with you on all points. I reverted the unrelated changes and applied your suggestion

@GuillaumeGomez GuillaumeGomez left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some small nits but otherwise looks good to me. Thanks for the PR and thanks @DanielEScherzer for the review!

View changes since this review

Comment thread crates/mdbook-html/src/html_handlebars/hbs_renderer.rs Outdated
Comment thread Cargo.toml Outdated
@rustbot rustbot added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: waiting on a review labels Oct 1, 2026
@rustbot

rustbot commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Chocorean

Copy link
Copy Markdown
Contributor Author

Comments addressed ! @rustbot ready

@rustbot rustbot added S-waiting-on-review Status: waiting on a review and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels Oct 1, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member

Time to squash all commits now. :)

ensure the original *.md filtering still happens

replace warn by error when cannot load mdbookignore file

revert unrelated changes

Update crates/mdbook-core/src/utils/fs.rs

Co-authored-by: Daniel Scherzer <daniel.e.scherzer@gmail.com>

Update crates/mdbook-html/src/html_handlebars/hbs_renderer.rs

Co-authored-by: Guillaume Gomez <contact@guillaume-gomez.fr>

revert deps order

remove extra bracket

Update crates/mdbook-core/src/utils/fs.rs

Co-authored-by: Daniel Scherzer <daniel.e.scherzer@gmail.com>

revert deps order
@Chocorean

Copy link
Copy Markdown
Contributor Author

@GuillaumeGomez I hope I got this right

@GuillaumeGomez

Copy link
Copy Markdown
Member

Looks all good to me, thanks! Since it's a new feature, let's ping the rest of the team.

@rfcbot fcp merge mdbook

@rust-rfcbot rust-rfcbot added the T-mdbook Necessary for rfcbot to work correctly right now label Oct 1, 2026
@rust-rfcbot

rust-rfcbot commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

@GuillaumeGomez has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@notriddle

notriddle commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Git, and systems like Git, allow you to put an ignore file in a subdirectory, allowing you to apply the rules to a particular scope. It doesn't seem to be working.

$ echo "thunk.txt" > src/misc/.mdbookignore
$ echo "my think" > src/misc/thunk.txt
$ ../target/release/mdbook build
 INFO Book building has started
 INFO Running the html backend
 INFO HTML book written to `/Users/michaelhowell/mdBook/guide/book`
$ ls -a book/misc
.			.mdbookignore		thunk.txt
..			contributors.html

It only works when I put it in the root directory.

$ rm -rf book
$ echo "thunk.txt" > src/.mdbookignore
$ ../target/release/mdbook build
 INFO Book building has started
 INFO Running the html backend
 INFO HTML book written to `/Users/michaelhowell/mdBook/guide/book`
$ ls -a book/misc
.			.mdbookignore
..			contributors.html

(If we're not going to implement it, then it shouldn't be a hidden file. Just make it a list of rules in book.toml.)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge proposed-final-comment-period T-mdbook Necessary for rfcbot to work correctly right now

Projects

None yet

7 participants