分享好友 编程语言首页 频道列表

Lua Doc生成工具

Lua  2023-02-07 18:430

http://keplerproject.github.io/luadoc/

Overview

LuaDoc is a documentation generator tool for Lua source code. It parses the declarations and documentation comments in a set of Lua source files and produces a set of XHTML pages describing the commented declarations and functions.

The output is not limited to XHTML. Other formats can be generated by implementing new doclets. The format of the documentation comments is also flexible and can be customized by implementing new taglets. Please refer to customizing section for further information.

LuaDoc is free software and uses the same license as Lua.

 

LDoc

https://github.com/stevedonovan/LDoc

A LuaDoc-compatible documentation generation system http://stevedonovan.github.com/ldoc/

 

Rationale

This project grew out of the documentation needs of Penlight (and not always getting satisfaction with LuaDoc) and depends on Penlight itself.(This allowed me to not write a lot of code.)

The API documentation of Penlight is an example of a project using plain LuaDoc markup processed using LDoc.

LDoc is intended to be compatible with LuaDoc and thus follows the pattern set by the various *Doc tools:

--- 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

Tags such as see and usage are supported, and generally the names of functions and modules can be inferred from the code.

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.

LDoc will also work with Lua C extension code, and provides some convenient shortcuts.

An example showing the support for named sections and 'classes' is the Winapi documentation; this is generated from winapi.l.c.

 

LDoc API & Help

http://stevedonovan.github.io/ldoc/manual/doc.md.html#Basic_Usage

 

LDoc, a Lua Documentation Tool

Introduction

LDoc is a software documentation tool which automatically generates API documentation out of source code comments (doc comments). It is mainly targeted at Lua and documenting Lua APIs, but it can also parse C with according doc comments for documenting Lua modules implemented in C.

It is mostly compatible with LuaDoc, except that certain workarounds are no longer needed. For instance, it is not so married to the idea that Lua modules should be defined using the module function; this is not only a matter of taste since this has been deprecated in Lua 5.2.

Otherwise, the output is very similar, which is no accident since the HTML templates are based directly on LuaDoc. You can ship your own customized templates and style sheets with your own project (also see Graham Hannington’s documentation for Lua for z/OS). LDoc comes with three extra themes; ‘pale’ for those who like whitespace, ‘one’ for one-column output, and ‘fixed’ for a fixed navigation bar down the left side.

You have an option to use Markdown to process the documentation, which means no ugly HTML is needed in doc comments. C/C++ extension modules may be documented in a similar way, although function names cannot be inferred from the code itself.

LDoc can provide integrated documentation, with traditional function comments, any documents in Markdown format, and specified source examples. Lua source in examples and the documents will be prettified.

Although there are a fair number of command-line options, the preferred route is to write a config.ld configuration file in Lua format. By convention, if LDoc is simply invoked as ldoc . it will read this file first. In this way, the aim is to make it very easy for end-users to build your documentation using this simple command.

 

------------

Here are all the tags known to LDoc:

  • @module A Lua module containing functions and tables, which may be inside sections
  • @classmod Like @module but describing a class
  • @submodule A file containing definitions that you wish to put into the named master module
  • @script A Lua program
  • @author (multiple), copyright, @license, @release only used for project-level tags like @module
  • @function, @lfunction. Functions inside a module
  • @param formal arguments of a function (multiple)
  • @return returned values of a function (multiple)
  • @raise unhandled error thrown by this function
  • @local explicitly marks a function as not being exported (unless --all)
  • @see reference other documented items
  • @usage give an example of a function’s use. (Has a somewhat different meaning when used with @module)
  • @table a Lua table
  • @field a named member of a table
  • @section starting a named section for grouping functions or tables together
  • @type a section which describes a class
  • @within puts the function or table into an implicit section
  • @fixme, @todo and @warning are annotations, which are doc comments that occur inside a function body.

http://stevedonovan.github.io/ldoc/manual/doc.md.html#Basic_Usage

Fields allowed in config.ld

