Renderers

Renderers can be viewed as a map with the following keys:

Table 2. Renderer properties

KeyTypeDescription
namexs:stringUsed to identify the renderer
descriptionxs:stringAbout the renderer
typexs:string"xqdoca:global" or "xqdoca:module"
urixs:stringThe name of the output it creates
outputxs:stringSerialization parameters for the output
functionfunction(*)The function that implements the rendering


The listing below shows some example renderers:

map {
  "output": "html5",
  "name": "index",
  "uri": "index.html",
  "function": Q{quodatum:build.xqdoc-html}index-html2#2,
  "type": Q{https://github.com/Quodatum/xqdoca}global,
  "description": "Index of sources"
}

map {
  "output": "json",
  "name": "swagger1",
  "uri": "swagger.json",
  "function": Q{quodatum:xqdoca.generator.swagger}swagger#2,
  "type": Q{https://github.com/Quodatum/xqdoca}global,
  "description": "Swagger file (JSON format) from restxq annotations."
}

map {
  "output": "xml",
  "name": "xqparse",
  "uri": "xqparse.xml",
  "function": Q{quodatum:xqdoca.mod-html}xqparse#3,
  "type": Q{https://github.com/Quodatum/xqdoca}module,
  "description": "xqparse file for the source module"
}

All outputs are created below the target folder specified in the $options map. For module style outputs, numbered sub-folders are created for each source module and the uri value is resolved relative to this folder.

Functions annotated as global renderers need to have arity=2 and signature ($model as map(*), $opts as map(*)).

Functions annotated as module renderers need to have arity=3 and signature ($file as map(*), $opts as map(*), $model as map(*)).