Include `src/README.md` as prefix chapter with `--auto-summary`.
This commit is contained in:
parent
f767167808
commit
20eacd2976
|
@ -76,6 +76,7 @@ impl Summary {
|
|||
/// The file/folder name is used to compose the chapter's link.
|
||||
///
|
||||
/// Chapters are added to the book in alphabetical order, using the file/folder name.
|
||||
/// If a `src_dir/README.md` file is present, it is included as a prefix chapter.
|
||||
pub fn from_sources<P: AsRef<Path>>(src_dir: P) -> std::io::Result<Summary> {
|
||||
let mut summary = Summary {
|
||||
title: None,
|
||||
|
@ -144,6 +145,13 @@ impl Summary {
|
|||
}
|
||||
}
|
||||
|
||||
// Special case for the `src/README.md` file.
|
||||
let root_readme_path = src_dir.as_ref().join("README.md");
|
||||
if root_readme_path.is_file() {
|
||||
let link = Link::new_unnamed(root_readme_path);
|
||||
summary.prefix_chapters.push(SummaryItem::Link(link))
|
||||
}
|
||||
|
||||
summary.numbered_chapters = read_dir(src_dir)?;
|
||||
number_items(&mut summary.numbered_chapters, &[]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue