Skip to content

Commit fe76ee6

Browse files
authored
Merge pull request #2772 from ehuss/unreachable-pub
Enable unreachable_pub
2 parents 97d9078 + f6c062f commit fe76ee6

File tree

12 files changed

+22
-16
lines changed

12 files changed

+22
-16
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ complexity = { level = "warn", priority = -1 }
1313
[workspace.lints.rust]
1414
missing_docs = "warn"
1515
rust_2018_idioms = "warn"
16+
unreachable_pub = "warn"
1617

1718
[workspace.package]
1819
edition = "2024"

crates/mdbook-driver/src/load.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::io::{Read, Write};
99
use std::path::Path;
1010

1111
/// Load a book into memory from its `src/` directory.
12-
pub fn load_book<P: AsRef<Path>>(src_dir: P, cfg: &BuildConfig) -> Result<Book> {
12+
pub(crate) fn load_book<P: AsRef<Path>>(src_dir: P, cfg: &BuildConfig) -> Result<Book> {
1313
let src_dir = src_dir.as_ref();
1414
let summary_md = src_dir.join("SUMMARY.md");
1515

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub mod navigation;
2-
pub mod resources;
3-
pub mod theme;
4-
pub mod toc;
1+
pub(crate) mod navigation;
2+
pub(crate) mod resources;
3+
pub(crate) mod theme;
4+
pub(crate) mod toc;

crates/mdbook-html/src/html_handlebars/helpers/navigation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn render(
169169
t.render(r, &local_ctx, &mut local_rc, out)
170170
}
171171

172-
pub fn previous(
172+
pub(crate) fn previous(
173173
_h: &Helper<'_>,
174174
r: &Handlebars<'_>,
175175
ctx: &Context,
@@ -185,7 +185,7 @@ pub fn previous(
185185
Ok(())
186186
}
187187

188-
pub fn next(
188+
pub(crate) fn next(
189189
_h: &Helper<'_>,
190190
r: &Handlebars<'_>,
191191
ctx: &Context,

crates/mdbook-html/src/html_handlebars/helpers/resources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use handlebars::{
88

99
// Handlebars helper to find filenames with hashes in them
1010
#[derive(Clone)]
11-
pub struct ResourceHelper {
11+
pub(crate) struct ResourceHelper {
1212
pub hash_map: HashMap<String, String>,
1313
}
1414

crates/mdbook-html/src/html_handlebars/helpers/theme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use handlebars::{
33
};
44
use log::trace;
55

6-
pub fn theme_option(
6+
pub(crate) fn theme_option(
77
h: &Helper<'_>,
88
_r: &Handlebars<'_>,
99
ctx: &Context,

crates/mdbook-html/src/html_handlebars/helpers/toc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use mdbook_markdown::special_escape;
88

99
// Handlebars helper to construct TOC
1010
#[derive(Clone, Copy)]
11-
pub struct RenderToc {
11+
pub(crate) struct RenderToc {
1212
pub no_section_label: bool,
1313
}
1414

crates/mdbook-html/src/html_handlebars/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn tokenize(text: &str) -> Vec<String> {
2626
}
2727

2828
/// Creates all files required for search.
29-
pub fn create_files(
29+
pub(super) fn create_files(
3030
search_config: &Search,
3131
static_files: &mut StaticFiles,
3232
book: &Book,

crates/mdbook-html/src/html_handlebars/static_files.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::sync::LazyLock;
2020
/// and interprets the `{{ resource }}` directives to allow assets to name each other.
2121
///
2222
/// [fingerprinting]: https://guides.rubyonrails.org/asset_pipeline.html#fingerprinting-versioning-with-digest-based-urls
23-
pub struct StaticFiles {
23+
pub(super) struct StaticFiles {
2424
static_files: Vec<StaticFile>,
2525
hash_map: HashMap<String, String>,
2626
}
@@ -37,7 +37,7 @@ enum StaticFile {
3737
}
3838

3939
impl StaticFiles {
40-
pub fn new(theme: &Theme, html_config: &HtmlConfig, root: &Path) -> Result<StaticFiles> {
40+
pub(super) fn new(theme: &Theme, html_config: &HtmlConfig, root: &Path) -> Result<StaticFiles> {
4141
let static_files = Vec::new();
4242
let mut this = StaticFiles {
4343
hash_map: HashMap::new(),
@@ -156,7 +156,7 @@ impl StaticFiles {
156156
Ok(this)
157157
}
158158

159-
pub fn add_builtin(&mut self, filename: &str, data: &[u8]) {
159+
pub(super) fn add_builtin(&mut self, filename: &str, data: &[u8]) {
160160
self.static_files.push(StaticFile::Builtin {
161161
filename: filename.to_owned(),
162162
data: data.to_owned(),
@@ -165,7 +165,7 @@ impl StaticFiles {
165165

166166
/// Updates this [`StaticFiles`] to hash the contents for determining the
167167
/// filename for each resource.
168-
pub fn hash_files(&mut self) -> Result<()> {
168+
pub(super) fn hash_files(&mut self) -> Result<()> {
169169
use sha2::{Digest, Sha256};
170170
use std::io::Read;
171171
for static_file in &mut self.static_files {
@@ -224,7 +224,7 @@ impl StaticFiles {
224224
Ok(())
225225
}
226226

227-
pub fn write_files(self, destination: &Path) -> Result<ResourceHelper> {
227+
pub(super) fn write_files(self, destination: &Path) -> Result<ResourceHelper> {
228228
use mdbook_core::utils::fs::write_file;
229229
use regex::bytes::{Captures, Regex};
230230
// The `{{ resource "name" }}` directive in static resources look like

examples/nop-preprocessor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fn handle_supports(pre: &dyn Preprocessor, sub_args: &ArgMatches) -> ! {
7171

7272
/// The actual implementation of the `Nop` preprocessor. This would usually go
7373
/// in your main `lib.rs` file.
74+
#[allow(unreachable_pub, reason = "wouldn't be a problem in a proper lib.rs")]
7475
mod nop_lib {
7576
use super::*;
7677

0 commit comments

Comments
 (0)