Skip to content

Commit

Permalink
Update documentation with the new alternative name for filters
Browse files Browse the repository at this point in the history
  • Loading branch information
k94ll13nn3 committed May 31, 2018
1 parent bb86577 commit 98b1100
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
7 changes: 5 additions & 2 deletions docs/input/documentation/parser/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ Additionally, a tag can start with:
Filters are similar to tags in term of syntax, but they always start with a `:`.
After that, they only allow these characters:

- Any Unicode letter (as defined [here](https://docs.microsoft.com/fr-fr/dotnet/api/system.char.isletter))
- A `_` or a `-`
- For the name of the filter:
- Any Unicode letter (as defined [here](https://docs.microsoft.com/fr-fr/dotnet/api/system.char.isletter))
- A `_` or a `-`
- For the alternative name of the filter:
- `!`, `%`, `&`, `*`, `.`, `/`, `<`, `=`, `>`, `@`, `^`, `|`, `~`, `?`, `$` or `#`

`:` is not part of the filter name (in term of API), it is only an indicator.

Expand Down
18 changes: 11 additions & 7 deletions docs/input/documentation/parser/tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Order: 4

Almost each token in Strinken has its own API, except the simple arguments, as they are just plain string.
Each token class shares a common interface : [IToken](/Strinken/api/Strinken/IToken/). This interface is composed of two members:

- `Name`: represents the name of the token, as it should appear in the string to process.
- `Description`: a string describing the token. It has no use inside Strinken, but can be used for documentation or displayed in an gui listing tokens.

Expand All @@ -25,20 +26,23 @@ returns the string to be rendered but it has no parameter.
# Filter tokens

For now, there is only one filter token. The filter interface is [IFilter](/Strinken/api/Strinken/IFilter/). In addition to the **IToken** members, it has:

- `Usage`: like the description, it has no use inside Strinken but can be used for documentation or displayed in an gui listing tokens.
- `Validate`: a method that takes all the arguments passed to the filter, and returns a **bool** indicating whether they are valid. This is called by the
content validation process of the parser.
- `Resolve`: a method that takes two arguments
- a **string** corresponding to the value on which the filter is applied (a tag or the result of another filter).
- a **string[]** corresponding to the arguments passed to the filter.
- `AlternativeName`: an alternative name for the filter.
- `Validate`: a method that takes all the arguments passed to the filter, and returns a **bool** indicating whether they are valid. This is called by the content validation process of the parser.
- `Resolve`: a method that takes two arguments
- a **string** corresponding to the value on which the filter is applied (a tag or the result of another filter).
- a **string[]** corresponding to the arguments passed to the filter.

## Filter without arguments

It is possible to easily create filter that takes no arguments by inheriting the
It is possible to easily create filter that takes no arguments by inheriting the
[FilterWithoutArguments](/Strinken/api/Strinken/FilterWithoutArguments/) abstract class. This class has the following abstract members:

- `Name`
- `Description`
- `AlternativeName`
- `Resolve`: a method that takes one argument
- a **string** corresponding to the value on which the filter is applied (a tag or the result of another filter).
- a **string** corresponding to the value on which the filter is applied (a tag or the result of another filter).

The `Usage` is automaticaly computed as *\{tag:**filterName**\}*.
1 change: 1 addition & 0 deletions docs/input/documentation/parser/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class TrimFilter : IFilter
{
public string Description => "Trims a string.";
public string Name => "Trim";
public string AlternativeName => null;
public string Usage => "{tag:Trim}";
public string Resolve(string value, string[] arguments) => value.Trim();
public bool Validate(string[] arguments) => arguments == null || arguments.Length == 0;
Expand Down

0 comments on commit 98b1100

Please sign in to comment.