docs: add mdbook-admonish for better tooltips

This commit is contained in:
Amaan Qureshi 2025-01-10 02:29:32 -05:00
parent c8bd78a29c
commit 21d74b8482
15 changed files with 435 additions and 48 deletions

View file

@ -53,7 +53,9 @@ typedef uint32_t (*DecodeFunction)(
);
```
> Note that the `TSInputEncoding` must be set to `TSInputEncodingCustom` for the `decode` function to be called.
```admonish attention
The `TSInputEncoding` must be set to `TSInputEncodingCustom` for the `decode` function to be called.
```
The `string` argument is a pointer to the text to decode, which comes from the `read` function, and the `length` argument
is the length of the `string`. The `code_point` argument is a pointer to an integer that represents the decoded code point,

View file

@ -154,8 +154,11 @@ TSTree *ts_tree_copy(const TSTree *);
Internally, copying a syntax tree just entails incrementing an atomic reference count. Conceptually, it provides you a new
tree which you can freely query, edit, reparse, or delete on a new thread while continuing to use the original tree on a
different thread. Note that individual `TSTree` instances are _not_ thread safe; you must copy a tree if you want to use
it on multiple threads simultaneously.
different thread.
```admonish danger
Individual `TSTree` instances are _not_ thread safe; you must copy a tree if you want to use it on multiple threads simultaneously.
```
[ejs]: https://ejs.co
[erb]: https://ruby-doc.org/stdlib-2.5.1/libdoc/erb/rdoc/ERB.html

View file

@ -4,14 +4,13 @@ You can access every node in a syntax tree using the `TSNode` APIs [described ea
to access a large number of nodes, the fastest way to do so is with a _tree cursor_. A cursor is a stateful object that
allows you to walk a syntax tree with maximum efficiency.
<div class="warning">
Note that the given input node is considered the root of the cursor, and the cursor cannot walk outside this node.
```admonish note
The given input node is considered the root of the cursor, and the cursor cannot walk outside this node.
Going to the parent or any sibling of the root node will always return `false`.
This has no unexpected effects if the given input node is the actual `root` node of the tree, but is something to keep in
mind when using cursors constructed with a node that is not the `root` node.
</div>
```
You can initialize a cursor from any node:

View file

@ -186,13 +186,15 @@ To recap about the predicates and directives Tree-Sitter's bindings support:
- `#strip!` removes text from a capture
_Note_ — Predicates and directives are not handled directly by the Tree-sitter C library.
```admonish info
Predicates and directives are not handled directly by the Tree-sitter C library.
They are just exposed in a structured form so that higher-level code can perform
the filtering. However, higher-level bindings to Tree-sitter like
[the Rust Crate][rust crate]
or the [WebAssembly binding][wasm binding]
do implement a few common predicates like those explained above. In the future, more "standard" predicates and directives
may be added.
```
[cgo]: https://pkg.go.dev/cmd/cgo
[rust crate]: https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding_rust