Skip to content

Commit bae70aa

Browse files
Refine phrasing in some API pages
1 parent 76b71d3 commit bae70aa

2 files changed

Lines changed: 51 additions & 49 deletions

File tree

src/content/docs/api/localization/localizer.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ However, there will be no breaking changes to methods detailed below.
1313
If necessary, they would only be deprecated for future removal.
1414
:::
1515

16-
The Localizer is an **experimental** interface defining the methods available for localization.
17-
Currently, it is only used by addons to load their language files, which is described below.
16+
Localizer is an **experimental** interface describing the methods available for localization.
17+
Currently, it is only used by addons to load their language files, which is detailed below.
1818

19-
## Obtaining a Localizer
19+
## Obtaining a localizer
2020
A Localizer instance is available through your [registered addon](../../skript/addons) by calling the `localizer()` method:
2121
```java
2222
SkriptAddon addon = ...;
2323
Localizer addonLocalizer = addon.localizer();
2424
```
2525

2626
## Loading language files
27-
The localizer currently provides a single method, `setSourceDirectories(String, String)` for loading an addon's language files.
27+
The Localizer interface currently describes a single method, `setSourceDirectories(String, String)` for loading an addon's language files.
2828
It takes two parameters:
2929
- A string representing the path to the directory (on the jar) containing language files
3030
- A string representing the path to the directory (on the disk) containing language files

src/content/docs/api/syntax/writing-syntax.md

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@ sidebar:
44
order: 5
55
---
66

