Commit Graph

30 Commits

Author SHA1 Message Date
Michael Bryan d39352aa45 Unit tests now all pass 2017-09-30 16:00:21 +08:00
Michael Bryan 02d1d9317d Started cleaning up some of the lints and warnings 2017-09-30 15:52:46 +08:00
Michael Bryan 4202ead962 Started integrating some of the feedback from budziq 2017-09-30 15:52:46 +08:00
Michael Bryan 1b5a58902f Created a Loader for loading a book using the Summary
This is a squashed commit. It roughly encompasses the following changes.

---

\# Book

- Created another private submodule, mdbook::loader::book

- This submodule contains the data types representing a Book

- For now the Book just contains a list of BookItems (either chapters or
separators)

- A Chapter contains its name, contents (as one long string), an
optional section number (only numbered chapters have numbers,
obviously), and any nested chapters

- There's a function for loading a single Chapter from disk using it's
associated Link entry from the SUMMARY.md

- Another function builds up the Book by recursively visiting all Links
and separators in the Summary and joining them into a single
Vec<SummaryItem>. This is the only non-dumb-data-type item which is
actually exported from the book module

\# Loader

- Made the loader use the book::load_book_from_disk function for
loading a book in the loader's directory.

\# Tests

- Made sure you can load from disk by writing some files to a temporary
directory

- Made sure the Loader can load the entire example-book from disk and
doesn't crash or hit an error

- Increased test coverage from 34.4% to 47.7% (as reported by cargo
kcov)
2017-09-30 15:52:46 +08:00
Michael Bryan 6d0d4bf379 Created a SUMMARY.md parser and basic Loader
From the [pull request comment][pr], here's a rough summary of what
was done in the squashed commits.

---

\# Summary Parser

- Added a private submodule called `mdbook::loader::summary` which
contains all the code for parsing `SUMMARY.md`

- A `Summary` contains a title (optional), then some prefix, numbered,
and suffix chapters (technically `Vec<SummaryItem>`)

- A `SummaryItem` is either a `Link` (i.e. link to a chapter), or a
separator

- A `Link` contains the chapter name, its location relative to the
book's `src/` directory, and a list of nested `SummaryItems`

- The `SummaryParser` (a state machine-based parser) uses
`pulldown_cmark` to turn the `SUMMARY.md` string into a stream of
`Events`, it then iterates over those events changing its behaviour
depending on the current state,

  - The states are `Start`, `PrefixChapters`, `NestedChapters(u32)` (the
  `u32` represents your nesting level, because lists can contain lists),
  `SuffixChapters`, and `End`

  - Each state will read the appropriate link and build up the
  `Summary`, skipping any events which aren't a link, horizontal rule
  (separator), or a list

\# Loader

- Created a basic loader which can be used to load the `SUMMARY.md` in
a directory.

\# Tests

- Added a couple unit tests for each state in the parser's state
machine

- Added integration tests for parsing a dummy SUMMARY.md then asserting
the result is exactly what we expected

[pr]: https://github.com/azerupi/mdBook/pull/371#issuecomment-312636102
2017-09-30 15:52:46 +08:00
Behnam Esfahbod 956a5cc7fd Fix heading links in nested pages
Plus fixing the whitespace chars not being replaced by hyphen.

Also expand tests for link creations, and add test for nested pages.

Fixes <https://github.com/azerupi/mdBook/issues/416>
Fixes <https://github.com/azerupi/mdBook/issues/417>
2017-09-06 00:52:17 -07:00
Behnam Esfahbod cef62ec42e Fix build and test warnings
Move non-test test module files into their own directories to prevent
cargo from running them as tests. Then suppress the left-over warnings.

Move *dummy book* code and data into a shared folder, and leave the rest
of helper utilities (one function) in the original module.
2017-09-06 00:52:17 -07:00
projektir 16aa545c5b Integrating Ace #247 2017-08-03 22:45:33 -04:00
Michael Bryan e2eb40bded Got some feedback from azerupi and added a DummyBook builder 2017-08-02 22:29:28 +08:00
Michael Bryan 0c3a2b80f8 Tested MDBook::init with custom args 2017-07-10 18:23:51 +08:00
Michael Bryan 29e00c0d97 Broke the integration tests out into individual sections 2017-07-10 18:17:19 +08:00
Michael Bryan 7e8819f4d2 Bye bye println() debugging 2017-07-09 22:08:57 +08:00
Michael Bryan c90c0f7848 Updated the book testing to take into account #340 2017-07-09 20:02:31 +08:00
Michael Bryan cd11035a69 trivial change to make travis run again 2017-07-09 19:59:29 +08:00
Michael Bryan 8b7c95e02f Made sure the rendered content actually contains the original text 2017-07-09 19:59:29 +08:00
Michael Bryan e3f047a35d Added playpen and mdbook init tests 2017-07-09 19:59:29 +08:00
Michael Bryan 9fab267da1 Added some end-user "sanity" tests 2017-07-09 19:59:29 +08:00
Michal Budzynski b1ca9cf5b5 HtmlConfig is no longer optional
`HtmlConfig` was both guaranteed to exist within `BookConfig`
and `expect`ed in few places.
This simplifies the API a little by representing the fact that
`HtmlConfig` is currently mandatory for proper mdBook binary operation.
2017-06-27 14:01:33 +02:00
Michal Budzynski b3c9ba4555 Correct clippy nits 2017-06-27 09:08:58 +02:00
Michal Budzynski db94b3d839 Add minimal testing for the optional MathJax support 2017-06-25 00:39:57 +02:00
Michal Budzynski 6d8ac6a23c Fixes missing the default "theme" dir location
if not specified in book.toml
2017-06-23 13:29:46 +02:00
Mathieu David 28afebdca2 Merge branch 'minor_refactor' of https://github.com/budziq/mdBook into budziq-minor_refactor 2017-06-23 01:09:26 +02:00
Mathieu David 26fc980ffb Remove 'curly_quotes' key from the json config 2017-06-23 00:48:59 +02:00
Jimmy Do 193f014a5b Add an option to convert to curly quotes when rendering to HTML 2017-06-18 10:11:04 -07:00
Michal Budzynski e8908e32c9 Minor cleanup
- removing need to explicitly use `Path::new` all over the place
- removed warnings from doctests (normally invisible unless `cargo test -- --nocapture`)
- no doctests are norun/ignore now
- updated docs both in book-example and in docs not to refer to nonexisting API's
2017-06-14 21:55:42 +02:00
Michal Budzynski f96e7e5cba Implemented support for additional JS 2017-06-11 15:08:09 +02:00
Mathieu David bb4ceb481f Allow an additional custom stylesheets, closes #178 2017-06-04 20:41:31 +02:00
Mathieu David c6bfe0b1d7 Adds a test for #240 2017-06-04 20:41:31 +02:00
Mathieu David 70383d0a25 New config structs supports json again (the old style) for a little deprecation period 2017-06-04 20:41:31 +02:00
Mathieu David 170bf8b1eb New configuration struct + tests #285 2017-06-04 20:41:31 +02:00