Skip to content

Commit

Permalink
Move citeproc into a separate crate
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Jul 30, 2019
1 parent bacbcdb commit 5e61221
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 15 deletions.
5 changes: 0 additions & 5 deletions .build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ steps:
inputs:
versionSpec: ">=10.x"
displayName: "Install Node.js"
- bash: |
cd citeproc
npm ci
npm run dist
displayName: "Bundle citeproc"
- ${{ if eq(parameters.coverage, 'false') }}:
- bash: |
export RUST_BACKTRACE=1
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ authors = [
edition = "2018"

[workspace]
members = ["./jsonrpc", "./jsonrpc_derive", "crates/texlab_syntax"]
members = [
"jsonrpc",
"jsonrpc_derive",
"crates/texlab_citeproc",
"crates/texlab_syntax"]

[dependencies]
base64 = "0.10.1"
Expand Down Expand Up @@ -36,6 +40,7 @@ serde_json = "1.0.40"
serde_repr = "0.1"
stderrlog = "0.4.1"
tempfile = "3"
texlab-citeproc = { path = "crates/texlab_citeproc" }
texlab-syntax = { path = "crates/texlab_syntax" }
tokio = "0.1"
tokio-codec = "0.1"
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ You will need to install the following dependencies to compile the server:
- [Rust](https://rustup.rs/)
- [Node.js](https://nodejs.org/)

Then run the following commands in the project folder:
Then run the following command in the project folder:

```shell
cd citeproc
npm install
npm run dist
cd ..
cargo build --release
```

Expand Down
20 changes: 20 additions & 0 deletions crates/texlab_citeproc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "texlab-citeproc"
version = "0.1.0"
authors = [
"Eric Förster <[email protected]>",
"Patrick Förster <[email protected]>"]
edition = "2018"

[dependencies]
futures-preview = { version = "0.3.0-alpha.15", features = ["compat"] }
html2md = "0.2.9"
lsp-types = { git = "https://github.com/latex-lsp/lsp-types", rev = "9fcc5d9b9d3013ce84e20ef566267754d594b268", features = ["proposed"] }
runtime = "0.3.0-alpha.4"
runtime-tokio = "0.3.0-alpha.4"
serde = { version = "1.0.97", features = ["derive", "rc"] }
tempfile = "3"
texlab-syntax = { path = "../texlab_syntax" }
tokio = "0.1"
tokio-process = "0.2.4"

20 changes: 20 additions & 0 deletions crates/texlab_citeproc/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::process::Command;

fn sh(command: &'static str) {
let (executable, args) = if cfg!(windows) {
("cmd", vec!["/C", command])
} else {
("sh", vec!["-c", command])
};

Command::new(executable)
.args(args)
.current_dir("script")
.output()
.expect(&format!("Failed to execute \"{}\"", command));
}

fn main() {
sh("npm ci");
sh("npm run dist");
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion src/data/citation.rs → crates/texlab_citeproc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#![feature(async_await)]

use texlab_syntax::*;
use futures::compat::*;
use lsp_types::*;
use std::process::{Command, Stdio};
use tempfile::tempdir;
use tokio_process::CommandExt;


#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum RenderCitationError {
InitializationFailed,
Expand Down Expand Up @@ -59,7 +62,7 @@ pub async fn render_citation(entry_code: &str) -> Result<MarkupContent, RenderCi
}
}

const SCRIPT: &str = include_str!("../../citeproc/dist/citeproc.js");
const SCRIPT: &str = include_str!("../script/dist/citeproc.js");

#[cfg(test)]
mod tests {
Expand Down
1 change: 0 additions & 1 deletion src/data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod citation;
pub mod completion;
pub mod kernel_primitives;
pub mod label;
2 changes: 1 addition & 1 deletion src/hover/latex_citation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::data::citation::{render_citation, RenderCitationError};
use texlab_citeproc::{render_citation, RenderCitationError};
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::formatting::bibtex;
use crate::formatting::bibtex::BibtexFormattingParams;
Expand Down
2 changes: 1 addition & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::action::{Action, ActionMananger, LintReason};
use crate::build::*;
use crate::client::LspClient;
use crate::completion::{CompletionItemData, CompletionProvider};
use crate::data::citation::render_citation;
use texlab_citeproc::render_citation;
use crate::data::completion::DATABASE;
use crate::definition::DefinitionProvider;
use crate::diagnostics::{DiagnosticsManager, LatexLintOptions};
Expand Down

0 comments on commit 5e61221

Please sign in to comment.