Same meaning as the corresponding parameters:

  • file a file or directory containing sources. In config.ld this can also be a table of files and directories.
  • project name of project, used as title in top left
  • title page title, default ‘Reference’
  • package explicit base package name; also used for resolving references in documents
  • all show local functions, etc as well in the docs
  • format markup processor, can be ‘plain’ (default), ‘markdown’ or ‘discount’
  • output output name (default ‘index’)
  • dir directory for output files (default ‘doc’)
  • colon use colon style, instead of @ tag style
  • boilerplate ignore first comment in all source files (e.g. license comments)
  • ext extension for output (default ‘html’)
  • one use a one-column layout
  • style, template: together these specify the directories for the style and and the template. In config.ld they may also be true, meaning use the same directory as the configuration file.
  • merge allow documentation from different files to be merged into modules without explicit @submodule tag

_These only appear in the configuration file:_

  • description a short project description used under the project title
  • full_description when you really need a longer project description
  • examples a directory or file: can be a table
  • readme or topics readme files (to be processed with Markdown)
  • pretty code prettify ‘lua’ (default) or ‘lxsh’
  • prettify_files prettify the source as well and make links to it; if its value is “show” then also index the source files.
  • charset use if you want to override the UTF-8 default (also @charset in files)
  • sort set if you want all items in alphabetical order
  • no_return_or_parms don’t show parameters or return values in output
  • no_lua_ref stop obsessively trying to create references to standard Lua libraries
  • backtick_references whether references in backticks will be resolved. Happens by default when using Markdown. When explicit will expand non-references in backticks into <code> elements
  • plain set to true if format is set but you don’t want code comments processed
  • wrap set to true if you want to allow long names to wrap in the summaries
  • manual_url point to an alternative or local location for the Lua manual, e.g. ‘file:///D:/dev/lua/projects/lua-5.1.4/doc/manual.html’
  • no_summary suppress the Contents summary
  • custom_tags define some new tags, which will be presented after the function description. The format is {<name>,[title=<name>,}{hidden=false,}{format=nil}}. For instance custom_tags={'remark',title='Remarks'} will add a little Remarks section to the docs for any function containing this tag. format can be a function – if not present the default formatter will be used, e.g. Markdown
  • custom_see_handler function that filters see-references
  • custom_display_name_handler function that formats an item’s name. The arguments are the item and the default function used to format the name. For example, to show an icon or label beside any function tagged with a certain tag:

 

LDoc demo

http://stevedonovan.github.io/ldoc/examples/mylib.c.html

/// A sample C extension.
// Demonstrates using ldoc's C/C++ support. Can either use /// or /*** */ etc.
// @module mylib
#include <string.h>
#include <math.h>

// includes for Lua
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

/***
Create a table with given array and hash slots.
@function createtable
@param narr initial array slots, default 0
@param nrec initial hash slots, default 0
*/
static int l_createtable (lua_State *L) {
  int narr = luaL_optint(L,1,0);
  int nrec = luaL_optint(L,2,0);
  lua_createtable(L,narr,nrec);
  return 1;
}

 

-------------

------
-- Various ways of indicating errors
-- @module multiple

-----
-- function with return groups.
-- @treturn[1] string result
-- @return[2]  nil
-- @return[2] error message
function mul1 () end

 

LDoc 依赖 PenLight 库

https://github.com/stevedonovan/Penlight

Penlight brings together a set of generally useful pure Lua modules, focusing on input data handling (such as reading configuration files), functional programming (such as map, reduce, placeholder expressions, etc), and OS path management. Much of the functionality is inspired by the Python standard libraries.

 

Paths, Files and Directories

  • path: queries like isdir,isfile,exists, splitting paths like dirname and basename
  • dir: listing files in directories (getfiles,getallfiles) and creating/removing directory paths
  • file: copy,move; read/write contents with read and write

