# Class: AutoDoc

### LuxModule: luxinialuacore

The AutoDoc system creates documentation files from the information provided from Luxinia and the modulekernel. The AutoDoc class provides a system that can be extended to create help files that fits your use.

For creating your own documentation, you have to set up a template table. This table may contain string, tables and functions.

## Methods:

### Method overview:

- createDoc
- templateFunctions
- templateFunctions.descriptor
- templateFunctions.hierarchylist
- templatePages
- templatePages.moduleHtmlDoc
- templates.apiSingleHtmlDoc
- templates.templatePages.apiDocIndex
- templates.templatePages.apiHTMLFrameDoc
- writeDoc

createDoc (table template)
  returns: (string doc, table struct)

  Creates a string from a table that was passed that acts as a template. The table may contain functions, tables and strings.

  The table is converted to a string that represents the final document. The table is therefore iterated from 1 to n, where n is the number of number-indexed values in the table. That means that you can use any kind of keys for storing additional information that you need during the process. In each iteration,

  - Strings are written to the output directly
  - Table values are passed as argument to a recursive function call on createDoc
  - Functions will be called with the table itself, the api hierarchy, the list of modules and a table containing all classes with their names as keys. The function may return itself a table (which is resolved as in the point above) or a string.
  The template may contain strings that are formated like "%file=abc%". The string "abc" is then used as a key in the table that is additionally returned. Per default, all output is saved to the key "main" in the table, as long as no such instruction is used. You can use the created table with all the outputstrings to write it to a file or another structure.
templateFunctions
  [table] - contains a number of default functions that can be used within template pages.
templateFunctions.descriptor (string classfmt, interfacefmt,childfmt,functionfmt,modulefmt)
  returns: (function)
  returns a function that can be used in the template system.
  - classfmt: the strings $classname,$classparent, $classdescription, $interfacelist, $childlist, $functionlist in the classfmt string will be replaced by the actual meaning
  - interfacefmt: $interfacename
  - childfmt: function (class, depth): function that should return a string
  - functionfmt: function (fname,description,cleandesc)
templateFunctions.hierarchylist (string format, string sublistfmt, [boolean api])
  returns: (function)

  returns a function that returns a string of a hierarchical listing of all class in a list form. If api is true, the apihierarchy is used, if its false or not used, the modulehierarchy is used.

  The passed string is used for each element in the list, the sublistfmt is used for childs in the hierarchy.
  - $name is replaced by the name of the element or (in the sublistfmt) with the childlist of the element.
  - $ifinterface=xyz$; will show xyz if the class is an interface class
  - $list will insert the sublist in the sublistfmt
templatePages
  [table] - contains a number of default templates for creating documentation pages
templatePages.moduleHtmlDoc
  [table] - Template table for creating the HTML API of the modules.
templates.apiSingleHtmlDoc
  [table] - Template table for creating the HTML API of all native Luxinia classes.
templates.templatePages.apiDocIndex
  [table] - API documentation in a single file.
templates.templatePages.apiHTMLFrameDoc
  [table] - Documentation of api and module pages as frames.
writeDoc (path, table template)
  returns: ()

  similiar to createDoc, except that the output is written to files in a given output directory.