Extract syntex highlighting module into a new component in workspace

This removes the dependency cycle between config and rendering that
causes 4 packages to be recompiled every time a change is made.

I just want to code fast!
This commit is contained in:
Geoff Shannon 2017-10-30 13:55:14 -07:00
parent bfdfe3bba3
commit c19e900bec
10 changed files with 45 additions and 6 deletions

11
Cargo.lock generated
View file

@ -238,7 +238,7 @@ version = "0.1.0"
dependencies = [
"chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"errors 0.1.0",
"rendering 0.1.0",
"highlighting 0.1.0",
"serde 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -440,6 +440,14 @@ dependencies = [
"ws 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "highlighting"
version = "0.1.0"
dependencies = [
"lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"syntect 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "httparse"
version = "1.2.3"
@ -939,6 +947,7 @@ version = "0.1.0"
dependencies = [
"errors 0.1.0",
"front_matter 0.1.0",
"highlighting 0.1.0",
"lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -42,6 +42,7 @@ members = [
"components/content",
"components/errors",
"components/front_matter",
"components/highlighting",
"components/pagination",
"components/rendering",
"components/site",

View file

@ -10,4 +10,4 @@ serde_derive = "1.0"
chrono = "0.4"
errors = { path = "../errors" }
rendering = { path = "../rendering" }
highlighting = { path = "../highlighting"}

View file

@ -3,7 +3,7 @@ extern crate serde_derive;
extern crate toml;
#[macro_use]
extern crate errors;
extern crate rendering;
extern crate highlighting;
extern crate chrono;
use std::collections::HashMap;
@ -15,7 +15,7 @@ use toml::{Value as Toml};
use chrono::Utc;
use errors::{Result, ResultExt};
use rendering::highlighting::THEME_SET;
use highlighting::THEME_SET;
mod theme;

3
components/errors/src/lib.rs Normal file → Executable file
View file

@ -1,3 +1,5 @@
#![allow(unused_doc_comment)]
#[macro_use]
extern crate error_chain;
extern crate tera;
@ -26,4 +28,3 @@ macro_rules! bail {
return Err(format!($fmt, $($arg)+).into());
};
}

View file

@ -0,0 +1,8 @@
[package]
name = "highlighting"
version = "0.1.0"
authors = ["Vincent Prouillet <vincent@wearewizards.io>"]
[dependencies]
lazy_static = "0.2"
syntect = { version = "1", features = ["static-onig"] }

View file

@ -0,0 +1,19 @@
#[macro_use]
extern crate lazy_static;
extern crate syntect;
use syntect::dumps::from_binary;
use syntect::parsing::SyntaxSet;
use syntect::highlighting::ThemeSet;
thread_local!{
pub static SYNTAX_SET: SyntaxSet = {
let mut ss: SyntaxSet = from_binary(include_bytes!("../../../sublime_syntaxes/newlines.packdump"));
ss.link_syntaxes();
ss
};
}
lazy_static!{
pub static ref THEME_SET: ThemeSet = from_binary(include_bytes!("../../../sublime_themes/all.themedump"));
}

View file

@ -15,6 +15,7 @@ serde_derive = "1.0"
errors = { path = "../errors" }
front_matter = { path = "../front_matter" }
highlighting = { path = "../highlighting"}
utils = { path = "../utils" }
[dev-dependencies]

View file

@ -11,13 +11,13 @@ extern crate serde;
extern crate errors;
extern crate front_matter;
extern crate highlighting;
extern crate utils;
#[cfg(test)]
extern crate templates;
mod context;
pub mod highlighting;
mod markdown;
mod short_code;
mod table_of_contents;