2011-06-19 17:58:15 +02:00
# LDoc - A Lua Documentation Tool
2020-09-30 19:27:48 +02:00
[![Luacheck ](https://github.com/lunarmodules/LDoc/workflows/Luacheck/badge.svg )](https://github.com/lunarmodules/LDoc/actions)
2012-12-29 10:59:30 +01:00
Copyright (C) 2011-2012 Steve Donovan.
2011-06-19 17:58:15 +02:00
## Rationale
2012-12-29 10:59:30 +01:00
This project grew out of the documentation needs of
2020-09-29 23:23:17 +02:00
[Penlight ](https://github.com/lunarmodules/Penlight ) (and not always getting satisfaction
2020-09-29 21:33:29 +02:00
with LuaDoc) and depends on Penlight itself. (This allowed me to _not_ write a lot of code.)
2011-06-19 17:58:15 +02:00
2020-09-29 23:23:17 +02:00
The [API documentation ](http://lunarmodules.github.com/Penlight/api/index.html ) of Penlight
2012-12-29 10:59:30 +01:00
is an example of a project using plain LuaDoc markup processed using LDoc.
2011-06-19 17:58:15 +02:00
2014-01-15 15:16:58 +01:00
LDoc is intended to be compatible with [LuaDoc ](http://keplerproject.github.io/luadoc/ ) and
2012-12-29 10:59:30 +01:00
thus follows the pattern set by the various *Doc tools:
2011-06-19 17:58:15 +02:00
--- Summary ends with a period.
-- Some description, can be over several lines.
-- @param p1 first parameter
-- @param p2 second parameter
-- @return a string value
-- @see second_fun
function mod1.first_fun(p1,p2)
end
2012-12-29 10:59:30 +01:00
Tags such as `see` and `usage` are supported, and generally the names of functions and
modules can be inferred from the code.
2011-06-19 17:58:15 +02:00
2012-12-29 10:59:30 +01:00
LDoc is designed to give better diagnostics: if a `@see` reference cannot be found, then the
line number of the reference is given. LDoc knows about modules which do not use `module()`
- this is important since this function has become deprecated in Lua 5.2. And you can avoid
having to embed HTML in commments by using Markdown.
2011-06-19 17:58:15 +02:00
LDoc will also work with Lua C extension code, and provides some convenient shortcuts.
2012-12-29 10:59:30 +01:00
An example showing the support for named sections and 'classes' is the [Winapi
documentation](http://stevedonovan.github.com/winapi/api.html); this is generated from
[winapi.l.c ](https://github.com/stevedonovan/winapi/blob/master/winapi.l.c ).
2011-06-19 17:58:15 +02:00
## Installation
2012-12-29 10:59:30 +01:00
This is straightforward; the only external dependency is
2020-09-29 23:23:17 +02:00
[Penlight ](https://github.com/lunarmodules/Penlight ), which in turn needs
2012-12-29 10:59:30 +01:00
[LuaFileSystem ](http://keplerproject.github.com/luafilesystem/ ). These are already present
2018-07-23 20:50:20 +02:00
in [Lua for Windows ](https://github.com/rjpcomputing/luaforwindows ), and Penlight is also available through [LuaRocks ](https://luarocks.org/ ) as `luarocks install
2012-12-29 10:59:30 +01:00
penlight`.
2011-06-19 17:58:15 +02:00
2012-12-29 10:59:30 +01:00
Unpack the sources somewhere and make an alias to `ldoc.lua` on your path. That is, either
2020-09-29 21:33:29 +02:00
an executable script called 'ldoc' like so:
2011-06-19 17:58:15 +02:00
lua /path/to/ldoc/ldoc.lua $*
Or a batch file called 'ldoc.bat':
@echo off
lua \path\to\ldoc\ldoc.lua %*