-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation annotations improvements (Prototype). (#7470)
* Add example annotation. * Support new annotation in documentation generators. * Update src/main/java/ch/njol/skript/doc/Example.java
- Loading branch information
Showing
4 changed files
with
95 additions
and
8 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,50 @@ | ||
package ch.njol.skript.doc; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* An example to be used in documentation for the annotated element. | ||
* Multiple example annotations can be stacked on a single syntax element. | ||
* <p> | ||
* Each annotation should include a single example. | ||
* This can be used instead of the existing {@link ch.njol.skript.doc.Examples} annotation. | ||
* <p> | ||
* <b>Multi-line examples</b> should use multi-line strings. | ||
* Note that whitespace and quotes do not need to be escaped in this mode. | ||
* The indentation will start from the least-indented line (and most IDEs provide a guideline to show this). | ||
* <pre>{@code | ||
* @Example("set player's health to 1") | ||
* @Example(""" | ||
* if player's health is greater than 10: | ||
* send "Wow you're really healthy!" | ||
* """) | ||
* @Example(""" | ||
* # sets the player's health to 1 | ||
* set player's health to 1""") | ||
* public class MyExpression extends ... { | ||
* } | ||
* }</pre> | ||
*/ | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Repeatable(Example.Examples.class) | ||
@Documented | ||
public @interface Example { | ||
|
||
String value(); | ||
|
||
boolean inTrigger() default true; // todo needed? | ||
|
||
/** | ||
* The internal container annotation for multiple examples. | ||
*/ | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@interface Examples { | ||
|
||
Example[] value(); | ||
|
||
} | ||
|
||
} |
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