Commit Graph

638 Commits

Author SHA1 Message Date
Michael Bryan 92f0fa0aba Started working on a MDBookBuilder 2017-08-03 00:30:46 +08:00
Michael Bryan ed83e0ec10 Updated the binary to use the new signature 2017-08-03 00:30:46 +08:00
Michael Bryan 65a60bf81f Integrated the new Book structure into MDBook 2017-08-03 00:30:45 +08:00
Michael Bryan 01301d9951 Started cleaning up some of the lints and warnings 2017-08-03 00:30:45 +08:00
Michael Bryan 773784a256 Started integrating some of the feedback from budziq 2017-08-03 00:30:45 +08:00
Michael Bryan 2670510fa4 Added a depth-first chapter iterator 2017-08-03 00:30:45 +08:00
Michael Bryan bce3297bbb 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-08-03 00:30:45 +08:00
Michael Bryan 0a035e3a49 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-08-03 00:30:45 +08:00
Mathieu David 6628757d8e Merge pull request #374 from Michael-F-Bryan/moar-tests
High level integration tests
2017-08-02 17:01:40 +02:00
Michael Bryan e2eb40bded Got some feedback from azerupi and added a DummyBook builder 2017-08-02 22:29:28 +08:00
Mathieu David 4f754a73ba Remove the empty introduction chapter 2017-08-02 15:04:03 +02:00
Mathieu David ba719c00be Possible fix for automatic deployment to gh-pages (GH_TOKEN has been updated on Travis) 2017-08-02 12:58:59 +02:00
Mathieu David 64f6f78663 Merge pull request #385 from azerupi/readme-pin-ci
Add a note about version pinning in the README
2017-08-01 14:32:43 +02:00
Mathieu David 3b0d2d1238 Add a note about version pinning for people doing automatic deployments of their books 2017-08-01 14:16:39 +02:00
Mathieu David 6ab3d3da2a ignore MacOS .DS_Store temporary files 2017-08-01 13:55:51 +02:00
Michal Budzynski ee29b9d5f6 added clone derives and made the separating space mandatory in links with paths 2017-08-01 13:50:12 +02:00
Michal Budzynski d7ecb1a80c Rewrite of {{#}} links handling in preprocess module
- Replaced link parser with a Regex
- Implemented {{#include}} links
- Will display relatively nice error when cannot open {{#}} linked file
- Escaped links no longer render with escape char
- utils::fs::file_to_path no takes AsRef<Path>
- sorted export/mod in lib.rs
2017-08-01 13:50:12 +02:00
Michal Budzynski f3f6b40ea9 Moved playpen.rs `renderer` helper to `preprocess/links.rs` module 2017-08-01 13:50:12 +02:00
Michał Budzyński c482650e56 Merge pull request #384 from budziq/travis-rustup-beta
fix travis ci for beta channel
2017-08-01 01:39:29 +02:00
Michał Budzyński 5da75bc798 fix travis ci for beta channel
travis started to fail for beta channel.
2017-08-01 01:04:05 +02: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
Mathieu David 55e7e82e5c Merge pull request #340 from messense/feature/mdbook-test-library-path
Add library path argument for `mdbook test`
2017-07-08 23:27:28 +02:00
Mathieu David 325458c957 Merge pull request #369 from budziq/info_logger
Increased default logging level to info unless RUST_LOG is set
2017-07-08 19:55:59 +02:00
Michał Budzyński 9c21fe32c1 Merge pull request #373 from Michael-F-Bryan/appveyor
Updated appveyor.yml to use rustup for installing Rust
2017-07-08 11:25:28 +02:00
Michael Bryan eaec9eff37 Updated appveyor.yml to use rustup for installing Rust 2017-07-08 12:47:27 +08:00
Michal Budzynski 287f539b7d Increased default logging level to info unless RUST_LOG is set 2017-06-28 23:37:03 +02:00
Mathieu David a220528c15 Merge pull request #367 from messense/feature/fix-mdbook-test-error
Print stdout when `mdbook test` failed
2017-06-28 08:41:13 +02:00
messense 7c023e2d1d
Add library path argument for `mdbook test` 2017-06-28 10:33:52 +08:00
messense f2544e0707
Print stdout when `mdbook test` failed 2017-06-28 10:28:50 +08:00
Mathieu David 4974d2cfa1 Merge pull request #362 from budziq/nonopt_htmlconfig
Make HtmlConfig is no longer optional
2017-06-27 14:33:56 +02: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
Mathieu David 5a27207844 Merge pull request #366 from budziq/split_commands
Split commands to separate files and register conditional ones if required features enabled
2017-06-27 13:37:57 +02:00
Michal Budzynski 5e088d92c9 Merge remote-tracking branch 'upstream/master' into split_commands 2017-06-27 13:06:19 +02:00
Mathieu David ea0c8ddea6 Merge pull request #364 from budziq/clippy_nits
Correct clippy complaints
2017-06-27 12:17:10 +02:00
Michal Budzynski b3c9ba4555 Correct clippy nits 2017-06-27 09:08:58 +02:00
Michal Budzynski 7f51039f9a Rename and move the clap sub-command generation functions 2017-06-27 07:59:50 +02:00
Michal Budzynski 7799ce285e Do not use wildcard imports if not needed 2017-06-26 23:17:46 +02:00
Michal Budzynski fe62d0c407 Merge remote-tracking branch 'upstream/master' into split_commands 2017-06-26 23:11:00 +02:00
Mathieu David c9a117cc4e Merge pull request #361 from Michael-F-Bryan/error-chain
Add error-chain throughout the codebase
2017-06-26 17:07:51 +02:00
Mathieu David 13ab20ea49 Merge pull request #363 from budziq/opt_mathjax
Make MathJax support optional
2017-06-26 17:01:52 +02:00
Michal Budzynski f3c8535870 Extracted `mdbook test` and `mdbook init` to separate files/modules 2017-06-26 01:24:33 +02:00
Michal Budzynski 35ed9fc286 corrected indentation in `serve` and `watch` subcommands definitions 2017-06-26 01:22:38 +02:00
Michal Budzynski efdd0330c1 Extracted `mdbook init` to separate file/module 2017-06-26 01:02:32 +02:00