Application Support

  • app: require_here to rebase require to work with main script path; simple argument parsing parse_args
  • lapp: sophisticated usage-text-driven argument parsing for applications
  • config: flexibly read Unix config files and Windows INI files
  • strict: check for undefined global variables - can use strict.module for modules
  • utils,compat: Penlight support for unified Lua 5.1/5.2 codebases
  • types: predicates like is_callable and is_integer; extended type function.

Extra String Operations

  • utils: can split a string with a delimiter using utils.split
  • stringx: extended string functions covering the Python string type
  • stringio: open strings for reading, and creating strings using standard Lua IO methods
  • lexer: lexical scanner for splitting text into tokens; special cases for Lua and C
  • text: indenting and dedenting text, wrapping paragraphs; optionally make % work as in Python
  • template: small but powerful template expansion engine
  • sip: Simple Input Patterns - higher-level string patterns for parsing text

Extra Table Operations

  • tablex: copying, comparing and mapping over
  • pretty: pretty-printing Lua tables, and various safe ways to load Lua as data
  • List: implementation of Python 'list' type - slices, concatenation and partitioning
  • Map, Set, OrderedMap: classes for specialized kinds of tables
  • data: reading tabular data into 2D arrays and efficient queries
  • array2d: operations on 2D arrays
  • permute: generate permutations

Iterators, OOP and Functional

  • seq: working with iterator pipelines; collecting iterators as tables
  • class: a simple reusable class framework
  • func: symbolic manipulation of expressions and lambda expressions
  • utils: utils.string_lambda converts short strings like '|x| x^2' into functions
  • comprehension: list comprehensions: C'x for x=1,4'()=={1,2,3,4}

 

参考BLOG

http://blog.justbilt.com/2015/08/23/ldoc/

http://www.dpull.com/blog/2016-02-03-ldoc

 

其它

http://www.cs.scranton.edu/~doc/cppdoc/

CDOC没有找到。

https://en.wikipedia.org/wiki/Comparison_of_documentation_generators

http://jessevdk.github.io/cldoc/

 

查看更多关于【Lua】的文章

