CORE/docs/references/preprocessor.gd.md
JeremyStarTM 83ea84b9ab Documentation/website release and more
This commit added:
- A website and documentation (two in one) containing a install guide and code references
- Character counting script (count_characters.sh)
- Godot development project support (making a temporary godot project)
- Makefile
2023-07-09 00:16:15 +02:00

219 lines
6.4 KiB
Markdown

---
hide:
- navigation
---
# Preprocessor (Preprocessor)
The **Preprocessor** can format text.
## Tags *(these can be used in log messages too!)*
All tags can be escaped by adding `esc_` before the tag name. Example:
```text
Raw: <esc_up><esc_np></esc_lo>
Output: <up><np></lo>
```
### No process `<np>`
- end tag `no`
- description `Disables preprocessing completely. Doesn't even display the prefix.`
- example:
``` text
Raw: <up>This is a</up><pa>test</pa><np> MESS<lo>age</lo>.
Output: <up>This is a</up><pa>test</pa> MESS<lo>age</lo>.
```
### Newline `<nl>`
- end tag `no`
- description `Makes a newline while respecting the prefix. Is much recommended over "\n".`
- example (with prefix `prefix_`):
``` text
Raw: Very nice message!<nl>Here's another message :)
Output:
prefix_Very nice message!
Here's another message :)
```
### Lowercase `<lo></lo>`
- end tag `yes`
- description `Makes your text lowercase.`
- example:
``` text
Raw: Did <lo>you FiNd THA</lo>T funny?
Output: Did you find thaT funny?
```
### Uppercase `<up></up>`
- end tag `yes`
- description `Makes your text uppercase.`
- example:
``` text
Raw: ThiS Te<up>XT should be UPPer</up>caSED
Output: ThiS TeXT SHOULD BE UPPERcaSED
```
### Camelcase `<ca></ca>`
- end tag `yes`
- description `Makes your text camelcase.`
- example:
``` text
Raw: This <ca>text should be CamelCa</ca>sed.
Output: This textShouldBeCamelCased.
```
### Pascalcase `<pa></pa>`
- end tag `yes`
- description `Makes your text pascalcase.`
- example:
``` text
Raw: This <pa>text should be PascelCa</pa>sed.
Output: This TextShouldBePascelCased.
```
### Snakecase `<sn></sn>`
- end tag `yes`
- description `Makes your text snakecase.`
- example:
``` text
Raw: This <sn>text should be SnakeCa</sn>sed.
Output: This text_should_be_snake_cased.
```
## Variables
### enabled
- type `bool`
- default value `true`
- description `Enables or disables the preprocessor.`
### verbose_logging
- type `bool`
- default value `false`
- description `Makes the log unreadable. Adds about twenty lines to every process() call.`
### tests_enabled
- type `bool`
- default value `true`
- description `Enables or disables preprocessor testing. Recommended to leave enabled as it disables the preprocessor if it's malfunctioning (somehow). Better to have unformatted text than broken text.`
### tests_level
- type `int`
- default value `1`
- description `Controls when test results are displayed. 0 = Never, 1 = On failure, 2 = Always`
## Methods
### do_tests()
- returns `void`
- description `Performs tests on all preprocessor functions. Very useful for catching bugs while debugging and/or modifying the preprocessor.`
- argument `ignore_flag`
- type `bool`
- mandatory `no, default value is false`
- description `ignores the "tests_enabled" variable if set to true`
### process()
- returns `String`
- description `Formats a message`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for processing`
- argument `prefix`
- type `String`
- mandatory `yes`
- description `The prefix used for newlines`
- argument `pre_msg`
- type `String`
- mandatory `no, default value is ""`
- description `Inserted before the message`
- argument `post_msg`
- type `String`
- mandatory `no, default value is ""`
- description `Inserted after the message`
- argument `exclusion_filter`
- type `Array`
- mandatory `no, default value is []`
- description `Removes specific Strings from the prefix (used in calculating spaces in _newline())`
## Internal variables
Do not touch these or you will cause breakage.
### tests_executed
- type `bool`
- default value `false`
- description `If tests have been executed already or not.`
### tests_log
- type `String`
- default value `""`
- description `The latest preprocessor testing log.`
### tests_success
- type `int`
- default value `0`
- description `The testing success count. If the value is 12, testing succeeded. If not, something is broken.`
## Internal Methods
Do not execute these or you will cause breakage.
### _ready()
- returns `void`
- description `Executes do_tests() and imports logger.`
### _newline()
- returns `String`
- description `Processes the <nl> tag`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for processing the tag`
- argument `prefix`
- type `String`
- mandatory `yes`
- description `The prefix used for newlines`
- argument `pre_msg`
- type `String`
- mandatory `yes`
- description `Inserted before the message`
- argument `post_msg`
- type `String`
- mandatory `yes`
- description `Inserted after the message`
- argument `exclusion_filter`
- type `Array`
- mandatory `yes`
- description `Removes specific Strings from the prefix (used in calculating spaces)`
### _case_lower()
- returns `String`
- description `Processes the <lo></lo> tags`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for processing the tags`
### _case_upper()
- returns `String`
- description `Processes the <up></up> tags`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for processing the tags`
### _case_camelcase()
- returns `String`
- description `Processes the <ca></ca> tags`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for processing the tags`
### _case_pascalcase()
- returns `String`
- description `Processes the <pa></pa> tags`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for processing the tags`
### _case_snakecase()
- returns `String`
- description `Processes the <sn></sn> tags`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for processing the tags`
### _case()
- returns `String`
- description `Executes all _case_* functions`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The messages passed to all other _case_* functions`
### _escapes()
- returns `String`
- description `It escapes tags`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for processing the tags`
### _noprocess()
- returns `bool`
- description `Checks if the "msg" variable contains "<np>"`
- argument `msg`
- type `String`
- mandatory `yes`
- description `The message used for searching "<np>"`