Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 804ca1d

Browse files
author
Hendrik van Antwerpen
committed
Update project documentation of tree-sitter-stack-graphs-typescript
1 parent 3286f81 commit 804ca1d

File tree

3 files changed

+131
-14
lines changed

3 files changed

+131
-14
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish tree-sitter-stack-graphs-typescript release
2+
3+
on:
4+
push:
5+
tags:
6+
- tree-sitter-stack-graphs-typescript-v*
7+
8+
jobs:
9+
publish-crate:
10+
runs-on: ubuntu-latest
11+
env:
12+
CARGO_TERM_COLOR: always
13+
CARGO_INCREMENTAL: 0
14+
CRATE_DIR: './languages/tree-sitter-stack-graphs-typescript'
15+
steps:
16+
- name: Install Rust environment
17+
uses: hecrj/setup-rust-action@v1
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
# TODO Verify the crate version matches the tag
21+
- name: Test crate
22+
run: cargo test --all-features
23+
working-directory: ${{ env.CRATE_DIR }}
24+
- name: Verify publish crate
25+
run: cargo publish --dry-run
26+
working-directory: ${{ env.CRATE_DIR }}
27+
- name: Publish crate
28+
run: cargo publish
29+
working-directory: ${{ env.CRATE_DIR }}
30+
env:
31+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
32+
create-release:
33+
needs: publish-crate
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: write
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v3
40+
- name: Create GitHub release
41+
uses: ncipollo/release-action@v1
42+
with:
43+
body: |
44+
Find more info on all releases at https://crates.io/crates/tree-sitter-stack-graphs-typescript.
45+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## Unreleased
9+
10+
### Added
11+
12+
- Stack graph rules, tests, and basic `tsconfig.json` and `package.json` analysis.
Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,98 @@
11
# tree-sitter-stack-graphs definition for TypeScript
22

3-
This project defines tree-sitter-stack-graphs rules for TypeScript using the [tree-sitter-typescript](https://www.npmjs.com/package/tree-sitter-typescript) grammar.
3+
This project defines tree-sitter-stack-graphs rules for TypeScript using the [tree-sitter-typescript][] grammar.
4+
5+
[tree-sitter-typescript]: https://crates.io/crates/tree-sitter-typescript
6+
7+
## Usage
8+
9+
To use this library, add the following to your `Cargo.toml`:
10+
11+
``` toml
12+
[dependencies]
13+
tree-sitter-stack-graphs-typescript = "0.1"
14+
```
15+
16+
Check out our [documentation](https://docs.rs/tree-sitter-stack-graphs-typescript/*/) for
17+
more details on how to use this library.
18+
19+
## Command-line Program
20+
21+
The command-line program for `tree-sitter-stack-graphs-typescript` lets you do
22+
stack graph based analysis and lookup from the command line.
23+
24+
Install the program using `cargo install` as follows:
25+
26+
``` sh
27+
$ cargo install --features cli tree-sitter-stack-graphs-typescript
28+
$ tree-sitter-stack-graphs-typescript --help
29+
```
430

531
## Development
632

33+
The project is written in Rust, and requires a recent version installed.
34+
Rust can be installed and updated using [rustup][].
35+
36+
[rustup]: https://rustup.rs/
37+
38+
739
The project is organized as follows:
840

941
- The stack graph rules are defined in `src/stack-graphs.tsg`.
1042
- Builtins sources and configuration are defined in `src/builtins.ts` and `builtins.cfg` respectively.
1143
- Tests are put into the `test` directory.
1244

13-
Make sure all development dependencies are installed by running:
45+
Build the project by running:
1446

15-
npm install
47+
``` sh
48+
$ cargo build
49+
```
1650

17-
Run all tests in the project by executing the following:
51+
Run the tests as follows:
1852

19-
npm test
53+
``` sh
54+
$ cargo test
55+
```
2056

21-
Parse and test a single file by executing the following commands:
57+
The project consists of a library and a CLI.
58+
By default, running `cargo` only applies to the library.
59+
To run `cargo` commands on the CLI as well, add `--features cli` or `--all-features`.
2260

23-
npm run parse-file test/test.ts
24-
npm run test-file test/test.ts
61+
Run the CLI from source as follows:
2562

26-
Additional flags can be passed to these commands as well. For example, to generate a visualization for the test, execute:
63+
``` sh
64+
$ cargo run --features cli -- ARGS
65+
```
2766

28-
npm run test-file -- -V test/test.ts
67+
Sources are formatted using the standard Rust formatted, which is applied by running:
2968

30-
To generate the visualization regardless of test outcome, execute:
69+
``` sh
70+
$ cargo fmt
71+
```
72+
73+
The stack graph rules are written in [tree-sitter-graph][], which provides a VSCode
74+
extension for syntax highlighting.
75+
76+
[tree-sitter-graph]: https://github.com/tree-sitter/tree-sitter-graph
3177

32-
npm run test-file -- -V --output-mode=always test/test.ts
78+
Parse and test a single file by executing the following commands:
79+
80+
``` sh
81+
$ cargo run -- parse FILES...
82+
$ cargo run -- test TESTFILES...
83+
```
84+
85+
Additional flags can be passed to these commands as well. For example, to generate
86+
a visualization for the test, execute:
3387

34-
These commands should be enough for regular development. If necessary, the `tree-sitter-stack-graphs` command can be invoked directly as well, by executing:
88+
``` sh
89+
$ cargo run -- test -V TESTFILES...
90+
```
91+
92+
To generate the visualization regardless of test outcome, execute:
3593

36-
npx tree-sitter-stack-graphs
94+
``` sh
95+
$ cargo run -- test -V --output-mode=always TESTFILES...
96+
```
3797

3898
Go to https://crates.io/crates/tree-sitter-stack-graphs for links to examples and documentation.

0 commit comments

Comments
 (0)