Author: Wizard
Created: June 19th, 2021
Version: 0.0.1
Description:
Convert lua comments (--) into markdown format, and document functions with (---)
following the LuaDoc format.
from double lua comment:
-- ## Header
-- hello world
into markdown:
hello world
from tripple lua comment for function documentation
--- the start of documentation, also start of the description.
-- you can add multiple lines to the start of the description,
-- there is no limit.
-- @param exam1 #string <*> [example description]
-- @param exam2 #table [example description]
-- @return exam3 #table
-- @usage
-- local exam = example("exam1", {[1] = "hello"})
local function example(exam1, exam2) ... end
into markdown:
the start of documentation, also start of the description.
you can add multiple lines to the start of the description,
there is no limit.
Param | Type | Required | Description |
---|---|---|---|
exam1 | string | yes | example description |
exam2 | table | example description |
Return | Type |
---|---|
exam3 | table |
Usage:
local exam = example("exam1", {[1] = "hello"})
Get the lines from a file
Parameter | Type | Required | Description |
---|---|---|---|
path | string | ✓ | the path to the file |
Return | Type |
---|---|
lines | array |
Get the description from a function
recursiverly goes through lines until there is no more comments.
also returns a second variable that is the current index.
Parameter | Type | Required | Description |
---|---|---|---|
lines | array | ✓ | the array of lines |
index | number | ✓ | the current line index |
Return | Type |
---|---|
description | array |
index | number |
Get the parameters from a function
recursively goes through lines and collects comments underneath params.
also returns a second variable that is the current index.
Parameter | Type | Required | Description |
---|---|---|---|
lines | array | ✓ | the array of lines |
index | number | ✓ | the current line index |
Return | Type |
---|---|
params | array |
index | number |
Get the returns from a function
Parameter | Type | Required | Description |
---|---|---|---|
lines | array | ✓ | the array of lines |
index | number | ✓ | the current line index |
Return | Type |
---|---|
returns | array |
index | number |
Get the usage examples from a function
Parameter | Type | Required | Description |
---|---|---|---|
lines | array | ✓ | the array of lines |
index | number | ✓ | the current line index |
Return | Type |
---|---|
usage | array |
index | number |
Get the function sytax
Parameter | Type | Required | Description |
---|---|---|---|
lines | array | ✓ | the array of lines |
index | number | ✓ | the current line index |
Return | Type |
---|---|
syntax | string |
index | number |
Get a tripple comment block
Parameter | Type | Required | Description |
---|---|---|---|
lines | array | ✓ | the array of lines |
index | number | ✓ | the current line index |
Return | Type |
---|---|
block | string |
index | number |
Write the header which is a functions syntax.
Parameter | Type | Required | Description |
---|---|---|---|
file | file | ✓ | the file to be written to |
header | string | ✓ | the header to write |
Return | Type |
---|---|
none |
Write the description for a function
Parameter | Type | Required | Description |
---|---|---|---|
file | file | ✓ | the file to be written to |
description | table | ✓ | the description to write |
Return | Type |
---|---|
none |
Write the parameters for a function
Parameter | Type | Required | Description |
---|---|---|---|
file | file | ✓ | the file to be written to |
params | table | ✓ | the params to write |
Return | Type |
---|---|
none |
Write the returns for a function
Parameter | Type | Required | Description |
---|---|---|---|
file | file | ✓ | the file to be written to |
returns | table | ✓ | the returns to write |
Return | Type |
---|---|
none |
Write the usage examples for a function
Parameter | Type | Required | Description |
---|---|---|---|
file | file | ✓ | the file to be written to |
usage | table | ✓ | the returns to usage |
Return | Type |
---|---|
none |
Write a tripple comment block
Parameter | Type | Required | Description |
---|---|---|---|
file | file | ✓ | the file to be written to |
block | table | ✓ | the block table to write out |
Return | Type |
---|---|
none |
Recursively goes through the lines and writes double comments and extracts information from tripple comment blocks.