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

Existing SUMMARY.md not taken into account #832

Closed
basbossink opened this issue Nov 26, 2018 · 2 comments · Fixed by #841
Closed

Existing SUMMARY.md not taken into account #832

basbossink opened this issue Nov 26, 2018 · 2 comments · Fixed by #841

Comments

@basbossink
Copy link
Contributor

I'm trying to bootstrap a book project however when running:

mdbook init 

in the root directory of the clone of the above mentioned repository the SUMMARY.md is overwritten and no additional files appart from the empty chapter_1.md are created in the src directory. While the documentation states:

Tip: Generate chapters from SUMMARY.md
When a SUMMARY.md file already exists, the init command will first parse it and generate the missing files according to the paths used in the SUMMARY.md. This allows you to think and create the whole structure of your book and then let mdBook generate it for you.

I've tried this on both Windows and the Windows subsystem for Linux. For the later the issue is also confirmed on a debug build of master with 005dfc55b as the HEAD.

@basbossink
Copy link
Contributor Author

Trying to move this issue along I was investigating by diving into the source but I don't see where an existing SUMMARY.md file is taken into account. Shouldn't book::init::create_stub_files check to see if an existing SUMMARY.md is present before creating a boilerplate one? A proposed fix is present in #841. Please provide some feedback if this analysis is somehow misguided or incomplete.

@phrohdoh
Copy link

phrohdoh commented May 8, 2019

I have run into this too.


I'm using mdbook and read https://rust-lang-nursery.github.io/mdBook/cli/init.html#tip-generate-chapters-from-summarymd which says:

When a SUMMARY.md file already exists, the init command will first parse it and generate the missing files according to the paths used in the SUMMARY.md. This allows you to think and create the whole structure of your book and then let mdBook generate it for you.

I have the following directory structure:

$ tree
.
└── SUMMARY.md

0 directories, 1 file

As you can see it is empty except for a SUMMARY.md file which has the following content:

- [Terminology](terminology.md)
- [1. Playing](sect-playing/README.md)
    - [1.1 Installing OpenRA](sect-playing/ch01-installing.md)
- [2. Modding](sect-modding/README.md)
    - [2.1. Getting Started](sect-modding/ch01-getting-started/README.md)
        - [2.1.1. Clone The Source Code](sect-modding/ch01-getting-started/cloning.md)
        - [2.1.2. Run The _Red Alert_ Mod](sect-modding/ch01-getting-started/run-ra.md)
    - [2.2. MiniYaml](sect-modding/ch02-miniyaml/README.md)
        - [2.1. Syntax Basics](sect-modding/ch02-miniyaml/syntax.md)
        - [2.2. A Real-World Example](sect-modding/ch02-miniyaml/example.md)
    - [2.?. Map Making](sect-modding/chXX-map-making/README.md)
        - [2.?.1. Map Editor 101](sect-modding/chXX-map-making/editor.md)
        - [2.?.2. Map Scripting 101](sect-modding/chXX-map-making/scripting.md)
    - [2.?. Campaign Creation](sect-modding/chXX-campaigns/README.md)
        - [2.?.1. What Isn't Yet Possible](sect-modding/chXX-campaigns/what-isnt-yet-possible.md)
    - [2.?. Utility](sect-modding/chXX-utility/README.md)
        - [2.?.1 Wiki](https://github.com/OpenRA/OpenRA/wiki/Utility)
        - [2.?.? Mod & Map Linting](sect-modding/chXX-utility/linting.md)
- [3. Developing](sect-developing/README.md)

After running mdbook init I have the following directory structure:

$ tree
.
├── SUMMARY.md
├── book
├── book.toml
└── src
    ├── SUMMARY.md
    └── chapter_1.md

2 directories, 4 files

Which does not have the structure I expect given the mdbook docs I quoted and the existing SUMMARY.md file.

Dylan-DPC-zz pushed a commit that referenced this issue May 8, 2019
* Add if around stub summary creation

Check if an existing SUMMARY.md is present to prevent overwriting it
with the stub SUMMARY.md.

[#832]

* Add test for existing SUMMARY.md
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this issue Aug 30, 2020
* Add if around stub summary creation

Check if an existing SUMMARY.md is present to prevent overwriting it
with the stub SUMMARY.md.

[rust-lang#832]

* Add test for existing SUMMARY.md
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

Successfully merging a pull request may close this issue.

2 participants