Files
docs-rust/README.md
2026-06-22 21:27:36 +05:30

3.4 KiB

Dewey's Rustbook Build

All redundant assets (CSS files, JS bundles, custom fonts, themes, and favicons) have been removed. The HTML pages have been cleaned up in place to keep only the structural content, organized into folders, and their relative links updated.

Setup and Cleanup Script

The cleanup and folder organization are powered by clean_book.py.

What the script does:

  1. HTML Clean-up: For each HTML file, it extracts only the main content inside the <main>...</main> tag (or fallback to <body>), and strips out the header scripts, navigation sidebar wrappers, theme toggles, templates, search panels, and footer navigation.
  2. Title Optimization: It extracts the page title and cleans up the redundant suffix ( - The Rust Programming Language) for a shorter context title.
  3. Asset Deletion: It recursively deletes redundant stylesheets (.css), javascript scripts (.js), favicons, web fonts, theme subdirectories, and decorative icons (such as Ferris badges inside img/ferris/).
  4. Folder Organization: It moves pages into organized subdirectories:
    • Chapters (ch00-xx, ch01-xx, ..., ch21-xx) are grouped into folders like ch01/, ch02/, etc.
    • Appendices are moved to the appendix/ folder.
    • Conceptual illustrations/diagrams are preserved and moved to img/.
  5. Relative Link Rewriting: It parses all link (href="...") and image (src="...") tags, and updates their paths relative to their new nested folder depth (e.g. replacing a link with ../ch02/ch02-00-guessing-game-tutorial.html or an image path with ../img/trpl15-01.svg as necessary).
  6. Build Directory Cleanup: Deletes the raw build/ folder completely once processing is finished.

Repository Layout

  • toc.html: The Table of Contents list page (root of the repo).
  • print.html: The single-page version of the entire book, containing all chapters in one clean, continuous document (1.8MB). This is highly recommended for single-file ingestion.
  • index.html: The landing page of the book.
  • foreword.html: The foreword of the book.
  • title-page.html: The title page.
  • ch01/ to ch21/: Respective chapter subdirectories containing the topics (e.g., ch01/ch01-01-installation.html).
  • appendix/: Subdirectory containing all appendix pages.
  • img/: Conceptual illustrations referenced by the text.

How to Run Again

If the book is rebuilt (which regenerates the raw build/ output folder), you can run the script to re-clean and re-organize everything back to the repository layout in one step:

python3 clean_book.py