Skip to content

Commit

Permalink
chore: update manifests, add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Aug 20, 2023
1 parent b11cbc1 commit e3bed64
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 64 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
'env': {
'commonjs': true,
'es2021': true,
},
'extends': 'google',
'overrides': [
],
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module',
},
'rules': {
'indent': ['error', 2, {'SwitchCase': 1}],
'max-len': [
'error',
{'code': 120, 'ignoreComments': true, 'ignoreUrls': true, 'ignoreStrings': true},
],
},
};
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/src/** linguist-vendored
/examples/* linguist-vendored

src/grammar.json linguist-generated
src/node-types.json linguist-generated
src/parser.c linguist-generated

src/grammar.json -diff
src/node-types.json -diff
src/parser.c -diff
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Cargo.lock
node_modules
build
*.log
package-lock.json
target
Cargo.lock
Expand Down
8 changes: 5 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
target
Cargo.lock
build
/test
/examples
/build
/script
/target
25 changes: 13 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
[package]
name = "tree-sitter-jsdoc"
description = "jsdoc grammar for the tree-sitter parsing library"
version = "0.0.1"
description = "JSDoc grammar for tree-sitter"
version = "0.20.0"
authors = [
"Max Brunsfeld <[email protected]>",
"Amaan Qureshi <[email protected]>"
]
license = "MIT"
readme = "bindings/rust/README.md"
keywords = ["incremental", "parsing", "jsdoc"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-javascript"
edition = "2018"
license = "MIT"
edition = "2021"
autoexamples = false

build = "bindings/rust/build.rs"
include = [
"bindings/rust/*",
"grammar.js",
"queries/*",
"src/*",
]
include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]

[lib]
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "0.17"
tree-sitter = "~0.20.10"

[build-dependencies]
cc = "1.0"
cc = "~1.0.83"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 Max Brunsfeld
Copyright (c) 2018 Max Brunsfeld <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
tree-sitter-jsdoc
=================
# tree-sitter-jsdoc

[![Build Status](https://travis-ci.org/tree-sitter/tree-sitter-jsdoc.svg?branch=master)](https://travis-ci.org/tree-sitter/tree-sitter-jsdoc)
[![build](https://github.com/tree-sitter/tree-sitter-python/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-python/actions/workflows/ci.yml)

JSDoc grammar for [tree-sitter][].

[tree-sitter]: https://github.com/tree-sitter/tree-sitter

References

* [UseJSDoc](https://jsdoc.app/)
[JSDoc](<(https://jsdoc.app/)>) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
35 changes: 35 additions & 0 deletions bindings/rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# tree-sitter-jsdoc

This crate provides a JSDoc grammar for the [tree-sitter][] parsing library.
To use this crate, add it to the `[dependencies]` section of your `Cargo.toml`
file. (Note that you will probably also need to depend on the
[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful
way.)

```toml
[dependencies]
tree-sitter = "0.20.10"
tree-sitter-jsdoc = "0.20.0"
```

Typically, you will use the [language][language func] function to add this
grammar to a tree-sitter [Parser][], and then use the parser to parse some code:

```rust
let code = r#"
def double(x):
return x * 2
"#;
let mut parser = Parser::new();
parser.set_language(tree_sitter_jsdoc::language()).expect("Error loading JSDoc grammar");
let parsed = parser.parse(code, None);
```

If you have any questions, please reach out to us in the [tree-sitter
discussions] page.

[language func]: https://docs.rs/tree-sitter-jsdoc/*/tree_sitter_jsdoc/fn.language.html
[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
[tree-sitter]: https://tree-sitter.github.io/
[tree-sitter crate]: https://crates.io/crates/tree-sitter
[tree-sitter discussions]: https://github.com/tree-sitter/tree-sitter/discussions
27 changes: 1 addition & 26 deletions bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,14 @@ fn main() {
let src_dir = std::path::Path::new("src");

let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
c_config.file(&parser_path);

// If your language uses an external scanner written in C,
// then include this block of code:

/*
let scanner_path = src_dir.join("scanner.c");
c_config.file(&scanner_path);
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
*/

c_config.compile("parser");
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());

// If your language uses an external scanner written in C++,
// then include this block of code:

/*
let mut cpp_config = cc::Build::new();
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir.join("scanner.cc");
cpp_config.file(&scanner_path);
cpp_config.compile("scanner");
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
*/
}
8 changes: 4 additions & 4 deletions bindings/rust/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! This crate provides jsdoc language support for the [tree-sitter][] parsing library.
//! This crate provides JSDoc language support for the [tree-sitter][] parsing library.
//!
//! Typically, you will use the [language][language func] function to add this language to a
//! tree-sitter [Parser][], and then use the parser to parse some code:
//!
//! ```
//! let code = "";
//! let mut parser = tree_sitter::Parser::new();
//! parser.set_language(tree_sitter_jsdoc::language()).expect("Error loading jsdoc grammar");
//! parser.set_language(tree_sitter_jsdoc::language()).expect("Error loading JSDoc grammar");
//! let tree = parser.parse(code, None).unwrap();
//! ```
//!
Expand All @@ -31,7 +31,7 @@ pub fn language() -> Language {
/// The content of the [`node-types.json`][] file for this grammar.
///
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
pub const NODE_TYPES: &str = include_str!("../../src/node-types.json");

// Uncomment these to include any queries that this grammar contains

Expand All @@ -47,6 +47,6 @@ mod tests {
let mut parser = tree_sitter::Parser::new();
parser
.set_language(super::language())
.expect("Error loading jsdoc language");
.expect("Error loading JSDoc grammar");
}
}
24 changes: 17 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
{
"name": "tree-sitter-jsdoc",
"version": "0.19.0",
"version": "0.20.0",
"description": "JSDoc grammar for tree-sitter",
"main": "bindings/node",
"keywords": [
"parser",
"lexer"
"lexer",
"jsdoc"
],
"authors": [
"Max Brunsfeld <[email protected]>"
"author": "Max Brunsfeld <[email protected]>",
"contributors": [
"Amaan Qureshi <[email protected]>"
],
"license": "MIT",
"dependencies": {
"nan": "^2.14.1"
"nan": "^2.17.0"
},
"devDependencies": {
"tree-sitter-cli": "^0.19.1"
"eslint": "^8.47.0",
"eslint-config-google": "^0.14.0",
"tree-sitter-cli": "^0.20.8"
},
"scripts": {
"build": "tree-sitter generate && node-gyp build",
"lint": "eslint grammar.js",
"parse": "tree-sitter parse",
"test": "tree-sitter test"
},
"repository": "https://github.com/tree-sitter/tree-sitter-jsdoc",
"tree-sitter": [
{
"scope": "text.jsdoc",
"injection-regex": "jsdoc"
"injection-regex": "jsdoc",
"highlights": [
"queries/highlights.scm"
]
}
]
}

0 comments on commit e3bed64

Please sign in to comment.