Skip to content

Add build.static-files-dir config option #2755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link
Member

This PR adds support for a new build.static-files-dir config option. It only targets static files, not custom ones. The goal is, when rustdoc officially supports to generate mdbook alongside the API docs, to make this integration easier for docs.rs:

  1. To prevent static files duplication.
  2. To prevent needing to rewrite URLs like we do with rustdoc files.

I tested this feature locally with:

diff --git a/test_book/book.toml b/test_book/book.toml
index 854b5e7d3..ad5b183af 100644
--- a/test_book/book.toml
+++ b/test_book/book.toml
@@ -7,6 +7,9 @@ language = "en"
 [rust]
 edition = "2018"
 
+[build]
+static-files-dir = "/tmp/static"
+
 [output.html]
 mathjax-support = true
 hash-files = true

It's working as expected, files were generated in /tmp/static and URLs were pointing to this folder.

Now, some questions: what would be the best way to test it in a unit test?

And finally: @syphar, would it be ok for docs.rs (speaking hypothetically for something that hopefully will be supported by rustdoc in the future) to use this new static folder option to generate static files directly in a /-/mdbook folder (since we use docker, I suppose we can cheat by creating a /- folder in any case)? Like that the URLs are already all valid so no need to update them when serving the book files and files are hashed.

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: waiting on a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants