Skip to content

Commit

Permalink
Rename topiary to topiary-core
Browse files Browse the repository at this point in the history
This works towards future publishing of this crate on crates.io
  • Loading branch information
Erin van der Veen committed Sep 21, 2023
1 parent 63a794c commit 4e67fe1
Show file tree
Hide file tree
Showing 53 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you do `cargo install flamegraph`, you can generate a performance flamegraph
like this:

```bash
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -- -l ocaml < topiary/tests/samples/input/ocaml.ml > formatted.ml
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -- -l ocaml < topiary-core/tests/samples/input/ocaml.ml > formatted.ml
```

## Code Coverage
Expand Down
46 changes: 23 additions & 23 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readme = "README.md"
license = "MIT"

[workspace]
members = ["topiary", "topiary-cli", "topiary-queries", "topiary-playground"]
members = ["topiary-core", "topiary-cli", "topiary-queries", "topiary-playground"]
exclude = ["samples"]

[profile.release]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1327,9 +1327,9 @@ containing the matched nodes are is single-line (resp. multi-line).
In order to work productively on query files, the following is one
suggested way to work:

1. Add a sample file to `topiary/tests/samples/input`.
1. Add a sample file to `topiary-core/tests/samples/input`.

2. Copy the same file to `topiary/tests/samples/expected`, and make any changes
2. Copy the same file to `topiary-core/tests/samples/expected`, and make any changes
to how you want the output to be formatted.

3. If this is a new language, add its Tree-sitter grammar, extend
Expand Down
8 changes: 4 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let
"Cargo.toml"
"languages.toml"
"queries"
"topiary"
"topiary-core"
"topiary-queries"
"topiary-cli"
"topiary-playground"
Expand Down Expand Up @@ -79,11 +79,11 @@ in
cargoTestCommand = "cargo bench --profile release";
});

topiary-lib = craneLib.buildPackage (commonArgs
topiary-core = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
pname = "topiary-lib";
cargoExtraArgs = "-p topiary";
pname = "topiary-core";
cargoExtraArgs = "-p topiary-core";
});

topiary-cli = craneLib.buildPackage (commonArgs
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
};

