Skip to content
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

Support for draft chapters #32

Closed
3 tasks
ophilli opened this issue May 22, 2024 · 1 comment
Closed
3 tasks

Support for draft chapters #32

ophilli opened this issue May 22, 2024 · 1 comment

Comments

@ophilli
Copy link
Contributor

ophilli commented May 22, 2024

Problem

The presence of a draft chapter in a SUMMARY.md causes mdbook-combiner to panic.

Details

Per https://rust-lang.github.io/mdBook/format/summary.html

Draft chapters are chapters without a file and thus content. The purpose of a draft chapter is to signal future chapters still to be written. Or when still laying out the structure of the book to avoid creating the files while you are still changing the structure of the book a lot. Draft chapters will be rendered in the HTML renderer as disabled links in the table of contents, as you can see for the next chapter in the table of contents on the left. Draft chapters are written like normal chapters but without writing the path to the file.

- [Draft Chapter]()

Repro

Steps

mkdir draft-chapters      
               
cat <<EOF > draft-chapters/SUMMARY.md          
- [Draft Chapter]()
EOF

RUST_BACKTRACE=1 mdbook-combiner --meta-directory draft-chapters

Example

oap@Owens-MBP ~ % mkdir draft-chapters      

cat <<EOF > draft-chapters/SUMMARY.md
- [Draft Chapter]()
EOF

RUST_BACKTRACE=1 mdbook-combiner --meta-directory draft-chapters
"draft-chapters"
thread 'main' panicked at /Users/oap/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mdbook-combiner-0.1.15/src/main.rs:169:41:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:144:5
   3: mdbook_combiner::rebase
   4: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
   5: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
   6: mdbook_combiner::rebase_summary
   7: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   8: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   9: mdbook_combiner::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
oap@Owens-MBP ~ % 

Possible TODOs:

  • Improve the error message in case of draft chapters
  • Support draft chapters
  • Add a test to cover draft chapters
@jscarrott
Copy link
Owner

Hopefully, a fix for this has just gone in, this project really needs some tests. As it now has at least 1 other user I might have some motivation to add them. #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants