Enable unreachable_pub
This lint can help make it clearer which items are actually exposed in the public API.
This commit is contained in:
parent
97d9078a32
commit
f6c062fc98
12 changed files with 22 additions and 16 deletions
|
|
@ -13,6 +13,7 @@ complexity = { level = "warn", priority = -1 }
|
||||||
[workspace.lints.rust]
|
[workspace.lints.rust]
|
||||||
missing_docs = "warn"
|
missing_docs = "warn"
|
||||||
rust_2018_idioms = "warn"
|
rust_2018_idioms = "warn"
|
||||||
|
unreachable_pub = "warn"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use std::io::{Read, Write};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
/// Load a book into memory from its `src/` directory.
|
/// Load a book into memory from its `src/` directory.
|
||||||
pub fn load_book<P: AsRef<Path>>(src_dir: P, cfg: &BuildConfig) -> Result<Book> {
|
pub(crate) fn load_book<P: AsRef<Path>>(src_dir: P, cfg: &BuildConfig) -> Result<Book> {
|
||||||
let src_dir = src_dir.as_ref();
|
let src_dir = src_dir.as_ref();
|
||||||
let summary_md = src_dir.join("SUMMARY.md");
|
let summary_md = src_dir.join("SUMMARY.md");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
pub mod navigation;
|
pub(crate) mod navigation;
|
||||||
pub mod resources;
|
pub(crate) mod resources;
|
||||||
pub mod theme;
|
pub(crate) mod theme;
|
||||||
pub mod toc;
|
pub(crate) mod toc;
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ fn render(
|
||||||
t.render(r, &local_ctx, &mut local_rc, out)
|
t.render(r, &local_ctx, &mut local_rc, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn previous(
|
pub(crate) fn previous(
|
||||||
_h: &Helper<'_>,
|
_h: &Helper<'_>,
|
||||||
r: &Handlebars<'_>,
|
r: &Handlebars<'_>,
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
|
|
@ -185,7 +185,7 @@ pub fn previous(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next(
|
pub(crate) fn next(
|
||||||
_h: &Helper<'_>,
|
_h: &Helper<'_>,
|
||||||
r: &Handlebars<'_>,
|
r: &Handlebars<'_>,
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use handlebars::{
|
||||||
|
|
||||||
// Handlebars helper to find filenames with hashes in them
|
// Handlebars helper to find filenames with hashes in them
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ResourceHelper {
|
pub(crate) struct ResourceHelper {
|
||||||
pub hash_map: HashMap<String, String>,
|
pub hash_map: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use handlebars::{
|
||||||
};
|
};
|
||||||
use log::trace;
|
use log::trace;
|
||||||
|
|
||||||
pub fn theme_option(
|
pub(crate) fn theme_option(
|
||||||
h: &Helper<'_>,
|
h: &Helper<'_>,
|
||||||
_r: &Handlebars<'_>,
|
_r: &Handlebars<'_>,
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use mdbook_markdown::special_escape;
|
||||||
|
|
||||||
// Handlebars helper to construct TOC
|
// Handlebars helper to construct TOC
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct RenderToc {
|
pub(crate) struct RenderToc {
|
||||||
pub no_section_label: bool,
|
pub no_section_label: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ fn tokenize(text: &str) -> Vec<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates all files required for search.
|
/// Creates all files required for search.
|
||||||
pub fn create_files(
|
pub(super) fn create_files(
|
||||||
search_config: &Search,
|
search_config: &Search,
|
||||||
static_files: &mut StaticFiles,
|
static_files: &mut StaticFiles,
|
||||||
book: &Book,
|
book: &Book,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use std::sync::LazyLock;
|
||||||
/// and interprets the `{{ resource }}` directives to allow assets to name each other.
|
/// and interprets the `{{ resource }}` directives to allow assets to name each other.
|
||||||
///
|
///
|
||||||
/// [fingerprinting]: https://guides.rubyonrails.org/asset_pipeline.html#fingerprinting-versioning-with-digest-based-urls
|
/// [fingerprinting]: https://guides.rubyonrails.org/asset_pipeline.html#fingerprinting-versioning-with-digest-based-urls
|
||||||
pub struct StaticFiles {
|
pub(super) struct StaticFiles {
|
||||||
static_files: Vec<StaticFile>,
|
static_files: Vec<StaticFile>,
|
||||||
hash_map: HashMap<String, String>,
|
hash_map: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +37,7 @@ enum StaticFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StaticFiles {
|
impl StaticFiles {
|
||||||
pub fn new(theme: &Theme, html_config: &HtmlConfig, root: &Path) -> Result<StaticFiles> {
|
pub(super) fn new(theme: &Theme, html_config: &HtmlConfig, root: &Path) -> Result<StaticFiles> {
|
||||||
let static_files = Vec::new();
|
let static_files = Vec::new();
|
||||||
let mut this = StaticFiles {
|
let mut this = StaticFiles {
|
||||||
hash_map: HashMap::new(),
|
hash_map: HashMap::new(),
|
||||||
|
|
@ -156,7 +156,7 @@ impl StaticFiles {
|
||||||
Ok(this)
|
Ok(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_builtin(&mut self, filename: &str, data: &[u8]) {
|
pub(super) fn add_builtin(&mut self, filename: &str, data: &[u8]) {
|
||||||
self.static_files.push(StaticFile::Builtin {
|
self.static_files.push(StaticFile::Builtin {
|
||||||
filename: filename.to_owned(),
|
filename: filename.to_owned(),
|
||||||
data: data.to_owned(),
|
data: data.to_owned(),
|
||||||
|
|
@ -165,7 +165,7 @@ impl StaticFiles {
|
||||||
|
|
||||||
/// Updates this [`StaticFiles`] to hash the contents for determining the
|
/// Updates this [`StaticFiles`] to hash the contents for determining the
|
||||||
/// filename for each resource.
|
/// filename for each resource.
|
||||||
pub fn hash_files(&mut self) -> Result<()> {
|
pub(super) fn hash_files(&mut self) -> Result<()> {
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
for static_file in &mut self.static_files {
|
for static_file in &mut self.static_files {
|
||||||
|
|
@ -224,7 +224,7 @@ impl StaticFiles {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_files(self, destination: &Path) -> Result<ResourceHelper> {
|
pub(super) fn write_files(self, destination: &Path) -> Result<ResourceHelper> {
|
||||||
use mdbook_core::utils::fs::write_file;
|
use mdbook_core::utils::fs::write_file;
|
||||||
use regex::bytes::{Captures, Regex};
|
use regex::bytes::{Captures, Regex};
|
||||||
// The `{{ resource "name" }}` directive in static resources look like
|
// The `{{ resource "name" }}` directive in static resources look like
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ fn handle_supports(pre: &dyn Preprocessor, sub_args: &ArgMatches) -> ! {
|
||||||
|
|
||||||
/// The actual implementation of the `Nop` preprocessor. This would usually go
|
/// The actual implementation of the `Nop` preprocessor. This would usually go
|
||||||
/// in your main `lib.rs` file.
|
/// in your main `lib.rs` file.
|
||||||
|
#[allow(unreachable_pub, reason = "wouldn't be a problem in a proper lib.rs")]
|
||||||
mod nop_lib {
|
mod nop_lib {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
//! The mdbook CLI.
|
//! The mdbook CLI.
|
||||||
|
|
||||||
|
#![allow(unreachable_pub, reason = "not needed in a bin crate")]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
//!
|
//!
|
||||||
//! See README.md for documentation.
|
//! See README.md for documentation.
|
||||||
|
|
||||||
|
#![allow(unreachable_pub, reason = "not needed in an integration test crate")]
|
||||||
|
|
||||||
mod book_test;
|
mod book_test;
|
||||||
mod build;
|
mod build;
|
||||||
mod cli;
|
mod cli;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue