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使用总结的更多相关文章

  1. 使用Ldoc给Lua生成文档

    Ldoc介绍 LDoc是一个Lua的文档生成工具,过去,比较常用的Lua生成文档的工具是LuaDoc,可惜作者自从2008年之后就再也没有发布过新的版本了,说明作者基本上已经放弃维护了.而LDoc则是 ...

  2. 【Lua】LDoc生成Lua文档工具的使用

    参考资料: http://my.oschina.net/wangxuanyihaha/blog/188909   LDoc介绍:     LDoc是一个Lua的文档生成工具,过去,比较常用的Lua生成 ...

  3. lua UT测试工具

    luaunit Luaunit is a unit-testing framework for Lua, in the spirit of many others unit-testing frame ...

  4. Lua Doc生成工具

    Luadoc http://keplerproject.github.io/luadoc/ Overview LuaDoc is a documentation generator tool for ...

  5. WPF 选项卡

    1.引用 xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock" 2.xaml代码 <xcad:DockingMa ...

  6. 《Python入门》Windows 7下Python Web开发环境搭建笔记

    最近想尝试一下在IBM Bluemix上使用Python语言创建Web应用程序,所以需要在本地搭建Python Web的开发测试环境. 关于Python的版本 进入Python的网站,鼠标移到导航条上 ...

  7. 全文检索引擎及工具 Lucene Solr

    全文检索引擎及工具 lucence lucence是一个全文检索引擎. lucence代码级别的使用步骤大致如下: 创建文档(org.apache.lucene.document.Document), ...

  8. windows服务与log4net应用

    有时候我们需要用到window服务来执行定时任务,然后配合log4net记录程序运行情况,这里简单记录下配置的整个过程以及注意要点: 一.添加windows服务 1.设计页面,右键添加安装程序

  9. Lua OpenResty容器化(考古历程)

    原文地址:Lua OpenResty容器化(考古历程) 背景 公司有几个"远古时期"的项目,一直都相对较为稳定,但是项目每天总会在一些时段,请求每分钟QPS到达峰值800K左右,导 ...

随机推荐

  1. sitecore 将媒体项目关联到为数字营销资产分类

    在创建营销活动时,您可能希望跟踪联系人与媒体项目的交互方式,例如PDF,视频或您网站上的其他文档.您可以通过将媒体项目分类为数字营销资产来实现此目的. 当您应用分类标签到媒体库中的项目时,项目就变成了 ...

  2. 关于优秀的视频播放器 - PotPlayer

    播放器设置 直接截图: 其他重要功能 1. 切换语音:Alt + A 谢谢浏览!

  3. docker安装mysql8

    docker run --restart=always -d -v /opt/data/conf.d/:/etc/mysql/conf.d/ -v /opt/data/mysql/:/var/lib/ ...

  4. C# WebBrowser控件 下载文件不弹下载提示框的办法

    参考链接 https://stackoverflow.com/questions/6773866/download-file-and-automatically-save-it-to-folder p ...

  5. Go函数篇

    1 定义格式 函数构成代码执行的逻辑结构.在Go语言中,函数的基本组成为:关键字func.函数名.参数列表.返回值.函数体和返回语句. Go 语言函数定义格式如下: func FuncName(/*参 ...

  6. ElasticSearch(九)e代驾使用Elasticsearch流程设计(Yii1版本)

    一.控制器层的更新.添加.删除 class AddKnowledgeAction extends CAction { //add and update public function actionPo ...

  7. JS树结构转list结构

    树转list /** * 树转list */ function treeToList(tree){ for(var i in tree){ var node = tree[i]; list = []; ...

  8. c# 读数据库二进制流到图片

    public Bitmap PictureShow(string connectionString, string opName, string productType)        {       ...

  9. android 第三方开源库 学习汇总

    依赖注入框架ButterKnife  https://github.com/JakeWharton/butterknife  学习过程     专注于android的View注入框架,并不支持其他方面 ...

  10. Html引入百度富文本编辑器ueditor及自定义工具栏

    在日常工作用,肯定有用到富文本编辑器的时候,富文本编辑器功能强大使用方便,我用的是百度富文本编辑器,首先需要下载好百度编辑器的demo, 然后创建ueditor.html文件,引入百度编辑器,然后在h ...