展开全文
相关推荐
反对 0
举报 0
评论 0
图文资讯
热门推荐
优选好物
更多热点专题
更多推荐文章
LUA解析json小demo
需要修改的json数据gui-config.json{"configs": [{"server": "JP3.ISS.TF","server_port": 443,"password": "58603228","method": "aes-256-cfb","remarks": ""},{"serv

0评论2023-03-16958

第二十三篇:在SOUI中使用LUA脚本开发界面
像写网页一样做客户端界面可能是很多客户端开发的理想。做好一个可以实现和用户交互的动态网页应该包含两个部分:使用html做网页的布局,使用脚本如vbscript,javascript做用户交互的逻辑。当需求变化时,只需要在服务端把相关代码调整一下,用户即可看到新的

0评论2023-03-16307

windows下编译lua源码"><转>windows下编译lua源码
因为之前一直使用 lua for windows 来搭建lua的使用环境,但是最新的 lua for windows 还没有lua5.2,我又想用这个版本的lua,所以被逼无奈只能自己编一下lua源码。首先从 lua的官网 下载你想要使用的lua源码,比如我下载的就是lua5.2。解压后内容如下:

0评论2023-03-16723

lua:使用Lua处理游戏数据
在之前lua学习:lua作配置文件里,我们学会了用lua作配置文件。其实lua在游戏开发中可以作为一个强大的保存、载入游戏数据的工具。 比如说,现在我有一份表单:data.xls用什么工具解析这个Excel文件并将数据载入游戏?我们可以使用Lua来完成这个工作。不过要

0评论2023-03-16955

cocos2d-lua 控制台输入Lua指令方便调试
用脚本进行开发,如果不能实时去输入指令,就丧失了脚本的一大特色,所以对cocos2d-x程序稍微修改下,使其可以直接从控制台读入lua指令,方便调试。1 首先在行首加入lua的引用,如下1 #include "main.h"2 #include "AppDelegate.h"3 #include "cocos2d.h"4 #i

0评论2023-02-09995

lua_touserdata
void *lua_touserdata(lua_State*L,intindex);如果给定索引处的值是一个完整的userdata,函数返回内存块的地址。如果值是一个lightuserdata,那么就返回它表示的指针。否则,返回NULL。例如: 在CCLuaStack::executeFunction()函数中有一段代码是用来获取c++

0评论2023-02-09613

Lua 5.2 中文参考手册
闲来无事,发现Lua更新到了5.2.2,参考手册也更到了5.2,在网上发现只有云风翻译的5.1版,花了几天时间翻译了一些。参考手册有点长,又要随时修改,所以在github上建了项目,有需要的朋友可以看看,同时也欢迎指正。中文手册:Lua 5.2中文参考手册

0评论2023-02-09578

lua报错,看到报错信息有tail call,以为和尾调用有关,于是查了一下相关知识
  尾调用是指在函数return时直接将被调函数的返回值作为调用函数的返回值返回,尾调用在很多语言中都可以被编译器优化, 基本都是直接复用旧的执行栈, 不用再创建新的栈帧, 原理上其实也很简单, 因为尾调用在本质上看的话,是整个子过程调用的最后执行语句,

0评论2023-02-09333

lua 实现tableToString
function tableToString(studentNum) local str ="{ " str = str.."\n" for k, v in pairs(studentNum) doif type(v) ~= "table" thenstr = str.."[\""..k.."\"]"str = str..":"str = str..vstr = st

0评论2023-02-09824

Lua类对象和类对象的单例 lua实例
1、Lua的类对象local myClass = {}function myClass:new()local self = {}setmetatable(self,{__index = myClass})endlocal a = 0local b = 0local c = 0return myClass以上类的对象实例化的调用:require "myClass"local _myClass = myClass:new()实例化后 _

0评论2023-02-09653

浅析一个lua文件窥slua工作机制 lua 调用so
slua的东西不是几句话能讲得完,这里只说结论不说原因,原因有空写个Little Slua工程来解释,下面注释中有几个关键点:LuaVar系列类:LuaFunction,LuaTable,LuaDelegate的使用,类型表和实例表,__parent代表继承关系,存ud的表是弱表(可以用来缓存c#中引用

0评论2023-02-09602

lua学习笔记10:lua简单的命令行 lua怎么执行
前面反复使用的命令行,好学喜欢命令行:一 格公式lua [options][script][args]两 详细命令-e 直接命令传递一个lua-l 加载文件-i 进入交互模式比例如。端子输入:lua -e "print(math.sin(12))" 版权声明:本文博主原创文章,博客,未经同意不得转载。

0评论2023-02-09533

Lua中强大的元方法__index详解 lua元表和元方法
今天要来介绍比较好玩的内容——__index元方法1.我是备胎,记得回头看看咳咳,相信每一位女生都拥有或者不知不觉中拥有了一些备胎,啊,当然,又或许是成为过别人的备胎。没有备胎的人,就不是完整的人生。(小若:停!) 我们来想象一下,如果对一个table进

0评论2023-02-09494

Lua调试工具使用及原理 lua运行原理
前言当我们在linux下使用c/c++开发时,可以通过gdb来调试我们编译后的elf文件。gdb支持了attch、单步运行(单行、单指令)、设置断点等非常实用的功能来辅助我们调试。当使用lua开发的时候,一般可能会使用print(打印到屏幕)或是输出日志等稍微简陋的调试方

0评论2023-02-09999

(转)lua protobuffer的实现
转自: http://www.voidcn.com/article/p-vmuovdgn-bam.html (1)lua实现protobuf的简介需要读者对google的protobuf有一定的了解。Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but s

0评论2023-02-09818

lua require路径设置实例
1.首先要强调的是,lua require的路径用的是斜杠"/",而不是从Windows文件属性那里复制来的反斜杠"\"。2.通过 print(pagckage.path) 和print(package.cpath)打印lua系统封装的两个全局属性可以看到当前lua解析器require的时候默认替换的路径3.更改路径的时候

0评论2023-02-09855

更多推荐