Compare commits

..

16 Commits

Author SHA1 Message Date
Michael Bryan
1790b04e03 (cargo-release) version 0.1.1 2018-01-27 11:54:27 +08:00
Michael Bryan
50ee15472b Updated the light theme to have a lighter scrollbar (#590) 2018-01-27 11:52:43 +08:00
Michael Bryan
ffb90bb9e2 Made sure we create the themes directory (#586) 2018-01-26 14:38:53 +08:00
Sorin Davidoi
186e649530 feat(src/theme): Scrollbar theme (#563) 2018-01-26 01:17:02 +08:00
Michael Bryan
adc1f4ade7 Reverted #549 (#565) 2018-01-26 01:12:10 +08:00
Michael Bryan
b777a318f7 Expose functionality for creating core types (#578)
* You can now add chapters to a Book

* Made the RenderContext::new() constructor public
2018-01-26 01:11:48 +08:00
Michael Bryan
30e3b83167 Updated Cargo.toml metadata to make releases easier (#584) 2018-01-26 01:11:32 +08:00
Sorin Davidoi
f082187844 fix(theme/book): Use passive listeners for touchstart, touchmove (#575) 2018-01-25 18:44:22 +08:00
Michael Bryan
6119972fa7 Merge pull request #581 from bmusin/patch-3
fix typo
2018-01-25 17:49:40 +08:00
Michael Bryan
a910435fd9 Merge pull request #577 from Michael-F-Bryan/missing-backends-arent-fatal
Missing backends shouldn't be fatal
2018-01-25 07:33:54 +08:00
Bulat Musin
53b902b479 remove dot for consistency (#580) 2018-01-25 07:32:52 +08:00
Bulat Musin
2e9d8671a0 fix typo (insert dash) (#582) 2018-01-25 07:32:33 +08:00
Bulat Musin
50cdfc9623 fix typo (#579) 2018-01-25 07:25:56 +08:00
Bulat Musin
d47f4dce7f fix typo 2018-01-24 21:52:51 +03:00
Michael Bryan
bda23f0183 Missing backends are no longer fatal 2018-01-25 01:15:29 +08:00
Michael Bryan
1fbad982d8 (cargo-release) start next development iteration 0.1.1-alpha.0 2018-01-23 22:06:55 +08:00
19 changed files with 159 additions and 30 deletions

View File

@@ -28,10 +28,10 @@ matrix:
- env: TARGET=x86_64-unknown-linux-musl
# Mac
# - env: TARGET=i686-apple-darwin
# os: osx
# - env: TARGET=x86_64-apple-darwin
# os: osx
- env: TARGET=i686-apple-darwin
os: osx
- env: TARGET=x86_64-apple-darwin
os: osx
# BSD
- env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1
@@ -41,14 +41,14 @@ matrix:
# Other channels
- env: TARGET=x86_64-unknown-linux-gnu
rust: beta
# - env: TARGET=x86_64-apple-darwin
# os: osx
# rust: beta
- env: TARGET=x86_64-apple-darwin
os: osx
rust: beta
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly
# - env: TARGET=x86_64-apple-darwin
# os: osx
# rust: nightly
- env: TARGET=x86_64-apple-darwin
os: osx
rust: nightly
before_install:
- set -e

View File

@@ -1,6 +1,6 @@
[package]
name = "mdbook"
version = "0.1.0"
version = "0.1.1"
authors = ["Mathieu David <mathieudavid@mathieudavid.org>", "Michael-F-Bryan <michaelfbryan@gmail.com>"]
description = "create books from markdown files (like Gitbook)"
documentation = "http://rust-lang-nursery.github.io/mdBook/index.html"
@@ -14,6 +14,11 @@ exclude = [
"src/theme/stylus/**",
]
[package.metadata.release]
sign-commit = true
push-remote = "upstream"
tag-prefix = "v"
[dependencies]
clap = "2.24"
chrono = "0.4"
@@ -65,6 +70,3 @@ serve = ["iron", "staticfile", "ws"]
doc = false
name = "mdbook"
path = "src/bin/mdbook.rs"
[workspace]
members = ["book-example/src/for_developers/mdbook-wordcount"]

View File

@@ -21,7 +21,7 @@ mdbook serve path/to/book
For example: suppose you had an nginx server for SSL termination which has a public address of 192.168.1.100 on port 80 and proxied that to 127.0.0.1 on port 8000. To run use the nginx proxy do:
```bash
mdbook server path/to/book -p 8000 -i 127.0.0.1 -a 192.168.1.100
mdbook serve path/to/book -p 8000 -i 127.0.0.1 -a 192.168.1.100
```
If you were to want live reloading for this you would need to proxy the websocket calls through nginx as well from `192.168.1.100:<WS_PORT>` to `127.0.0.1:<WS_PORT>`. The `-w` flag allows for the websocket port to be configured.

View File

@@ -116,7 +116,7 @@ tables. If none are provided it'll fall back to using the default HTML
renderer.
Notably, this means if you want to add your own custom backend you'll also
need to make sure to add the HTML backend, even if its tabke just stays empty.
need to make sure to add the HTML backend, even if its table just stays empty.
Now you just need to build your book like normal, and everything should *Just
Work*.
@@ -149,7 +149,7 @@ The reason we didn't need to specify the full name/path of our `wordcount`
backend is because `mdbook` will try to *infer* the program's name via
convention. The executable for the `foo` backend is typically called
`mdbook-foo`, with an associated `[output.foo]` entry in the `book.toml`. To
explicitly tell `mdbook` what command to invoke (it may require command line
explicitly tell `mdbook` what command to invoke (it may require command-line
arguments or be an interpreted script), you can use the `command` field.
```diff
@@ -349,4 +349,4 @@ the source code or ask questions.
[`Book`]: http://rust-lang-nursery.github.io/mdBook/mdbook/book/struct.Book.html
[`Book::iter()`]: http://rust-lang-nursery.github.io/mdBook/mdbook/book/struct.Book.html#method.iter
[`Config`]: http://rust-lang-nursery.github.io/mdBook/mdbook/config/struct.Config.html
[issue tracker]: https://github.com/rust-lang-nursery/mdBook/issues
[issue tracker]: https://github.com/rust-lang-nursery/mdBook/issues

View File

@@ -21,7 +21,7 @@ The process of rendering a book project goes through several steps.
1. Load the book
- Parse the `book.toml`, falling back to the default `Config` if it doesn't
exist.
exist
- Load the book chapters into memory
- Discover which preprocessors/backends should be used
2. Run the preprocessors
@@ -43,4 +43,4 @@ explanation on the configuration system.
[`MDBook`]: http://rust-lang-nursery.github.io/mdBook/mdbook/book/struct.MDBook.html
[API Docs]: http://rust-lang-nursery.github.io/mdBook/mdbook/
[config]: file:///home/michael/Documents/forks/mdBook/target/doc/mdbook/config/index.html
[config]: file:///home/michael/Documents/forks/mdBook/target/doc/mdbook/config/index.html

View File

@@ -2,9 +2,8 @@
name = "mdbook-wordcount"
version = "0.1.0"
authors = ["Michael Bryan <michaelfbryan@gmail.com>"]
workspace = "../../../.."
[dependencies]
mdbook = { path = "../../../.." }
mdbook = { path = "../../../..", version = "*" }
serde = "1.0"
serde_derive = "1.0"

View File

@@ -101,6 +101,12 @@ impl Book {
{
for_each_mut(&mut func, &mut self.sections);
}
/// Append a `BookItem` to the `Book`.
pub fn push_item<I: Into<BookItem>>(&mut self, item: I) -> &mut Self {
self.sections.push(item.into());
self
}
}
pub fn for_each_mut<'a, F, I>(func: &mut F, items: I)
@@ -126,6 +132,12 @@ pub enum BookItem {
Separator,
}
impl From<Chapter> for BookItem {
fn from(other: Chapter) -> BookItem {
BookItem::Chapter(other)
}
}
/// The representation of a "chapter", usually mapping to a single file on
/// disk however it may contain multiple sub-chapters.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]

View File

@@ -245,6 +245,10 @@ impl HtmlHandlebars {
for custom_file in custom_files {
let output_location = destination.join(custom_file);
if let Some(parent) = output_location.parent() {
fs::create_dir_all(parent)
.chain_err(|| format!("Unable to create {}", parent.display()))?;
}
debug!(
"Copying {} -> {}",
custom_file.display(),

View File

@@ -16,7 +16,7 @@ pub use self::html_handlebars::HtmlHandlebars;
mod html_handlebars;
use std::fs;
use std::io::Read;
use std::io::{self, Read};
use std::path::PathBuf;
use std::process::{Command, Stdio};
use serde_json;
@@ -26,6 +26,8 @@ use errors::*;
use config::Config;
use book::Book;
const MDBOOK_VERSION: &str = env!("CARGO_PKG_VERSION");
/// An arbitrary `mdbook` backend.
///
/// Although it's quite possible for you to import `mdbook` as a library and
@@ -68,7 +70,7 @@ pub struct RenderContext {
impl RenderContext {
/// Create a new `RenderContext`.
pub(crate) fn new<P, Q>(root: P, book: Book, config: Config, destination: Q) -> RenderContext
pub fn new<P, Q>(root: P, book: Book, config: Config, destination: Q) -> RenderContext
where
P: Into<PathBuf>,
Q: Into<PathBuf>,
@@ -76,7 +78,7 @@ impl RenderContext {
RenderContext {
book: book,
config: config,
version: env!("CARGO_PKG_VERSION").to_string(),
version: MDBOOK_VERSION.to_string(),
root: root.into(),
destination: destination.into(),
}
@@ -155,13 +157,22 @@ impl Renderer for CmdRenderer {
let _ = fs::create_dir_all(&ctx.destination);
let mut child = self.compose_command()?
let mut child = match self.compose_command()?
.stdin(Stdio::piped())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.current_dir(&ctx.destination)
.spawn()
.chain_err(|| "Unable to start the renderer")?;
.spawn() {
Ok(c) => c,
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
warn!("The command wasn't found, is the \"{}\" backend installed?", self.name);
warn!("\tCommand: {}", self.cmd);
return Ok(());
}
Err(e) => {
return Err(e).chain_err(|| "Unable to start the backend")?;
}
};
{
let mut stdin = child.stdin.take().expect("Child has stdin");

View File

@@ -340,6 +340,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
background-color: #fafafa;
color: #364149;
}
.light .sidebar::-webkit-scrollbar {
background: #fafafa;
}
.light .sidebar::-webkit-scrollbar-thumb {
background: #ccc;
}
.light .chapter li {
color: #aaa;
}
@@ -464,6 +470,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
.light .icon-button i {
margin: 0;
}
.light ::-webkit-scrollbar {
background: #fff;
}
.light ::-webkit-scrollbar-thumb {
background: #ccc;
}
.coal {
color: #98a3ad;
background-color: #141617;
@@ -494,6 +506,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
background-color: #292c2f;
color: #a1adb8;
}
.coal .sidebar::-webkit-scrollbar {
background: #292c2f;
}
.coal .sidebar::-webkit-scrollbar-thumb {
background: #a1adb8;
}
.coal .chapter li {
color: #505254;
}
@@ -618,6 +636,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
.coal .icon-button i {
margin: 0;
}
.coal ::-webkit-scrollbar {
background: #141617;
}
.coal ::-webkit-scrollbar-thumb {
background: #a1adb8;
}
.navy {
color: #bcbdd0;
background-color: #161923;
@@ -648,6 +672,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
background-color: #282d3f;
color: #c8c9db;
}
.navy .sidebar::-webkit-scrollbar {
background: #282d3f;
}
.navy .sidebar::-webkit-scrollbar-thumb {
background: #c8c9db;
}
.navy .chapter li {
color: #505274;
}
@@ -772,6 +802,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
.navy .icon-button i {
margin: 0;
}
.navy ::-webkit-scrollbar {
background: #161923;
}
.navy ::-webkit-scrollbar-thumb {
background: #c8c9db;
}
.rust {
color: #262625;
background-color: #e1e1db;
@@ -802,6 +838,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
background-color: #3b2e2a;
color: #c8c9db;
}
.rust .sidebar::-webkit-scrollbar {
background: #3b2e2a;
}
.rust .sidebar::-webkit-scrollbar-thumb {
background: #c8c9db;
}
.rust .chapter li {
color: #505254;
}
@@ -926,6 +968,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
.rust .icon-button i {
margin: 0;
}
.rust ::-webkit-scrollbar {
background: #e1e1db;
}
.rust ::-webkit-scrollbar-thumb {
background: #c8c9db;
}
.ayu {
color: #c5c5c5;
background-color: #0f1419;
@@ -956,6 +1004,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
background-color: #14191f;
color: #c8c9db;
}
.ayu .sidebar::-webkit-scrollbar {
background: #14191f;
}
.ayu .sidebar::-webkit-scrollbar-thumb {
background: #c8c9db;
}
.ayu .chapter li {
color: #5c6773;
}
@@ -1080,6 +1134,12 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
.ayu .icon-button i {
margin: 0;
}
.ayu ::-webkit-scrollbar {
background: #0f1419;
}
.ayu ::-webkit-scrollbar-thumb {
background: #c8c9db;
}
@media only print {
#sidebar,
#menu-bar,

View File

@@ -279,6 +279,7 @@ function playpen_text(playpen) {
})();
(function themes() {
var html = document.querySelector('html');
var themeToggleButton = document.getElementById('theme-toggle');
var themePopup = document.getElementById('theme-list');
var themeColorMetaTag = document.querySelector('meta[name="theme-color"]');
@@ -331,9 +332,15 @@ function playpen_text(playpen) {
});
}
var previousTheme;
try { previousTheme = localStorage.getItem('mdbook-theme'); } catch (e) { }
if (previousTheme === null || previousTheme === undefined) { previousTheme = 'light'; }
try { localStorage.setItem('mdbook-theme', theme); } catch (e) { }
document.body.className = theme;
html.classList.remove(previousTheme);
html.classList.add(theme);
}
// Set theme
@@ -422,7 +429,7 @@ function playpen_text(playpen) {
x: e.touches[0].clientX,
time: Date.now()
};
});
}, { passive: true });
document.addEventListener('touchmove', function (e) {
if (!firstContact)
@@ -440,7 +447,7 @@ function playpen_text(playpen) {
firstContact = null;
}
});
}, { passive: true });
// Scroll sidebar to current active section
var activeSection = sidebar.querySelector(".active");

View File

@@ -65,6 +65,7 @@
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = 'light'; }
document.body.className = theme;
document.querySelector('html').className = theme;
</script>
<!-- Hide / unhide sidebar before it is displayed -->

View File

@@ -9,6 +9,8 @@ $sidebar-non-existant = #5c6773
$sidebar-active = #ffb454
$sidebar-spacer = #2d334f
$scrollbar = $sidebar-fg
$icons = #737480
$icons-hover = #b7b9cc

View File

@@ -32,6 +32,14 @@
.sidebar {
background-color: $sidebar-bg
color: $sidebar-fg
&::-webkit-scrollbar {
background: $sidebar-bg;
}
&::-webkit-scrollbar-thumb {
background: $scrollbar;
}
}
.chapter li {
@@ -172,4 +180,12 @@
margin: 0;
}
}
::-webkit-scrollbar {
background: $bg;
}
::-webkit-scrollbar-thumb {
background: $scrollbar;
}
}

View File

@@ -9,6 +9,8 @@ $sidebar-non-existant = #505254
$sidebar-active = #3473ad
$sidebar-spacer = #393939
$scrollbar = $sidebar-fg
$icons = #43484d
$icons-hover = #b3c0cc

View File

@@ -9,6 +9,8 @@ $sidebar-non-existant = #aaaaaa
$sidebar-active = #008cff
$sidebar-spacer = #f4f4f4
$scrollbar = #cccccc
$icons = #cccccc
$icons-hover = #333333

View File

@@ -9,6 +9,8 @@ $sidebar-non-existant = #505274
$sidebar-active = #2b79a2
$sidebar-spacer = #2d334f
$scrollbar = $sidebar-fg
$icons = #737480
$icons-hover = #b7b9cc

View File

@@ -9,6 +9,8 @@ $sidebar-non-existant = #505254
$sidebar-active = #e69f67
$sidebar-spacer = #45373a
$scrollbar = $sidebar-fg
$icons = #737480
$icons-hover = #262625

View File

@@ -24,6 +24,13 @@ fn failing_alternate_backend() {
md.build().unwrap_err();
}
#[test]
fn missing_backends_arent_fatal() {
let (md, _temp) = dummy_book_with_backend("missing", "trduyvbhijnorgevfuhn");
assert!(md.build().is_ok());
}
#[test]
fn alternate_backend_with_arguments() {
let (md, _temp) = dummy_book_with_backend("arguments", "echo Hello World!");