rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.62k stars 1.61k forks source link

Refactor the book structure into its own type #359

Closed Michael-F-Bryan closed 6 years ago

Michael-F-Bryan commented 7 years ago

The in-memory representation of a book is currently really tightly tied into MdBook and has a lot of functionality that it probably doesn't need. This complicates the current library quite a bit, makes testing difficult because you often need to create a temporary book on disk, and makes it hard to implement much-desired features like plugins and alternate renderers.

My thoughts are that a "book" should be a super simple tree data structure which represents the source files making up the book, then contain the chapters' text as a simple string. It shouldn't really have any behaviour, instead it'll use a Loader object (sorry, names are hard :disappointed: ) which will parse the SUMMARY.md and use it to construct a Book in memory.

This issue should act as an overall tracker for the changes necessary to make working with the book structure easier, dealing with the "book representation" part of #90. I'm planning to make a separate PR for each of the following:

Some questions which may need addressing:

Are there any other questions which should be addressed, or tasks which may fall under refactoring the internal representation of a book?

cc: @azerupi @budziq

Michael-F-Bryan commented 6 years ago

This was fixed in #491.