config: add documentation for items and sections. (#2829)

This commit is contained in:
Ganom
2020-10-18 22:45:42 -04:00
committed by GitHub
parent b62adaacd9
commit 9cf237a1f6
3 changed files with 198 additions and 1 deletions

View File

@@ -33,36 +33,127 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
public @interface ConfigItem
{
/**
* If there is a section set, it will display in order
* starting from lowest value and ending at highest value
* in that specific section. Else, it will display in order
* for the config panel in a whole.
*
* @return The index of the config item.
*/
int position() default -1;
/**
* This is not visible to users
*
* @return name used for finding the config item
* from the properties map. Hence, KEY name.
*/
String keyName();
/**
* This is the name that is shown to users when looking
* at the config panel.
* <p>
* Choose a name carefully, as there is a maximum width
* that depends on the users DPI scaling. Short is best.
*
* @return display name for the config item.
*/
String name();
/**
* This will be shown to the user if they are hovering
* the config item in the config panel.
*
* @return the description of the config item.
*/
String description();
/**
* If this is set to true, the config field will be
* hidden. You are able to change this value at runtime
* by having another config field unhide it {@link #unhide()}
*/
boolean hidden() default false;
/**
* This is only used for {@link Boolean} config fields.
* <p>
* If this is set, then a warning(y/n) will be displayed
* when the user enables said config field. If they accept
* then the value will be set updated.
*
* @return a warning for enabling the config field.
*/
String warning() default "";
/**
* This is only used for {@link String} config fields.
* <p>
* If this is set to true, any input from the user
* will be hidden, and not displayed. This should
* be used for any sensitive information that may
* be accidentally leaked.
* <p>
* For example; api keys.
*/
boolean secret() default false;
/**
* If this is set, it will look for a section
* by that {@link ConfigSection#name()}, if it exists,
* it will insert the config item under that
* section in order.
*
* @return title of the section.
*/
String section() default "";
/**
* If this is set, it will look for a title section
* by that {@link ConfigTitleSection#name()}, if it exists,
* it will insert the config item under that
* section in order.
*
* @return title of the section.
*/
String titleSection() default "";
/**
* If this is set, it will look for a config item
* by that name. If it is hidden, it will unhide the item.
*
* @return {@link #name()} to unhide.
*/
String unhide() default "";
String unhideValue() default "";
/**
* If this is set, it will look for a config item
* by that name. If it is not hidden, it will hide the item.
*
* @return {@link #name()} to hide.
*/
String hide() default "";
String hideValue() default "";
/**
* If this is set, it will look for a config item
* by the name provided, if that config item is enabled
* then this item will also be enabled.
*/
String enabledBy() default "";
String enabledByValue() default "";
/**
* If this is set, it will look for a config item
* by the name provided, if that config item is disabled
* then this item will also be disabled.
*/
String disabledBy() default "";
String disabledByValue() default "";

View File

@@ -33,25 +33,76 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
public @interface ConfigSection
{
/**
* Displayed position of the section.
*
* @return The index of the section.
*/
int position();
/**
* This is not visible to users
*
* @return name used for finding the config section
* from the properties map. Hence, KEY name.
*/
String keyName();
/**
* This is the name that is shown to users when looking
* at the config panel.
* <p>
* Choose a name carefully, as there is a maximum width
* that depends on the users DPI scaling. Short is best.
*
* @return display name for the config section.
*/
String name();
/**
* This will be shown to the user if they are hovering
* the config item in the config panel.
*
* @return the description of the config item.
*/
String description();
/**
* Setting this will tell the panel
* that this section should be placed beneath
* said section.
*
* @return parent section.
*/
String section() default "";
/**
* NOT USED.
*/
String titleSection() default "";
/**
* NOT USED.
*/
boolean hidden() default false;
/**
* NOT USED.
*/
String unhide() default "";
/**
* NOT USED.
*/
String unhideValue() default "";
/**
* NOT USED.
*/
String hide() default "";
/**
* NOT USED.
*/
String hideValue() default "";
}

View File

@@ -33,25 +33,80 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
public @interface ConfigTitleSection
{
/**
* Displayed position of the title section.
*
* @return The index of the title section.
*/
int position();
/**
* This is not visible to users
*
* @return name used for finding the config section
* from the properties map. Hence, KEY name.
*/
String keyName();
/**
* This is the name that is shown to users when looking
* at the config panel.
* <p>
* Choose a name carefully, as there is a maximum width
* that depends on the users DPI scaling. Short is best.
*
* @return display name for the config title section.
*/
String name();
/**
* This will be shown to the user if they are hovering
* the config item in the config panel.
*
* @return the description of the config item.
*/
String description();
/**
* Setting this will tell the panel
* that this title should be placed beneath
* said section.
*
* @return parent section.
*/
String section() default "";
/**
* Setting this will tell the panel
* that this title should be placed beneath
* said title.
*
* @return parent title section.
*/
String titleSection() default "";
/**
* NOT USED.
*/
boolean hidden() default false;
/**
* NOT USED.
*/
String unhide() default "";
/**
* NOT USED.
*/
String unhideValue() default "";
/**
* NOT USED.
*/
String hide() default "";
/**
* NOT USED.
*/
String hideValue() default "";
}