-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add CONTRIBUTING.md #47
Open
i582
wants to merge
3
commits into
tact-lang:main
Choose a base branch
from
i582:pmakhnev/add-contributing-guide
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Contributing | ||
|
||
Thank you for your interest in contributing to the Tact tree-sitter grammar! We welcome contributions from everyone. | ||
|
||
## Quick Links | ||
- [Issues](https://github.com/tact-lang/tree-sitter-tact/issues) | ||
- [Pull Requests](https://github.com/tact-lang/tree-sitter-tact/pulls) | ||
- [Tree-sitter Documentation](https://tree-sitter.github.io/tree-sitter/) | ||
|
||
## Getting Started | ||
|
||
Before you begin: | ||
- Check if there's already an [open issue](https://github.com/tact-lang/tree-sitter-tact/issues) addressing your problem | ||
- Check out existing [pull requests](https://github.com/tact-lang/tree-sitter-tact/pulls) to see if someone else is working on similar changes | ||
|
||
## How to Contribute | ||
|
||
### Reporting Issues | ||
|
||
- Include code snippets and error messages | ||
- Include as much detail as possible | ||
- Include steps to reproduce the issue | ||
- Include the version of tree-sitter you're using | ||
- Use code blocks for error messages and logs | ||
|
||
### Making Changes | ||
|
||
1. Fork the repository | ||
2. Create a new branch for your changes | ||
3. Make your changes | ||
4. Write or update tests as needed | ||
5. Ensure all tests pass | ||
6. Format the code using `npm run fmt` | ||
7. Submit a pull request | ||
|
||
### Pull Request Process | ||
|
||
1. Update the README.md if needed | ||
2. Follow the existing code style | ||
3. Include a clear description of your changes | ||
4. Link any related issues using keywords (e.g., "Fixes #123") | ||
5. Wait for review from maintainers | ||
|
||
## Development Setup | ||
|
||
This repository contains the Tact language grammar for the [Tree-Sitter](https://tree-sitter.github.io/tree-sitter/) | ||
parsing library. | ||
|
||
### Building grammar | ||
|
||
To generate the grammar after making changes, you first need to install tree-sitter-cli if it is not already | ||
installed: | ||
|
||
``` | ||
npm install | ||
``` | ||
|
||
Now to build the grammar, use the command: | ||
|
||
``` | ||
npm run build | ||
``` | ||
|
||
To generate wasm, use the command: | ||
|
||
``` | ||
npm run build-wasm | ||
``` | ||
|
||
### Testing grammar | ||
|
||
Grammar tests are divided into several types and placed in their own folders inside `test/`: | ||
|
||
- AST tests (`test/corpus`): | ||
|
||
Check that the generated AST matches the expected one. | ||
|
||
- Highlighting tests (`test/highlight`): | ||
|
||
Check that parts of the code have certain type kinds (`keyword`, `type.builtin`, `punctuation.delimiter`, etc.). | ||
|
||
- Tags tests (`test/tags`): | ||
|
||
Check that parts of the code have certain tags (`definition.method`, `definition.constant`, etc.). | ||
|
||
After making changes to the grammar, run the command: | ||
|
||
``` | ||
tree-sitter generate && tree-sitter test | ||
``` | ||
|
||
to test your changes. | ||
|
||
If you see differences after the changes, and you are **absolutely sure** that they are correct (for example, if you | ||
changed a rule name), then add the `-u` flag to automatically update the tests: | ||
|
||
``` | ||
tree-sitter test -u | ||
``` | ||
|
||
For more details, see the official testing documentation in | ||
the [tree-sitter documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers/5-writing-tests.html). | ||
|
||
### Changing grammar | ||
|
||
When changing rules in the grammar, you need a way to check if the file is parsed correctly. There are two options | ||
for checking this. | ||
|
||
Use the command: | ||
|
||
``` | ||
tree-sitter parse file.tact | ||
``` | ||
|
||
to get an AST. If there are errors in it, the output will contain ERROR or MISSING nodes. | ||
|
||
To find out why parsing was unsuccessful, add the `-D --open-log` flags to open the parsing step-by-step report in the | ||
browser. | ||
|
||
The second method involves using the web playground via the command: | ||
|
||
``` | ||
npm run play | ||
``` | ||
|
||
This playground is convenient for changing code in real time and looking at the resulting AST. Don't forget to restart | ||
it after changing the grammar! | ||
|
||
After changing the grammar, don't forget to format it using the command: | ||
|
||
``` | ||
npm run fmt | ||
``` | ||
|
||
#### Queries | ||
|
||
When adding new rules or renaming existing ones, remember to add/rename them in queries located in the `queries/` | ||
and `editor_queries/` folders! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably removed this altogether or moved it somewhere to highlight the dev setup and the overall structure of the project which follows below