Skip to content

Commit 064848a

Browse files
committed
Describe validation rules in docs
Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
1 parent 921a458 commit 064848a

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

docs/lime_markdown.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,43 @@ Excluding an element from documentation
239239
Documentation comments support a special `@exclude` tag. This tag is converted into a language-appropriate "exclude from
240240
the documentation" tag in the generated code. When using this tag, it should be placed on a separate line of its own
241241
within the IDL documentation comment.
242+
243+
Validation rules for documentation comments
244+
---------------------------------------
245+
246+
Sometimes certain elements must contain given required information. For instance, about module to which given public interface belongs or
247+
online/offline availability. In order to add custom validation of comments, a dedicated JSON file with rules can be used. The file can be
248+
specified via `-docsvalidationrules` CLI option or `GLUECODIUM_DOCS_VALIDATION_RULES` CMake parameter. The JSON file must contain a list
249+
of rules. Each rule consists of required fields:
250+
- **name** - the name of the rule, which must be unique within the file
251+
- **limeElements** - the list of LIME elements to which the rule applies. The supported elements are: `class`, `struct`,
252+
`interface`, `lambda`, `enum`, `function` and `property`.
253+
- **regex** - the regular expression used to validate the comment.
254+
255+
Moreover, the following optional fields may be used for a rule:
256+
- **isWarningOnly** - by default it is set to `false`. This field is used to control the behavior of validator that is triggered
257+
when the rule is not respected. When this field is set to `true` then only warning is raised instead of an error.
258+
- **resolvePlaceholders** - by default it is set to `true`. This field is used to ease creation of validation rules that want to
259+
check if placeholder is used in the body of comment. When this flag is set to `false` then validation rule may look only for
260+
`@Placeholder <NAME>`.
261+
- **platforms** - by default a rule is checked for all generated platforms. However, there may be a need to create platform-specific
262+
rule e.g. respected only for Java, Swift, Kotlin or Dart. In such a case `platforms` field can be used - it is a list of platforms
263+
specified as string. When this field is set the rule is applied only for the specified platforms.
264+
265+
The example input JSON with rules can be found below:
266+
```
267+
[
268+
{
269+
"name": "Availability rule",
270+
"limeElements": ["class", "interface"],
271+
"regex": "@Placeholder (AvailableOnline|AvailableOffline)",
272+
"resolvePlaceholders": false
273+
},
274+
{
275+
"name": "Module belonging",
276+
"limeElements": ["class", "struct", "interface", "lambda", "enum"],
277+
"regex": "This type belongs to modules: .*"
278+
},
279+
]
280+
```
281+

0 commit comments

Comments
 (0)