Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add guide link to readme - 'hooks' are replaced with 'modules' - API page
- Loading branch information
Showing
6 changed files
with
80 additions
and
65 deletions.
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
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,14 @@ | ||
# API | ||
|
||
## Code transformers | ||
|
||
`tgpy.add_code_transformer` | ||
|
||
`code_transformers` | ||
|
||
TODO | ||
|
||
## Available variables | ||
|
||
- `tgpy.variables` - dictionary of variables | ||
- `tgpy.constants` - dictionary of [TGPy constants](builtins.md#tgpy-objects) |
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 was deleted.
Oops, something went wrong.
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,57 @@ | ||
# Modules | ||
|
||
Modules are executed when TGPy starts. For example, with modules you can define shortcut functions for future using. | ||
|
||
## Add modules | ||
|
||
Add one of previous TGPy messages to modules by replying with `modules.add` function. | ||
|
||
```python | ||
modules.add(module_name) | ||
``` | ||
|
||
You can also use `#!python modules.add(module_name, code)` to add any other code. | ||
|
||
If the module with this name already exists, its code will be replaced. | ||
|
||
!!! example | ||
|
||
1. Define a square function: | ||
|
||
```python | ||
def square(x): | ||
return x * x | ||
TGPy> None | ||
``` | ||
|
||
2. Save the definition to modules: | ||
|
||
```python | ||
# in reply to the previous message | ||
modules.add('square') | ||
TGPy> Added module 'square'. | ||
The module will be executed every time TGPy starts. | ||
``` | ||
|
||
## Remove modules | ||
|
||
Remove a module by name: | ||
```python | ||
modules.remove(module_name) | ||
``` | ||
|
||
## Manage your modules | ||
|
||
Use the string value of `modules` to list all of your modules: | ||
|
||
```python | ||
modules | ||
``` | ||
|
||
Modules are executed when TGPy starts. By default, modules are executed in order of addition. | ||
|
||
Modules are stored as separate Python files in `data/modules` directory. You can safely edit them manually. | ||
|
||
TODO: metadata explanation |
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 |
---|---|---|
|
@@ -43,5 +43,6 @@ nav: | |
- builtins.md | ||
- code_detection.md | ||
- Advanced: | ||
- hooks.md | ||
- modules.md | ||
- context.md | ||
- api.md |