Artur Mukhamadiev a4e1284a54 [packaging] convert to installable executable package
- rename src/ts-example -> src/ts_example (valid import identifier)
- switch intra-package imports to relative form
- add hatchling build-system, [project.scripts] entry point (ts-example),
  and src-layout wheel config to pyproject.toml
- move runtime deps (rich, textual, textual-autocomplete) into pyproject
- update README: pip install -e ., launch via ts-example or python -m ts_example
2026-07-12 23:06:54 +03:00

54 lines
1.3 KiB
Markdown

# Tree sitter Seminar
## Prerequisites
```bash
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -e .
```
The `-e` flag installs the package in editable mode, so edits under `src/`
are picked up without reinstalling. The install also creates a `ts-example`
command on your PATH (see `pyproject.toml` -> `[project.scripts]`).
## Launch
Once installed, run the package via its console script:
```bash
$ ts-example minimal --file path/to/file.py
```
or equivalently as a module:
```bash
$ python3 -m ts_example minimal --file path/to/file.py
```
## TUI usage
Start the TUI (the required `--file` argument can be the file you intend to
inspect). Global options such as `--tui` must come *before* the subcommand:
```bash
$ ts-example --tui minimal --file path/to/file.py
```
At the prompt, load a file and then inspect grammar fields:
```text
> read_file path/to/file.py
> find_field_values function_definition name
```
`find_field_values <node_type> <field_name>` walks every matching node and
prints the named field and its location. Node and field names are
language-grammar-specific. For example, C++ class names can be found with:
```text
> find_field_values class_specifier name
```
Other available commands include `dump_tree` and `get_usages <function>`.