Difference between revisions of "User:Glyph"

From Kerbal Space Program Wiki
Jump to: navigation, search
Line 24: Line 24:
 
  |name=string
 
  |name=string
 
  |summary=string|default blank
 
  |summary=string|default blank
 +
 +
// Template for a list of enumerations that are part of a class.
 +
Template:ClassEnums
 +
|enums=Template:ClassEnum
 +
 +
Template:ClassEnum
 +
|name=string
 +
|values=Template:ClassEnumValue...  <- List of Template:ClassEnumValue, without commas between them.
 +
 +
Template:ClassEnumValue
 +
|name=string
 +
|value=string  <- If this enum value is given an actual int value, specify that value here (without the =).
 
   
 
   
 
  Template:Properties
 
  Template:Properties
  |properties=Template:Property...  <- List of Template:Property templates, no comma between them.
+
  |properties=Template:Property...  <- List of Template:Property templates, without commas between them.
 
   
 
   
 
  Template:Property
 
  Template:Property
Line 34: Line 46:
 
  |get=true|default blank
 
  |get=true|default blank
 
  |set=true|default blank
 
  |set=true|default blank
 +
|static=true|default blank
 
  |summary=string|default blank
 
  |summary=string|default blank
 
   
 
   
Line 57: Line 70:
 
  |static=true|default blank
 
  |static=true|default blank
 
  |virtual=true|default blank
 
  |virtual=true|default blank
  |args=Template:Arg,...  <- Comma separated list of Template:Arg.
+
  |args=Template:Arg, ...  <- Comma separated list of Template:Arg. Actually separated by ", " (comma and a space).
 
  |summary=string|default blank
 
  |summary=string|default blank
 
   
 
   
Line 73: Line 86:
 
                                             generics template e.g. List<int> would have Template:Generic(Template:Type(int)).
 
                                             generics template e.g. List<int> would have Template:Generic(Template:Type(int)).
 
   
 
   
  Template:Generic
+
  Template:Generics
 
  |types=Template:Type,...  <- All the types that this generic template has, comma separated.
 
  |types=Template:Type,...  <- All the types that this generic template has, comma separated.

Revision as of 08:09, 14 October 2015

Things that need doing

  • PropertiesStart and PropertiesEnd templates to be replaced with Properties to fit in line with Methods, Fields, etc.
  • We could use a better Template:Type. Probably something that works recursively so we can have proper links to templated types e.g. Dictionary<String, Vessel> will properly link to Vessel.
  • Could use a template to stick at the top of API pages that urges users to contribute to the API descriptions.

API classes updated to KSP 1.04

Classes left to do

Error: infinite lists not supported

How to fix API templates

API templates are in a terrible state. None of their pages are clear in their intent or documentation, and the logic behind their structure does not work regardless. Using special generics tags is not enough.

Here is a possible re-implementation using some tricks from EBNF (a language for specifying syntax).

Template:Class
|name=string
|summary=string|default blank

// Template for a list of enumerations that are part of a class.
Template:ClassEnums
|enums=Template:ClassEnum

Template:ClassEnum
|name=string
|values=Template:ClassEnumValue...  <- List of Template:ClassEnumValue, without commas between them.

Template:ClassEnumValue
|name=string
|value=string  <- If this enum value is given an actual int value, specify that value here (without the =).

Template:Properties
|properties=Template:Property...  <- List of Template:Property templates, without commas between them.

Template:Property
|name=string
|type=Template:Type
|access=string  <- "public" or "protected"
|get=true|default blank
|set=true|default blank
|static=true|default blank
|summary=string|default blank

Template:Fields
|fields=Template:Field...  <- List of Template:Field templates, no comma between them.

Template:Field
|name=string
|type=Template:Type
|access=string  <- "public" or "protected"
|static=true|default blank
|const=true|default blank
|initialValue=string|default blank
|summary=string|default blank

Template:Methods
|methods=Template:Method...  <- List of Template:Method templates, no comma between them.

Template:Method
|name=string
|returnType=Template:Type|blank  <- blank for constructor
|access=string  <- "public" or "protected"
|static=true|default blank
|virtual=true|default blank
|args=Template:Arg, ...  <- Comma separated list of Template:Arg. Actually separated by ", " (comma and a space).
|summary=string|default blank

Template:Arg
|name=string
|type=Template:Type
|defaultValue=string|default blank  <- The default value for this argument, i.e. this is an optional argument.
|ref=ref|out|default blank  <- If this argument is a "ref" or "out" argument, or blank for neither.

Template:Type
|name=string  <- The actual identifier for the type. List<Dictionary<Blah, Blah>> has the name List.
                 This, and nothing else, is linked to other pages via API:{name}.
|array=true|default blank  <- If set true, end type with [].
|generic=Template:Generic|default blank  <- If blank, this type is simple. If not, this type uses a
                                            generics template e.g. List<int> would have Template:Generic(Template:Type(int)).

Template:Generics
|types=Template:Type,...  <- All the types that this generic template has, comma separated.