diff --git a/.github/workflows/snorkell-auto-documentation.yml b/.github/workflows/snorkell-auto-documentation.yml new file mode 100644 index 0000000..926c7e5 --- /dev/null +++ b/.github/workflows/snorkell-auto-documentation.yml @@ -0,0 +1,19 @@ +# This workflow will improvise current file with AI genereated documentation and Create new PR + +name: Penify - Revolutionizing Documentation on GitHub + +on: + push: + branches: ["main"] + workflow_dispatch: + +jobs: + Documentation: + runs-on: ubuntu-latest + steps: + - name: Penify DocGen Client + uses: SingularityX-ai/snorkell-documentation-client@v1.0.0 + with: + client_id: ${{ secrets.SNORKELL_CLIENT_ID }} + api_key: ${{ secrets.SNORKELL_API_KEY }} + branch_name: "main" \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index f036e72..d85dc85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = [ "treeedb", "treeedb-c", + "treeedb-cpp", "treeedb-csharp", "treeedb-java", "treeedb-javascript", @@ -13,6 +14,7 @@ members = [ "treeedbgen", "treeedbgen-souffle", "treeedbgen-souffle-c", + "treeedbgen-souffle-cpp", "treeedbgen-souffle-csharp", "treeedbgen-souffle-java", "treeedbgen-souffle-javascript", diff --git a/treeedb-cpp/Cargo.toml b/treeedb-cpp/Cargo.toml new file mode 100644 index 0000000..d255c75 --- /dev/null +++ b/treeedb-cpp/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "treeedb-cpp" +version = "0.1.0" +edition = "2021" +description = "Generate Datalog facts from C++ source code" +keywords = ["datalog", "cpp", "parsing", "souffle"] +authors = ["Langston Barrett "] +license = "MIT" +readme = "../README.md" +homepage = "https://github.com/langston-barrett/treeedb" +repository = "https://github.com/langston-barrett/treeedb" + +[dependencies] +anyhow = "1.0" +treeedb = { version = "0.1.0", path = "../treeedb", features = ["cli"] } +tree-sitter-cpp = { version = "0.20" } diff --git a/treeedb-cpp/src/main.rs b/treeedb-cpp/src/main.rs new file mode 100644 index 0000000..865aae0 --- /dev/null +++ b/treeedb-cpp/src/main.rs @@ -0,0 +1,5 @@ +use anyhow::Result; + +fn main() -> Result<()> { + treeedb::cli::main(tree_sitter_cpp::language()) +} diff --git a/treeedbgen-souffle-cpp/.gitignore b/treeedbgen-souffle-cpp/.gitignore new file mode 100644 index 0000000..afed073 --- /dev/null +++ b/treeedbgen-souffle-cpp/.gitignore @@ -0,0 +1 @@ +*.csv diff --git a/treeedbgen-souffle-cpp/Cargo.toml b/treeedbgen-souffle-cpp/Cargo.toml new file mode 100644 index 0000000..a414910 --- /dev/null +++ b/treeedbgen-souffle-cpp/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "treeedbgen-souffle-cpp" +version = "0.1.0" +edition = "2021" +description = "Generate Soufflé types and relations from the C++ tree-sitter grammar" +keywords = ["datalog", "cpp", "parsing", "souffle"] +authors = ["Langston Barrett "] +license = "MIT" +readme = "../README.md" +homepage = "https://github.com/langston-barrett/treeedb" +repository = "https://github.com/langston-barrett/treeedb" + +[dependencies] +anyhow = "1" +treeedbgen-souffle = { version = "0.1.0", path = "../treeedbgen-souffle", features = ["cli"] } +tree-sitter-cpp = { version = "0.20" } + +[dev-dependencies] +assert_cmd = "2.0" +predicates = "2.1" +tempfile = "3" \ No newline at end of file diff --git a/treeedbgen-souffle-cpp/src/main.rs b/treeedbgen-souffle-cpp/src/main.rs new file mode 100644 index 0000000..6784e7b --- /dev/null +++ b/treeedbgen-souffle-cpp/src/main.rs @@ -0,0 +1,5 @@ +use anyhow::Result; + +fn main() -> Result<()> { + treeedbgen_souffle::cli::main(tree_sitter_cpp::NODE_TYPES) +} diff --git a/treeedbgen-souffle-cpp/tests/main.rs b/treeedbgen-souffle-cpp/tests/main.rs new file mode 100644 index 0000000..7c2577d --- /dev/null +++ b/treeedbgen-souffle-cpp/tests/main.rs @@ -0,0 +1,33 @@ +use std::process::Command; + +use assert_cmd::prelude::*; +use predicates::prelude::*; +use tempfile::NamedTempFile; + +#[test] +fn gen() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("treeedbgen-souffle-cpp")?; + let tmp = NamedTempFile::new()?; + cmd.arg("-o").arg(tmp.path()); + cmd.arg("--prefix=cpp").arg("--printsize"); + cmd.assert() + .success() + .stdout(predicate::str::is_empty()) + .stderr(predicate::str::is_empty()); + + let mut cmd = Command::cargo_bin("treeedb-cpp")?; + cmd.arg("tests/rs/hello-world.rs"); + cmd.assert() + .success() + .stdout(predicate::str::is_empty()) + .stderr(predicate::str::is_empty()); + + let mut souffle = Command::new("souffle"); + souffle.arg(tmp.path()); + souffle + .assert() + .success() + .stdout(predicate::str::contains("cpp_node\t10")) + .stderr(predicate::str::is_empty()); + Ok(()) +} diff --git a/treeedbgen-souffle-cpp/tests/rs/hello-world.rs b/treeedbgen-souffle-cpp/tests/rs/hello-world.rs new file mode 100644 index 0000000..47ad8c6 --- /dev/null +++ b/treeedbgen-souffle-cpp/tests/rs/hello-world.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello World!"); +}