7-
## SyntaxInfos
8-
9-
In Skript, every syntax is defined by a [SyntaxInfo](https://github.com/SkriptLang/Skript/blob/master/src/main/java/org/skriptlang/skript/registration/SyntaxInfo.java)
10-
that describes the properties of that syntax.
11-
12-
### Creating SyntaxInfos
13-
Skript provides a standard implementation and builder for SyntaxInfos.
14-
A new builder can be created by using the `builder(Class)` method on SyntaxInfo.
15-
It takes one parameter: the class implementing the syntax.
16-
As an example, let's start by creating a new builder for a SyntaxInfo:
7+
## Syntax infos
8+
In Skript, every syntax is defined by a syntax info that describes the properties of that syntax.
9+
A syntax info is described by the [SyntaxInfo](https://github.com/SkriptLang/Skript/blob/master/src/main/java/org/skriptlang/skript/registration/SyntaxInfo.java) interface.
10+
11+
### Creating syntax infos
12+
Skript provides a standard implementation and builder for creating syntax infos.
13+
A new builder can be created by using the `builder(Class)` method from the SyntaxInfo interface.
14+
It takes one parameter: the Class implementing the syntax.
15+
As an example, let's start by creating a new builder for a syntax info:
1716
```java
1817
var builder = SyntaxInfo.builder(MySyntax.class);
1918
```
20-
We recommend using `var` for SyntaxInfo builders to simplify generics handling.
19+
We recommend using `var` for syntax info builders to simplify generics handling.
2120

2221
### Patterns
2322
Every syntax is made up of patterns that must be matched for your syntax implementation to be used.
24-
They can be accessed by calling the `patterns` method on a SyntaxInfo.
23+
They can be accessed by calling the `patterns` method on a syntax info.
2524

2625
The simplest pattern is made up of literal characters:
2726
```text
@@ -129,8 +128,8 @@ The pattern options summarized are:
129128
- Use angle brackets (`<expr>`) for regular expressions
130129
- Use colons (`tag:pattern`) for parse tags
131130

132-
#### Adding patterns to a SyntaxInfo
133-
We can add patterns to a SyntaxInfo builder by using any of the following methods:
131+
#### Adding patterns to a syntax info
132+
When creating a syntax info, patterns can be added by using the following methods from the SyntaxInfo.Builder interface:
134133
- `addPattern(String)`
135134
- `addPatterns(String[])`
136135
- `addPatterns(Collection)`
@@ -144,12 +143,12 @@ builder.addPattern("(stop|shutdown) [the] server [in %-timespan%]");
144143
```
145144

146145
### Type
147-
Every SyntaxInfo has a class that provides the implementation of the syntax it describes.
148-
It can be obtained by calling the `type` method on a SyntaxInfo.
146+
Every syntax info has a class that provides the implementation of the syntax it describes.
147+
It can be obtained by calling the `type` method of a SyntaxInfo.
149148

150149
#### Creating new instances
151-
When Skript matches a SyntaxInfo during the parsing process, it needs to instantiate the class providing the implementation of the syntax.
152-
Skript uses the `instance` method of a SyntaxInfo for this instantiation.
150+
When Skript matches a syntax info during the parsing process, it needs to instantiate the class providing the implementation of the syntax.
151+
Skript invokes the `instance` method of a SyntaxInfo for this instantiation.
153152

154153
By default, Skript uses reflection to instantiate new instances.
155154
This requires that the class have a nullary (zero argument) constructor.
@@ -161,41 +160,41 @@ builder.supplier(MySyntax::new); // equivalent to: () -> new MySyntax()
161160
```
162161

163162
### Priority
164-
The priority of a SyntaxInfo dictates its position for matching during parsing.
165-
That is, a collection of SyntaxInfos will be sorted by their priority, and Skript will attempt to match each SyntaxInfo through order-based traversal.
163+
The priority of a syntax info dictates its position for matching during parsing.
164+
That is, a collection of syntax infos will be sorted by their priority, and Skript will attempt to match each syntax info through order-based traversal.
166165
It can be obtained by calling the `priority` method on a SyntaxInfo.
167166

168-
There are three standard priorities used by Skript, available as constants on SyntaxInfo:
169-
- `SIMPLE` - For SyntaxInfos with patterns that only match simple text. That is, they do not contain any other expressions.
170-
- `COMBINED` For SyntaxInfos with patterns that contain other expressions.
171-
- `PATTERN_MATCHES_EVERYTHING` For SyntaxInfos with patterns that contain adjacent expressions.
167+
There are three standard priorities used by Skript, available as constants on the SyntaxInfo interface:
168+
- `SIMPLE` - For syntax infos with patterns that only match simple text. That is, they do not contain any other expressions.
169+
- `COMBINED` For syntax infos with patterns that contain other expressions.
170+
- `PATTERN_MATCHES_EVERYTHING` For syntax infos with patterns that contain adjacent expressions.
172171

173172
`SIMPLE` is the earliest priority, with `COMBINED` coming directly after, followed by `PATTERN_MATCHES_EVERYTHING`.
174173

175-
The default SyntaxInfo builders will automatically assign a priority based on these criteria.
174+
The default builders will automatically assign a priority based on these criteria.
176175
Thus, it is generally unnecessary to specify a priority.
177-
However, if there is a need to override the automatic assignment, a priority can be specified by calling the `priority` method on a SyntaxInfo builder, for example:
176+
However, if there is a need to override the automatic assignment, a priority can be specified by calling the `priority` method on a builder, for example:
178177
```java
179178
var builder = SyntaxInfo.builder(MySyntax.class);
180179
builder.priority(SyntaxInfo.PATTERN_MATCHES_EVERYTHING);
181180
```
182181

183182
### Origin
184-
The origin of a SyntaxInfo provides information about its source, such as the [SkriptAddon](../../skript/addons) that registered it.
183+
The origin of a syntax info provides information about its source, such as the [addon](../../skript/addons) that registered it.
185184
It can be obtained by calling the `origin` method on a SyntaxInfo.
186185

187-
The default Skript implementation will automatically assign an origin to a SyntaxInfo when it is registered (if one was not specified during building).
188-
For documentation purposes, it can be helpful to provide more information than just the addon that registered a SyntaxInfo.
189-
For example, if using the [AddonModule](../../skript/addons#addon-modules) system, an origin that also describes the module can be created:
186+
The default Skript implementation will automatically assign an origin to a syntax info when it is registered (if one was not specified during building).
187+
For documentation purposes, it can be helpful to provide more information than just the addon that registered a syntax info.
188+
For example, if using the [addon module](../../skript/addons#addon-modules) system, an origin that also describes the module can be created:
190189
```java
191190
var builder = SyntaxInfo.builder(MySyntax.class);
192191
builder.origin(AddonModule.origin(addonInstance, moduleInstance));
193192
```
194193

195-
## The SyntaxRegistry
196-
The [SyntaxRegistry](https://github.com/SkriptLang/Skript/blob/master/src/main/java/org/skriptlang/skript/registration/SyntaxRegistry.java) is the central store of all registered SyntaxInfos.
194+
## The Syntax Registry
195+
The Syntax Registry, described by the [SyntaxRegistry](https://github.com/SkriptLang/Skript/blob/master/src/main/java/org/skriptlang/skript/registration/SyntaxRegistry.java) interface, is the central store of all registered syntax infos.
197196

198-
It can be accessed by calling the `syntaxRegistry` method on SkriptAddon.
197+
It can be accessed by calling the `syntaxRegistry` method on a SkriptAddon.
199198
:::note
200199
This is the same as calling:
201200
```java
@@ -204,22 +203,22 @@ SyntaxRegistry syntaxRegistry = addon.registry(SyntaxRegistry.class);
204203
```
205204
:::
206205

207-
With a SyntaxRegistry, you can obtain all registered SyntaxInfos or all registered SyntaxInfos of a specific type (key, described further below).
208-
It is also possible to register and unregister SyntaxInfos.
206+
A syntax registry can be used to obtain all registered syntax infos or all registered syntax infos of a specific type (key, described further below).
207+
It is also possible to register and unregister syntax infos.
209208

210209
### Keys
211-
Keys are used to store SyntaxInfos based on the type of syntax they represent.
210+
Keys are used to store syntax infos based on the type of syntax they represent.
212211

213-
Skript provides the following keys (based on the standard types of syntax), available as constants on SyntaxRegistry:
212+
Skript provides the following keys (based on the standard types of syntax), available as constants on the SyntaxRegistry interface:
214213
- `STRUCTURE`
215214
- `SECTION`
216215
- `STATEMENT`
217216
- `EFFECT` (child of `STATEMENT`)
218217
- `CONDITION` (child of `STATEMENT`)
219218
- `EXPRESSION`
220219

221-
Keys can be created using the `of` method on Key.
222-
It takes one parameter: a string typically representing the name of the syntax element type represented by the key.
220+
Keys can be created using the `of` method from the Key interface (a subinterface of the SyntaxRegistry interface).
221+
It takes one parameter: a String typically representing the name of the syntax element type represented by the key.
223222
```java
224223
Key<SyntaxInfo<? extends Statement>> STATEMENT = Key.of("statement");
225224
```
@@ -232,16 +231,19 @@ Thus, the syntax stored under `STATEMENT` includes the union of the syntaxes sto
232231
While it is possible to register syntax only under the `STATEMENT` key, this is atypical and may result in unexpected behavior.
233232
:::
234233

235-
Child keys can be created using the `of` method on ChildKey, for example:
234+
Child keys can be created using the `of` method from the ChildKey interface (a subinterface of the SyntaxRegistry interface).
235+
It takes two parameters:
236+
- A Key representing the parent
237+
- A String (typically representing the name of the syntax element type represented by the key)
236238
```java
237239
Key<SyntaxInfo<? extends Effect>> EFFECT = ChildKey.of(STATEMENT, "effect");
238240
```
239241

240242
### Registering syntax
241-
A SyntaxInfo can be registered using the `register(Key, SyntaxInfo)` method.
243+
A syntax info can be registered using the `register(Key, SyntaxInfo)` method.
242244
It takes in two parameters:
243-
- The key to register the SyntaxInfo under (see above)
244-
- The SyntaxInfo to register
245+
- A Key to register the syntax info under (see above)
246+
- A SyntaxInfo to register
245247
For example, combining everything we have learned so far, we are ready to register a syntax:
246248
```java
247249
var key = ...; // key to be determined by the type of syntax you are registering (see above)
@@ -254,8 +256,8 @@ addon.syntaxRegistry().register(key, builder.build());
254256
#### Unregistering syntax
255257
There exists a similar method for unregistering syntax: `unregister(Key, SyntaxInfo)`.
256258
It takes in the same parameters as the `register` method:
257-
- The key the SyntaxInfo is stored under
258-
- The SyntaxInfo to unregister
259+
- A Key to register the syntax info under (see above)
260+
- A SyntaxInfo to register
259261

260262
If this all still seems confusing, that is understandable.
261263
The rest of these pages will provide information about registering and implementing syntax for each of Skript's built-in syntax types.

0 commit comments

Comments
 (0)