diff --git a/doc/assets/bookdata.graphml b/doc/assets/bookdata.graphml new file mode 100644 index 00000000..e60ad73c --- /dev/null +++ b/doc/assets/bookdata.graphml @@ -0,0 +1,533 @@ + + + + + + + + + + + + + + + + + + + + + + + Config + + + + + + + + + + + + Book Content + + + + + + + + + + + CLI Args + + + + + + + + + + + + + + + + book.toml + + + + + + + + + + + + + + + + SUMMARY.md + + + + + + + + + + + + + + + + markdown +chapters + + + + + + + + + + + + + + + + template assets + + + + + + + + + + + + + + + + BookConfig + root +src +dest +template +renderer + + + + + + + + + + + + + + + + + + + Book + metadata +chapters + + + + + + + + + + + + + + + + + + + Renderer + render(book, config) + + + + + + + + + + + + + + + + + + + MDBook + books +config + + + + + + + + + + + + + + + + + + + images + + + + + + + + + + + + + + + + BookMetadata + title +author +publisher + + + + + + + + + + + + + + + + + + + Vec<Chapter> + title +file +sub_chapters + + + + + + + + + + + + + + + + + + + YAML headers +(optional) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + behaviour control, +paths, target format + + + + + + + + + + + + + + paths + + + + + + + + + + + + + + metadata + + + + + + + + + + + + + + + + + + + + chapter list + + + + + + + + + + + + + + chapter attributes +chapter content + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + renderer specific +data + + + + + + + + + + + + template path + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/assets/bookdata.png b/doc/assets/bookdata.png new file mode 100644 index 00000000..bcab50dc Binary files /dev/null and b/doc/assets/bookdata.png differ diff --git a/doc/assets/structs.png b/doc/assets/structs.png new file mode 100644 index 00000000..c250d832 Binary files /dev/null and b/doc/assets/structs.png differ diff --git a/doc/assets/structs.pum b/doc/assets/structs.pum new file mode 100644 index 00000000..3637ee69 --- /dev/null +++ b/doc/assets/structs.pum @@ -0,0 +1,142 @@ +@startuml + +class book::MDBook { + root + dest + src + theme_path + title + author + description + content : Vec + books : HashMap<&'a str, Book> + renderer + livereload +} + +class book::book.Book { + metadata + frontmatter + mainmatter + backmatter + + new(title) +} + +class book::bookconfig.BookConfig { + root + dest + src + theme_path + title + author + description + indent_spaces + multilingual + + new(root) +} + +class book::chapter.Chapter { + title + file + author + description + index + class + sub_chapters + + new(title, file) +} + +namespace book::bookitem { + +enum BookItem { + Chapter "String, Chapter" + Affix "Chapter" + Spacer +} + +class BookItems { + items : &'a [BookItem] + current_index + stack : Vec<"&'a [BookItem], usize"> +} + +class Chapter { + name + path + sub_items + + new(name, path) +} + +} + +namespace book::metadata { + +class BookMetadata { + title + subtitle + description + publisher + language + authors + translators + number_format + section_names + new(title) +} + +class Author { + name + email + new(name) +} + +class Language { + name + code +} + +class Publisher { + name + url + logo_src +} + +enum NumberFormat { + Arabic + Roman + Word +} + +} + +class renderer::html_handlebars::HtmlHandlebars { + new() + render(book: MDBook) +} + +class theme::Theme { + index + css + favicon + js + highlight_css + tomorrow_night_css + highlight_js + jquery + new(src) +} + +book::book-[hidden]->book::bookconfig +book::book-[hidden]->book::chapter +book::book-[hidden]->book::bookitem +book::book-[hidden]->book::metadata + +book::bookitem.BookItems-[hidden]->book::bookitem.BookItem + +renderer::html_handlebars::HtmlHandlebars-[hidden]->theme::Theme + +@enduml diff --git a/doc/doc.md b/doc/doc.md new file mode 100644 index 00000000..27ae47a5 --- /dev/null +++ b/doc/doc.md @@ -0,0 +1,78 @@ +# Doc + +Diagrams are with [yEd](http://www.yworks.com/products/yed) and [plantuml](http://plantuml.com). + +## Data + +![book data](assets/bookdata.png) + +### Renderer + +Takes data from: + +- a book's metadata and chapters (`Book`) +- paths and behaviour config (`BookConfig`) +- template assets (`template_path`) + +For generating pages: + +Book metadata, `BookMetadata` (title, author, publisher, etc.). Just recognize +those properties which can be easily anticipated. + +If Renderer needs more specific data, it can be supplied in `book.toml`. It's +the Renderer's job to open that and parse it out. + +Chapters, `Vec`. + +If the user wants to store attributes that are not anticipated with structs, +they can go in a hashmap with string keys, let them be accessible from the +templates with helpers. + +For generating output: + +- template assets, `template-path`, renderer does whatever it wants with it +- config (root, dest, etc. folders) + +Renderer is seleceted by CLI or default (html). Each book is passed to this +renderer. + +### Config + +Takes data from: + +- CLI args +- book.json + +## Structs + +### Currently + +Already almost good for implementing the above. + +Storing data attributes can be reorganized. + +Modules could be refactored to express intention more clearly. + +![structs](assets/structs.png) + +## Notes + +There could be less modules. Merge modules which express one intention. + +The two Chapter structs could be refactored out. + +Take config paths for as many things as possible. Let the user organize their +project folder differently, or allow `mdbook` to function in existing projects +with already established folders. + +Add config path for `SUMMARY.md`. Default is good to be in `src/`, it allows +chapter links to work when reading the file on Github. + +The init command should copy the assets folder by default, it is better to make +this choice for new users. + +The specific assets (CSS, templates, etc.) are closely coupled with the book +content when the user is writing it. If the templates change when mdbook +develops, this changes the output in a way the user doesn't expect, maybe even +breaking their book. +