All Downloads are FREE. Search and download functionalities are using the official Maven repository.

vertx-java.template.dataObjectCheatsheet.templ Maven / Gradle / Ivy

There is a newer version: 4.5.10
Show newest version
@comment{'A template @DataObject that creates cheatsheets doc'}

@includeNamed{'common-lib.templ'}

@code{

  /**
   * Render a tag link to an its plain value, this function is used as parameter of the
   * renderDocToHtml function when it needs to render tag links.
   */
  def renderTagLinkToHtml(tag) {
    return tag.name;
  }

  /**
   * Return the formatted property data type.
   */
  def getDataType(type) {
    var kind = type.kind;
    if (kind.basic) {
      if (kind == CLASS_STRING) {
        return 'String';
      }
      var typeName = type.name;
      if (typeName == 'java.lang.Boolean' || typeName == 'boolean') {
        return "Boolean";
      }
      if (typeName == 'java.lang.Character' || typeName == 'chat') {
        return "Char";
      }
      if (typeName == 'java.lang.Byte' || typeName == 'byte' ||
          typeName == 'java.lang.Short' || typeName == 'short' ||
          typeName == 'java.lang.Integer' || typeName == 'int' ||
          typeName == 'java.lang.Long' || typeName == 'long' ||
          typeName == 'java.lang.Float' || typeName == 'float' ||
          typeName == 'java.lang.Double' || typeName == 'double') {
        return 'Number (' + type.simpleName + ')';
      }
    } else if (kind == CLASS_JSON_OBJECT) {
      return 'Json object';
    } else if (kind == CLASS_JSON_ARRAY) {
      return 'Json array';
    } else if (kind == CLASS_DATA_OBJECT) {
      return 'link:dataobjects.html#' + type.raw.simpleName + '[' + type.raw.simpleName + ']';
    } else if (kind == CLASS_ENUM) {
      return 'link:enums.html#' + type.raw.simpleName + '[' + type.raw.simpleName + ']';
    } else if (kind == CLASS_API) {
      if (type.name == 'io.vertx.core.buffer.Buffer') {
        return "Buffer"
      }
    }
    System.out.println("unhandled type " + type);
    return null;
  }
}

[[@{type.simpleName}]]\n
== @{type.simpleName}\n
\n
@if{doc != null}
++++\n
@{renderDocToHtml('', doc, renderTagLinkToHtml)}
++++\n
'''\n
@end{}
\n
[cols=">25%,^25%,50%"]\n
[frame="topbot"]\n
|===\n
^|Name | Type ^| Description\n
@foreach{property:properties}
	@code{propertyType=getDataType(property.type)}
	@code{arrayPrefix = (property.list || property.set) ? 'Array of ' : ''}
	@if{propertyType != null}
		|[[@{property.name}]]`@{property.name}`
		|`@{arrayPrefix}@{getDataType(property.type)}`
		|@if{property.doc != null}\n
		+++\n
		@{renderDocToHtml('', property.doc, renderTagLinkToHtml).trim()}\n
		+++\n
		@else{}-\n@end{}
	@end{}
@end{}
|===\n




© 2015 - 2024 Weber Informatics LLC | Privacy Policy