Browse Source

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!
index-subcmd
Geoff Shannon 7 years ago
parent
commit
c19e900bec
10 changed files with 45 additions and 6 deletions
  1. +10
    -1
      Cargo.lock
  2. +1
    -0
      Cargo.toml
  3. +1
    -1
      components/config/Cargo.toml
  4. +2
    -2
      components/config/src/lib.rs
  5. +2
    -1
      components/errors/src/lib.rs
  6. +8
    -0
      components/highlighting/Cargo.toml
  7. +0
    -0
      components/highlighting/src/highlighting.rs
  8. +19
    -0
      components/highlighting/src/lib.rs
  9. +1
    -0
      components/rendering/Cargo.toml
  10. +1
    -1
      components/rendering/src/lib.rs

+ 10
- 1
Cargo.lock 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)",


+ 1
- 0
Cargo.toml View File

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


+ 1
- 1
components/config/Cargo.toml View File

@@ -10,4 +10,4 @@ serde_derive = "1.0"
chrono = "0.4"

errors = { path = "../errors" }
rendering = { path = "../rendering" }
highlighting = { path = "../highlighting"}

+ 2
- 2
components/config/src/lib.rs 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;


+ 2
- 1
components/errors/src/lib.rs 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());
};
}


+ 8
- 0
components/highlighting/Cargo.toml 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"] }

components/rendering/src/highlighting.rs → components/highlighting/src/highlighting.rs View File


+ 19
- 0
components/highlighting/src/lib.rs 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"));
}

+ 1
- 0
components/rendering/Cargo.toml 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]


+ 1
- 1
components/rendering/src/lib.rs 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;


Loading…
Cancel
Save