Export Documentation
The language server can export documentation for your project in Markdown and JSON formats.
Markdown
md
# Array ## concat ```Lua (method) Array:concat(array: Array) -> Object: Array ``` Append an array to the end of this one, combining them @_param_ `array` — The array to append to the end of this one ## every ```Lua (method) Array:every(test: fun(index: integer, value: any, array: Array):boolean) -> passed: boolean ``` Returns `true` if every element in this array passes the testing function @_return_ `passed` — If all elements passed the testing function ## fill ```Lua (method) Array:fill(value: any, start: integer, stop?: integer) -> Object: Array ``` Fills the array with a `value` from `start` to `stop` @_param_ `value` — The value to fill the array with @_param_ `start` — The index to start filling at @_param_ `stop` — The index to stop filling at ...
JSON
JSON
[ { "defines": [ { "file": "file:///c%3A/Users/Me/Documents/Array.lua", "finish": 10015, "start": 10010, "type": "doc.class" } ], "fields": [ { "extends": { "finish": 140021, "start": 140016, "type": "getlocal", "view": "Array" }, "file": "file:///c%3A/Users/Me/Documents/Array.lua", "finish": 140013, "name": "__index", "start": 140000, "type": "setfield" }, { "extends": { "finish": 20030, "start": 20025, "type": "doc.type", "types": [ { "finish": 20030, "start": 20025, "type": "doc.type.array", "view": "any[]" } ], "view": "any[]" }, "file": "file:///c%3A/Users/Me/Documents/Array.lua", "finish": 20030, "name": "_items", "start": 20010, "type": "doc.field" }, { "desc": "Append an array to the end of this one, combining them\n\n@*param* `array` — The array to append to the end of this one", "extends": { "args": [ { "finish": 520008, "name": "self", "start": 520008, "type": "self", "view": "Array" }, { "desc": "The array to append to the end of this one", "finish": 520027, "name": "array", "start": 520022, "type": "local", "view": "Array" } ], "desc": "Append an array to the end of this one, combining them\n\n@*param* `array` — The array to append to the end of this one", "finish": 610003, "returns": [ { "name": "Object", "type": "function.return", "view": "Array" } ], "start": 520000, "type": "function", "view": "(method) Array:concat(array: Array)\n -> Object: Array" }, "file": "file:///c%3A/Users/Me/Documents/Array.lua", "finish": 520021, "name": "concat", "start": 520009, "type": "setmethod" }, { "desc": "Returns `true` if every element in this array passes the testing function\n\n@*return* `passed` — If all elements passed the testing function", "extends": { "args": [ { "finish": 790008, "name": "self", "start": 790008, "type": "self", "view": "Array" }, { "finish": 790025, "name": "test", "start": 790021, "type": "local", "view": "fun(index: integer, value: any, array: Array):boolean" } ], "desc": "Returns `true` if every element in this array passes the testing function\n\n@*return* `passed` — If all elements passed the testing function", "finish": 880003, "returns": [ { "desc": "If all elements passed the testing function", "name": "passed", "type": "function.return", "view": "boolean" } ], "start": 790000, "type": "function", "view": "(method) Array:every(test: fun(index: integer, value: any, array: Array):boolean)\n -> passed: boolean" }, "file": "file:///c%3A/Users/Me/Documents/Array.lua", "finish": 790020, "name": "every", "start": 790009, "type": "setmethod" }, { "desc": "Fills the array with a `value` from `start` to `stop`\n\n@*param* `value` — The value to fill the array with\n\n@*param* `start` — The index to start filling at\n\n@*param* `stop` — The index to stop filling at", "extends": { "args": [ { "finish": 950008, "name": "self", "start": 950008, "type": "self", "view": "Array" }, { "desc": "The value to fill the array with", "finish": 950025, "name": "value", "start": 950020, "type": "local", "view": "any" }, { "desc": "The index to start filling at", "finish": 950032, "name": "start", "start": 950027, "type": "local", "view": "integer" }, { "desc": "The index to stop filling at", "finish": 950038, "name": "stop", "start": 950034, "type": "local", "view": "integer?" } ], "desc": "Fills the array with a `value` from `start` to `stop`\n\n@*param* `value` — The value to fill the array with\n\n@*param* `start` — The index to start filling at\n\n@*param* `stop` — The index to stop filling at", "finish": 1090003, "returns": [ { "name": "Object", "type": "function.return", "view": "Array" } ], "start": 950000, "type": "function", "view": "(method) Array:fill(value: any, start: integer, stop?: integer)\n -> Object: Array" }, "file": "file:///c%3A/Users/Me/Documents/Array.lua", "finish": 950019, "name": "fill", "start": 950009, "type": "setmethod" } ], "name": "Array", "type": "type" } ]
By specifying Lua.docScriptPath
setting, you could override the default documentation generation behavior. When set, the server uses this script (instead of the built-in one ) to generate LuaDocs, allowing customization of filtering, sorting, and formatting rules. Leave empty to use the default script. Requires the custom script to implement specific APIs for compatibility.
API
Lua
export.getLocalPath(uri) -- Called when the documentation needs to get the path of a source relative to the DOC path. Returns the relative path, or the absolute path, prefixed with the string '[FOREIGN]' export.positionOf(rowcol) -- Wrapper for guide.positionOf(rowcol[1], rowcol[2]) export.sortDoc(a,b) -- A comparison function used by table.sort that is used to sort every piece of documentation in alphabetical order. export.documentObject(source, has_seen) -- A function that gets called on every source object. It is responsible for filtering each source to their corresponding export.makeDocObject[<TYPE>] function export.makeDocObject[<TYPE>] -- A table of functions that are responsible for building their corresponding <TYPE>'s documentation. TYPES include 'type', 'variable', 'doc.class', etc. 'INIT' corresponds to every documentation object before it is processed by its corresponding type. export.gatherGlobals() -- Called when the documentation needs an exhaustive list of the globals it should export documentation. By default this includes the result of vm.getAllGlobals(). Returns the collected variables/types. export.makeDocs(globals, callback) -- Documents globals from export.gatherGlobals() by calling export.documentObject on each one; updates its progress by calling callback when a global is finished being documented. Returns a table of the collected documentation export.serializeAndExport(docs, outputDir) -- Serializes documentation tables from export.makeDocs to json and markdown, Writes them to <outputDir>/doc.json and <outputDir>/doc.md, respectively. Returns these paths.