-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlunardoc.lua
More file actions
47 lines (41 loc) · 1.92 KB
/
lunardoc.lua
File metadata and controls
47 lines (41 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
local lunardoc = require('lunardoc.index')
local tokenizer = require('lunardoc.libraries.tokenizer').lua
local json = require('lunardoc.libraries.json')
local lapp = require('pl.lapp')
local file = require('pl.file')
local args = lapp [[
Lunadoc - A Lua documentation generator for Lua.
Available options
--all Include local items in documentation.
--boilerplate Removal of boilerplate / license block comments.
--box Include infobox in output.
--caption Infobox image caption.
--card (default true) Include endmatter card in the output at the end of the documentation.
--code Only document Lunardoc code items while excluding article infobox and lede.
--colon Format tags with a : suffix and without the @ prefix.
--footer (default true) Append a horizontal line & 'generated by Lunardoc' to the bottom of the output.
--image Infobox image.
--noluaref Don't link to the Lua reference manual for types.
--plain Disable Markdown formatting in documentation.
--preface Preface text to insert between lede & item documentation, used to provide usage and code examples.
--simple Limit documentation to descriptions only.
--sort Sort documentation items in alphabetical order.
--strip Remove table index in documentation.
--verbose Show the code description of a package function when documenting function modules.
--ulist Indent subitems as <ul> lists - LDoc/JSDoc behaviour.
<method> (string) Command word - either 'dump' or 'generate'.
<file> (string) Path to the Lua module being documented.
]]
if args.method == 'parse' then
local taglet = lunardoc.taglet(args.file, args)
print(json.encode(taglet, { indent = ' ' }))
end
if args.method == 'serialise' then
local documentation = lunardoc.build(args.file, args)
print(documentation)
end
if args.method == 'tokenize' then
local contents = file.read(args.file)
local tokens = tokenizer(contents)
print(json.encode(tokens, { indent = ' ' }))
end