LDoc使用总结
LDoc使用总结
安装
按照下面的安装就可以了
http://www.cnblogs.com/ZhYQ-Note/articles/6022525.html
使用
参考:官方的说明文档
https://stevedonovan.github.io/ldoc/manual/doc.md.html
修改
问题
在模块中生成函数列表时,如我下面这样定义:
--[[--
color 颜色处理
@module color
]]
local color = {}
---整形转cc.c3b类型
-- @function intToc3b
-- @param int intValue
-- @return cc.c3b
function color.intToc3b(intValue)
local hexStr = string.format("%06X", intValue)
return color.hexToc3b(hexStr)
end
---整形转cc.c3b类型
-- @function color.intToHex
-- @param int intValue
-- @return "aabbcc"
color.intToHex = function (intValue)
return string.format("%06X", intValue)
end
最后生成的函数列表会去掉模块名,生成的函数名是intToc3b 和 intToHex,但是我想生成的
函数名字是根据-- @function intToc3b 这这里写的,我写成color.intToHex 就生成这样的
就行了,而不是主动给我去掉color 前缀,只剩下intToHex,这样就不能很好的区分调用方式是
color:intToHex 还是 color.intToHex
解决
出线上面的问题,我就想自己查看下ldoc的源码,看看能不能自己修改下,毕竟源码是lua写的,也是抱着试试看的感觉,分析了下ldoc的源码,找到了一个地方:
在doc.lua文件中
-- 看注释应该是获取模块中的函数名mod.foo
-- new-style modules will have qualified names like 'mod.foo'
if item.name == nil then
self:error("item's name is nil")
end
--分开模块名和函数名
local mod,fname = split_dotted_name(item.name)
-- warning for inferred unqualified names in new style modules
-- (retired until we handle methods like Set:unset() properly)
if not mod and not this_mod.old_style and item.inferred then
--item:warning(item.name .. ' is declared in global scope')
end
-- the function may be qualified with a module alias...
local alias = this_mod.tags.alias
if (alias and mod == alias) or mod == 'M' or mod == '_M' then
mod = this_mod.mod_name
end
--- 这里是关键,这里做了一个判断,意思是只保留foo即函数名,去掉模块名,
--- 所以我这里直接这两行去掉,保留为模块名.函数名的形式,如mod.foo
--- 这样我们生成的文档应该就可以了
-- if that's the mod_name, then we want to only use 'foo'
-- if mod == this_mod.mod_name and this_mod.tags.pragma ~= 'nostrip' then
-- item.name = fname
-- end
注意
因为我的ldoc是通过luarocks安装的,那必须找到luarocks把安装的工具源码放到那里了,才能够修改源码,并且实验是否方案可行,在官网上找到了
https://github.com/keplerproject/luarocks/wiki/File-locations#Path_to_Lua_binaries_and_associated_data,这个网页上说明了luarocks的
所有相关路径,最终在:
LuaRocks command-line tools are configured during installation to be able to find those files.
Unix default: /usr/local/share/lua/5.x/
我的:/usr/local/share/lua/5.1 目录下的文件:
ldoc(需要修改的地方) luarocks markdown.lua pl
LDoc使用总结的更多相关文章
- 使用Ldoc给Lua生成文档
Ldoc介绍 LDoc是一个Lua的文档生成工具,过去,比较常用的Lua生成文档的工具是LuaDoc,可惜作者自从2008年之后就再也没有发布过新的版本了,说明作者基本上已经放弃维护了.而LDoc则是 ...
- 【Lua】LDoc生成Lua文档工具的使用
参考资料: http://my.oschina.net/wangxuanyihaha/blog/188909 LDoc介绍: LDoc是一个Lua的文档生成工具,过去,比较常用的Lua生成 ...
- lua UT测试工具
luaunit Luaunit is a unit-testing framework for Lua, in the spirit of many others unit-testing frame ...
- Lua Doc生成工具
Luadoc http://keplerproject.github.io/luadoc/ Overview LuaDoc is a documentation generator tool for ...
- WPF 选项卡
1.引用 xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock" 2.xaml代码 <xcad:DockingMa ...
- 《Python入门》Windows 7下Python Web开发环境搭建笔记
最近想尝试一下在IBM Bluemix上使用Python语言创建Web应用程序,所以需要在本地搭建Python Web的开发测试环境. 关于Python的版本 进入Python的网站,鼠标移到导航条上 ...
- 全文检索引擎及工具 Lucene Solr
全文检索引擎及工具 lucence lucence是一个全文检索引擎. lucence代码级别的使用步骤大致如下: 创建文档(org.apache.lucene.document.Document), ...
- windows服务与log4net应用
有时候我们需要用到window服务来执行定时任务,然后配合log4net记录程序运行情况,这里简单记录下配置的整个过程以及注意要点: 一.添加windows服务 1.设计页面,右键添加安装程序
- Lua OpenResty容器化(考古历程)
原文地址:Lua OpenResty容器化(考古历程) 背景 公司有几个"远古时期"的项目,一直都相对较为稳定,但是项目每天总会在一些时段,请求每分钟QPS到达峰值800K左右,导 ...
随机推荐
- ElasticSearch如何更新集群的状态
ElasticSearch如何更新集群的状态 最近发生了很多事情,甚至对自己的技术能力和学习方式产生了怀疑,所以有一段时间没更新文章了,估计以后更新的频率会越来越少,希望有更多的沉淀而不是简单地分享. ...
- main 函数返回值
[1]main函数 [2]main() 经典的C风格函数头,如下: main() 在C语言中,省略返回类型相当于说函数的类型为int. 但是,需要明确,C++逐步淘汰了这种用法. 另外,在C语言中,让 ...
- 算法设计与分析(李春保)练习题答案v2
----------------------------------------------------- Page 1 --------------------------------------- ...
- Python 3 的 int 类型详解(为什么 int 不存在溢出问题?)
在以前的Python2中,整型分为int和long,也就是整型和长整型, 长整型不存在溢出问题, 即可以存放任意大小的数值,理论支持无限大数字. 因此在Python3 中,统一使用长整型,用int表示 ...
- 《 .NET并发编程实战》阅读指南 - 第14章
先发表生成URL以印在书里面.等书籍正式出版销售后会公开内容.
- aspose.cells导出Demo
/// <summary> /// 导出excel /// </summary> /// <param name="list"></par ...
- javascript工厂函数(factory function)vs构造函数(constructor function)
如果你从其他语言转到javascript语言的开发,你会发现有很多让你晕掉的术语,其中工厂函数(factory function)和构造函数(constructor function)就是其中的一个. ...
- JavaScript中数组相关的属性方法
下面的这些方法会改变调用它们的对象自身的值: Array.prototype.copyWithin() 在数组内部,将一段元素序列拷贝到另一段元素序列上,覆盖原有的值. Array.prototype ...
- datagrid相关
int rowID = Convert.ToInt32(dataGrid_OpenBoxScan.CurrentRowIndex.ToString());//得到所选行的行号 ...
- jquery添加插件
转自:https://www.cnblogs.com/joey0210/p/3408349.html 前言 如今做web开发,jquery 几乎是必不可少的,就连vs神器在2010版本开始将Jquer ...