Class PropertiesFileDocProvider

java.lang.Object
com.inductiveautomation.ignition.common.script.hints.PropertiesFileDocProvider
All Implemented Interfaces:
ScriptFunctionDocProvider

public class PropertiesFileDocProvider extends Object implements ScriptFunctionDocProvider
Default ScriptFunctionDocProvider implementation that relies on various annotations on methods and fields to look up script documentation in properties files.

Properties files are required to follow a rigid format, following this pattern:

Note: Each row should begin with the 'bundle prefix'; see JythonElement.docBundlePrefix() and getBundlePrefix.

 common-param.$paramName=This is a fallback parameter name that can be used in multiple methods.
 $someFunction.desc=This is a description of $someFunction.
 $someFunction.param.$someParam=This is a description $someParam.
 $someFunction.param.$someParam.type=A type override for $someParam. \
   The supplied type will be passed to TypeDescriptor.lookupOrNull(String).
 $someFunction.param.$someParam.default=This is the default value for $someParam. \
   If specified, the parameter is optional by default.
 $someFunction.param.$someParam.optional=A b boolean string literal to indicate optionality of $someParam, as \
   evaluated by Boolean.parseBoolean(String)
 $someFunction.param.$someParam.deprecated=This is a deprecation message for $someParam.
 $someFunction.param.$someParam.replacement=This is a suggested replacement for $someParam.
 $someFunction.deprecated=This is a deprecation message for $someFunction.
 $someFunction.replacement=This is a replacement suggestion for $someFunction.
 $someFunction.returns=This is a description of the return value.
 $someFunction.returns.type=This is a type override for the return value. \
   The supplied type name will be accepted verbatim and not evaluated for correctness or looked up at all.
 $someFunction.throws.$SomeException=This is a description of why $SomeException would be thrown.
 
See Also:
  • Field Details

    • IGNORED_EXCEPTIONS

      protected static final Set<String> IGNORED_EXCEPTIONS
  • Constructor Details

    • PropertiesFileDocProvider

      public PropertiesFileDocProvider()
  • Method Details

    • getMethodDescriptor

      @Nullable public com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor.Method getMethodDescriptor(String path, Method method)
      Specified by:
      getMethodDescriptor in interface ScriptFunctionDocProvider
      Parameters:
      path - The path this function is being added at, as given to the ScriptManager.
      method - The Method being added as a scripting function.
      Returns:
      A descriptor for the method.
      See Also:
      • CompletionDescriptor.Method
      • TypeDescriptor
    • getMethodDescription

      protected String getMethodDescription(Method m)
    • getParameters

      protected List<com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor.Parameter> getParameters(Method method)
    • parametersFromKeywordArgs

      protected List<com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor.Parameter> parametersFromKeywordArgs(Method method)
    • parametersFromScriptArgs

      protected List<com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor.Parameter> parametersFromScriptArgs(Method method)
    • buildParameter

      protected com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor.Parameter buildParameter(Method method, String parameterName, Class<?> declaredType, Boolean declaredOptional)
    • getReturnType

      protected com.inductiveautomation.ignition.common.script.typing.TypeDescriptor getReturnType(Method method)
    • getReturnDocs

      protected String getReturnDocs(Method method)
    • getAnnotations

      protected List<String> getAnnotations(Method method)
      By default, no Java annotations are exposed to scripting. If you want to expose annotations, override this method.
    • getExceptions

      protected List<com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor.Method.ThrowsDetail> getExceptions(Method method)
      Returns the list of exceptions that the method explicitly throws, plus the list from JythonThrows, minus the list from JythonThrows.ignored().
    • getIgnoredExceptions

      protected Set<String> getIgnoredExceptions()
    • getExceptionDescription

      protected String getExceptionDescription(Method method, String exceptionName)
    • getFieldDescriptor

      public com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor.Attribute getFieldDescriptor(String path, Field field)
      Specified by:
      getFieldDescriptor in interface ScriptFunctionDocProvider
      Parameters:
      path - The path this field is being added at, as given to the ScriptManager.
      field - The Field being added as a scripting field.
      Returns:
      A descriptor for the field.
      See Also:
      • CompletionDescriptor.Attribute
      • TypeDescriptor
    • shouldBeIgnored

      protected boolean shouldBeIgnored(String path, Field field)
    • getFieldDescription

      protected String getFieldDescription(Field f)
    • getFieldValue

      protected String getFieldValue(Field f)
    • getFieldType

      @Nonnull protected com.inductiveautomation.ignition.common.script.typing.TypeDescriptor getFieldType(Field field)
    • getBundlePrefix

      @Nonnull protected String getBundlePrefix(AnnotatedElement element)
    • b10n

      protected String b10n(String format, String... args)
    • getDeprecation

      protected com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor.Deprecation getDeprecation(String bundlePrefix, String name)