Compare commits

...

14 Commits

Author SHA1 Message Date
Michael Bryan
b765023da3 (cargo-release) version 0.1.3 2018-02-16 07:45:52 +08:00
Sorin Davidoi
d306aed587 Accessibility improvements (#611)
* fix(theme/book/themes): Check for control keys in event listener

* fix(theme/index): Menu role for theme selector

* fix(theme/book/themes): Handle focus when toggling theme list

* feat(theme/book/themes): Handle ArrowUp, ArrowDown, Home and End
2018-02-15 07:37:19 +08:00
Sorin Davidoi
89a5dbaf9a fix(theme/stylus/sidebar): Contain scrolling to the sidebar (#612)
> A position fixed left navigation bar does not want to hand off scrolling to the document because a scroll gesture performed on the navigation bar is almost never meant to scroll the document. In this case, the author can use contain on the sidebar to prevent scrolling from being chained to the parent document element.

https://wicg.github.io/overscroll-behavior/#motivating-examples
2018-02-15 07:24:39 +08:00
Ryan Scheel
6961247f56 Include Cargo.lock (#620) 2018-02-15 07:03:10 +08:00
Sorin Davidoi
07551760c9 feat(theme/stylus/sidebar): Reduce padding on non-touch devices (#615)
Closes #594.
2018-02-15 06:59:55 +08:00
Sorin Davidoi
990daceed5 feat(theme/book): Scroll to top when clicking the page title (#613)
Common pattern, especially on mobile devices where the page can be quite long.
2018-02-09 18:34:18 +08:00
Mathieu David
2989096188 Merge pull request #609 from bchatard/typo
Fix typo in format configuration
2018-02-05 15:17:24 +01:00
bchatard
03c6c44e5b Fix typo in format configuration 2018-02-05 13:01:17 +01:00
Ofek Lev
31a370d149 fix readme (#606) 2018-02-05 07:11:55 +08:00
Bulat Musin
0bc1030a02 implement clean subcommand (#583) 2018-02-04 21:00:29 +08:00
boxdot
43fcd00cd5 Inline footnotes. (#600) 2018-02-02 20:15:48 +08:00
Mathieu David
3d83b784b3 Merge pull request #601 from tshepang/patch-1
doc: small fixes
2018-02-01 11:31:55 +01:00
Tshepang Lekhonkhobe
5d42738a79 doc: small fixes 2018-02-01 03:29:39 +02:00
Michael Bryan
1f4dab3e5c (cargo-release) start next development iteration 0.1.3-alpha.0 2018-01-31 19:19:50 +08:00
14 changed files with 1506 additions and 21 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
Cargo.lock
target
# MacOS temp file

1380
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
[package]
name = "mdbook"
version = "0.1.2"
version = "0.1.3"
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"

View File

@@ -40,7 +40,7 @@ There are multiple ways to install mdBook.
path to the binary into your `PATH`.
2. **From Crates.io**
j
This requires [Rust] and Cargo to be installed. Once you have installed
Rust, type the following in the terminal:

View File

@@ -110,7 +110,7 @@ editable = false
## Environment Variables
All configuration values van be overridden from the command line by setting the
All configuration values can be overridden from the command line by setting the
corresponding environment variable. Because many operating systems restrict
environment variables to be alphanumeric characters or `_`, the configuration
key needs to be formatted slightly differently to the normal `foo.bar.baz` form.

View File

@@ -1,8 +1,8 @@
# mdBook specific markdown
# mdBook-specific markdown
## Hiding code lines
There is a feature in mdBook that let's you hide code lines by prepending them with a `#`.
There is a feature in mdBook that lets you hide code lines by prepending them with a `#`.
```bash
# fn main() {
@@ -55,7 +55,7 @@ With the following syntax, you can insert runnable Rust files into your book:
The path to the Rust file has to be relative from the current source file.
When play is clicked, the code snippet will be send to the [Rust Playpen] to be compiled and run. The result is send back and displayed directly underneath the code.
When play is clicked, the code snippet will be sent to the [Rust Playpen] to be compiled and run. The result is sent back and displayed directly underneath the code.
Here is what a rendered code snippet looks like:

30
src/bin/clean.rs Normal file
View File

@@ -0,0 +1,30 @@
use std::fs;
use std::path::PathBuf;
use clap::{App, ArgMatches, SubCommand};
use mdbook::MDBook;
use mdbook::errors::*;
use get_book_dir;
// Create clap subcommand arguments
pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name("clean")
.about("Delete built book")
.arg_from_usage(
"-d, --dest-dir=[dest-dir] 'The directory of built book{n}(Defaults to ./book when \
omitted)'",
)
}
// Clean command implementation
pub fn execute(args: &ArgMatches) -> ::mdbook::errors::Result<()> {
let book_dir = get_book_dir(args);
let book = MDBook::load(&book_dir)?;
let dir_to_remove = match args.value_of("dest-dir") {
Some(dest_dir) => PathBuf::from(dest_dir),
None => book.root.join(&book.config.build.build_dir),
};
fs::remove_dir_all(&dir_to_remove).chain_err(|| "Unable to remove the build directory")?;
Ok(())
}

View File

@@ -19,6 +19,7 @@ use env_logger::Builder;
use mdbook::utils;
pub mod build;
pub mod clean;
pub mod init;
pub mod test;
#[cfg(feature = "serve")]
@@ -44,7 +45,8 @@ fn main() {
at: https://github.com/rust-lang-nursery/mdBook")
.subcommand(init::make_subcommand())
.subcommand(build::make_subcommand())
.subcommand(test::make_subcommand());
.subcommand(test::make_subcommand())
.subcommand(clean::make_subcommand());
#[cfg(feature = "watch")]
let app = app.subcommand(watch::make_subcommand());
@@ -55,6 +57,7 @@ fn main() {
let res = match app.get_matches().subcommand() {
("init", Some(sub_matches)) => init::execute(sub_matches),
("build", Some(sub_matches)) => build::execute(sub_matches),
("clean", Some(sub_matches)) => clean::execute(sub_matches),
#[cfg(feature = "watch")]
("watch", Some(sub_matches)) => watch::execute(sub_matches),
#[cfg(feature = "serve")]

View File

@@ -47,6 +47,17 @@ table td {
table thead td {
font-weight: 700;
}
:not(.footnote-definition) + .footnote-definition,
.footnote-definition + :not(.footnote-definition) {
margin-top: 2em;
}
.footnote-definition {
font-size: 0.9em;
margin: 0.5em 0;
}
.footnote-definition p {
display: inline;
}
.sidebar {
position: fixed;
left: 0;
@@ -60,6 +71,7 @@ table thead td {
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
overscroll-behavior-y: contain;
-webkit-transition: -webkit-transform 0.5s;
-moz-transition: -moz-transform 0.5s;
-o-transition: -o-transform 0.5s;
@@ -83,16 +95,26 @@ table thead td {
}
.chapter li a {
display: block;
padding: 5px 0;
padding: 0;
text-decoration: none;
}
@media (-moz-touch-enabled: 1), (pointer: coarse) {
.chapter li a {
padding: 5px 0;
}
}
.chapter li a:hover {
text-decoration: none;
}
.chapter .spacer {
width: 100%;
height: 3px;
margin: 10px 0px;
margin: 5px 0px;
}
@media (-moz-touch-enabled: 1), (pointer: coarse) {
.chapter .spacer {
margin: 10px 0;
}
}
.section {
list-style: none outside none;
@@ -209,6 +231,7 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
cursor: pointer;
}
.nav-chapters {
font-size: 2.5em;

View File

@@ -298,11 +298,13 @@ function playpen_text(playpen) {
function showThemes() {
themePopup.style.display = 'block';
themeToggleButton.setAttribute('aria-expanded', true);
themePopup.querySelector("button#" + document.body.className).focus();
}
function hideThemes() {
themePopup.style.display = 'none';
themeToggleButton.setAttribute('aria-expanded', false);
themeToggleButton.focus();
}
function set_theme(theme) {
@@ -369,19 +371,43 @@ function playpen_text(playpen) {
set_theme(theme);
});
// Hide theme selector popup when clicking outside of it
document.addEventListener('click', function (event) {
if (themePopup.style.display === 'block' && !themeToggleButton.contains(event.target) && !themePopup.contains(event.target)) {
themePopup.addEventListener('focusout', function(e) {
if (!themePopup.contains(e.relatedTarget)) {
hideThemes();
}
});
document.addEventListener('keydown', function (e) {
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; }
if (!themePopup.contains(e.target)) { return; }
switch (e.key) {
case 'Escape':
e.preventDefault();
hideThemes();
break;
case 'ArrowUp':
e.preventDefault();
var li = document.activeElement.parentElement;
if (li && li.previousElementSibling) {
li.previousElementSibling.querySelector('button').focus();
}
break;
case 'ArrowDown':
e.preventDefault();
var li = document.activeElement.parentElement;
if (li && li.nextElementSibling) {
li.nextElementSibling.querySelector('button').focus();
}
break;
case 'Home':
e.preventDefault();
themePopup.querySelector('li:first-child button').focus();
break;
case 'End':
e.preventDefault();
themePopup.querySelector('li:last-child button').focus();
break;
}
});
})();
@@ -522,6 +548,14 @@ function playpen_text(playpen) {
});
})();
(function scrollToTop () {
var menuTitle = document.querySelector('.menu-title');
menuTitle.addEventListener('click', function () {
document.scrollingElement.scrollTo({ top: 0, behavior: 'smooth' });
});
})();
(function autoHideMenu() {
var menu = document.getElementById('menu-bar');

View File

@@ -95,12 +95,12 @@
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="submenu">
<li><button class="theme" id="light">Light <span class="default">(default)</span></button></li>
<li><button class="theme" id="rust">Rust</button></li>
<li><button class="theme" id="coal">Coal</button></li>
<li><button class="theme" id="navy">Navy</button></li>
<li><button class="theme" id="ayu">Ayu</button></li>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light <span class="default">(default)</span></button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
</div>

View File

@@ -48,3 +48,15 @@ table {
td { font-weight: 700; }
}
}
:not(.footnote-definition) + .footnote-definition,
.footnote-definition + :not(.footnote-definition) {
margin-top: 2em;
}
.footnote-definition {
font-size: 0.9em;
margin: 0.5em 0;
p { display: inline; }
}

View File

@@ -38,4 +38,5 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
white-space: nowrap
overflow: hidden
text-overflow: ellipsis
cursor: pointer;
}

View File

@@ -11,6 +11,7 @@
font-size: 0.875em
box-sizing: border-box
-webkit-overflow-scrolling: touch
overscroll-behavior-y: contain;
// Animation: slide away
transition: transform 0.5s
@@ -31,16 +32,18 @@
li a {
display: block;
padding: 5px 0
padding: 0
text-decoration: none
@media (-moz-touch-enabled: 1), (pointer: coarse) { padding: 5px 0; }
&:hover { text-decoration: none }
}
.spacer {
width: 100%
height: 3px
margin: 10px 0px
margin: 5px 0px
@media (-moz-touch-enabled: 1), (pointer: coarse) { margin: 10px 0; }
}
}