checks = {
inherit (code) clippy clippy-wasm fmt topiary-lib topiary-cli topiary-playground audit benchmark;
inherit (code) clippy clippy-wasm fmt topiary-core topiary-cli topiary-playground audit benchmark;

## Check that the `lib.pre-commit-hook` output builds/evaluates
## correctly. `deepSeq e1 e2` evaluates `e1` strictly in depth before
Expand Down
2 changes: 1 addition & 1 deletion languages.toml
2 changes: 1 addition & 1 deletion playground.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ get_sample_input() {
local language="$1"

# Only return the first result, presuming there is one
find topiary/tests/samples/input -name "${language}.*" \
find topiary-core/tests/samples/input -name "${language}.*" \
| head -1
}

Expand Down
2 changes: 1 addition & 1 deletion samples/client-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ edition = "2021"

[dependencies]
tokio = { version = "^1.28.1", features = ["rt-multi-thread", "macros"] }
topiary = { path = "../../topiary" }
topiary-core = { path = "../../topiary-core" }
2 changes: 1 addition & 1 deletion samples/client-app/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use topiary::{formatter, Configuration, Operation, TopiaryQuery};
use topiary_core::{formatter, Configuration, Operation, TopiaryQuery};

#[tokio::main]
async fn main() {
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ serde-toml-merge = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["fs", "rt-multi-thread", "sync", "macros"] }
toml = { workspace = true }
topiary = { path = "../topiary" }
topiary-core = { path = "../topiary-core" }
topiary-queries = { path = "../topiary-queries" }
tree-sitter-facade = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clap_complete::{generate, shells::Shell};
use std::{io::stdout, path::PathBuf};

use log::LevelFilter;
use topiary::SupportedLanguage;
use topiary_core::SupportedLanguage;

use crate::{
configuration,
Expand Down
6 changes: 3 additions & 3 deletions topiary-cli/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use directories::ProjectDirs;
use indoc::formatdoc;
use itertools::Itertools;
use std::{env::current_dir, fmt, path::PathBuf};
use topiary::{default_configuration_toml, Configuration};
use topiary_core::{default_configuration_toml, Configuration};

use crate::error::{CLIResult, TopiaryError};

Expand Down Expand Up @@ -164,7 +164,7 @@ impl TryFrom<&ConfigSource> for toml::Value {

/// Return the valid sources of configuration, in priority order (lowest to highest):
///
/// 1. Built-in configuration (`topiary::default_configuration_toml`)
/// 1. Built-in configuration (`topiary_core::default_configuration_toml`)
/// 2. `~/.config/topiary/languages.toml` (or equivalent)
/// 3. `.topiary/languages.toml` (or equivalent)
/// 4. `file`, passed as a CLI argument/environment variable
Expand Down Expand Up @@ -305,7 +305,7 @@ mod test_config_collation {
use super::{collate_toml, CollationMode, Configuration};

// NOTE PartialEq for toml::Value is (understandably) order sensitive over array elements, so
// we deserialse to `topiary::Configuration` for equality testing. This also has the effect of
// we deserialse to `topiary_core::Configuration` for equality testing. This also has the effect of
// side-stepping potential duplication, from concatenation, when using `CollationMode::Merge`.

static BASE: &str = r#"
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{error, fmt, io, process::ExitCode, result};
use topiary::FormatterError;
use topiary_core::FormatterError;

/// A convenience wrapper around `std::result::Result<T, TopiaryError>`.
pub type CLIResult<T> = result::Result<T, TopiaryError>;
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
};

use tempfile::NamedTempFile;
use topiary::{Configuration, Language, SupportedLanguage, TopiaryQuery};
use topiary_core::{Configuration, Language, SupportedLanguage, TopiaryQuery};

use crate::{
cli::{AtLeastOneInput, ExactlyOneInput, FromStdin},
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
};

use tokio::sync::Mutex;
use topiary::{Language, TopiaryQuery};
use topiary_core::{Language, TopiaryQuery};

use crate::{error::CLIResult, io::InputFile};

Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
process::ExitCode,
};

use topiary::{formatter, Operation};
use topiary_core::{formatter, Operation};

use crate::{
cli::Commands,
Expand Down
4 changes: 2 additions & 2 deletions topiary-cli/src/visualisation.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use clap::ValueEnum;
use topiary::Visualisation;
use topiary_core::Visualisation;

/// Visualisation output formats for Tree-sitter parse trees
// NOTE While redundant, we cannot implement clap::ValueEnum for topiary::Visualisation without
// NOTE While redundant, we cannot implement clap::ValueEnum for topiary_core::Visualisation without
// breaking the orphan rules. So we have to maintain a local copy for the sake of the CLI.
#[derive(Clone, Debug, ValueEnum)]
pub enum Format {
Expand Down
2 changes: 1 addition & 1 deletion topiary/Cargo.toml → topiary-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "topiary"
name = "topiary-core"
description = "Formats input source code in a style defined for that language."
categories = ["development-tools", "text-processing"]
keywords = ["code-formatter", "formatter", "text", "tree-sitter"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use criterion::async_executor::FuturesExecutor;
use criterion::{criterion_group, criterion_main, Criterion};
use std::fs;
use std::io;
use topiary::{formatter, Operation};
use topiary::{Configuration, TopiaryQuery};
use topiary_core::{formatter, Operation};
use topiary_core::{Configuration, TopiaryQuery};

async fn format() {
let input = fs::read_to_string("tests/samples/input/ocaml.ml").unwrap();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion topiary/src/lib.rs → topiary-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub enum Operation {
/// # tokio_test::block_on(async {
/// use std::fs::File;
/// use std::io::{BufReader, Read};
/// use topiary::{formatter, Configuration, FormatterError, TopiaryQuery, Operation};
/// use topiary_core::{formatter, Configuration, FormatterError, TopiaryQuery, Operation};
///
/// let input = "[1,2]".to_string();
/// let mut input = input.as_bytes();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::path::Path;
use log::info;
use test_log::test;

use topiary::{
use topiary_core::{
apply_query, formatter, test_utils::pretty_assert_eq, Configuration, FormatterError, Language,
Operation, TopiaryQuery,
};
Expand Down
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions topiary-playground/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ crate-type = ["cdylib"]

[dependencies]
cfg-if = { workspace = true }
topiary = { path = "../topiary" }
topiary-core = { path = "../topiary-core" }
tree-sitter-facade = { workspace = true }
wasm-bindgen = { workspace = true }
wasm-bindgen-futures = { workspace = true }

[build-dependencies]
itertools = { workspace = true }
topiary = { path = "../topiary" }
topiary-core = { path = "../topiary-core" }
6 changes: 3 additions & 3 deletions topiary-playground/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::Write;
use std::path::{Path, PathBuf};
use std::{env::current_dir, fs};

use topiary::{Configuration, SupportedLanguage};
use topiary_core::{Configuration, SupportedLanguage};

fn to_js_string(path: PathBuf) -> String {
fs::read_to_string(path)
Expand All @@ -21,7 +21,7 @@ fn to_js_string(path: PathBuf) -> String {

fn main() {
println!("cargo:rerun-if-changed=../queries/");
println!("cargo:rerun-if-changed=../topiary/tests/samples/input/");
println!("cargo:rerun-if-changed=../topiary-core/tests/samples/input/");

// Export test samples and queries as JS files
let language_dir = current_dir().unwrap().join("../queries/");
Expand Down Expand Up @@ -50,7 +50,7 @@ fn main() {

let input_dir = current_dir()
.unwrap()
.join("../topiary/tests/samples/input/");
.join("../topiary-core/tests/samples/input/");
let input_files = fs::read_dir(input_dir).unwrap();

let mut input_map: HashMap<String, String> = HashMap::new();
Expand Down
4 changes: 2 additions & 2 deletions topiary-playground/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(target_arch = "wasm32")]
use std::sync::Mutex;
#[cfg(target_arch = "wasm32")]
use topiary::{formatter, Configuration, FormatterResult, Language, Operation, TopiaryQuery};
use topiary_core::{formatter, Configuration, FormatterResult, Language, Operation, TopiaryQuery};
#[cfg(target_arch = "wasm32")]
use tree_sitter_facade::TreeSitter;
#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -89,7 +89,7 @@ async fn format_inner(

Ok(String::from_utf8(output)?)
}
None => Err(topiary::FormatterError::Internal(
None => Err(topiary_core::FormatterError::Internal(
"The query has not been initialized.".into(),
None,
)),
Expand Down
4 changes: 2 additions & 2 deletions web-playground/e2e/sample-tester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('test all grammars with puppeteer', () => {

it('can format', async () => {
const rootDir = path.join(__dirname, "../../");
const inputDir = path.join(rootDir, "topiary/tests/samples/input/");
const expectedDir = path.join(rootDir, "topiary/tests/samples/expected/");
const inputDir = path.join(rootDir, "topiary-core/tests/samples/input/");
const expectedDir = path.join(rootDir, "topiary-core/tests/samples/expected/");
const queryDir = path.join(rootDir, "queries/");

for (let inputFileName of await fs.promises.readdir(inputDir)) {
Expand Down

0 comments on commit 4e67fe1

Please sign in to comment.