Documentation lua-文档的元数据
我读到了诺曼·拉姆齐的一篇评论 我正试图从我的lib生成文档,如果可能的话,我不想使用luadoc 我想更多地了解这种生成文档的“面向元数据”方法——方法、示例或使用的程序 其他答案是受欢迎的,但这是一个诺曼可能比其他人回答得更好的问题Documentation lua-文档的元数据,documentation,lua,luadoc,Documentation,Lua,Luadoc,我读到了诺曼·拉姆齐的一篇评论 我正试图从我的lib生成文档,如果可能的话,我不想使用luadoc 我想更多地了解这种生成文档的“面向元数据”方法——方法、示例或使用的程序 其他答案是受欢迎的,但这是一个诺曼可能比其他人回答得更好的问题 谢谢 嗯,我想我应该回答这个问题。虽然我可能会在2010年7月15日之后进入可发布状态,但代码还没有准备好进入黄金时间,我很乐意在手边分享副本 有两个想法: 每个模块都有一个名为\uu doc的表。模块中的每个名称都会在\u doc表中获得一个条目。下面是一个例
谢谢 嗯,我想我应该回答这个问题。虽然我可能会在2010年7月15日之后进入可发布状态,但代码还没有准备好进入黄金时间,我很乐意在手边分享副本 有两个想法:
\uu doc
的表。模块中的每个名称都会在\u doc
表中获得一个条目。下面是一个例子:
__doc.rfc2822_to_localtime_or_nil = [[function(date) returns number or nil
Converts RFC2822 date to local time (Unix time).
]]
第一行是函数的“简短文档”。我希望有一天它能被动态检查,但现在它只是文档。剩下的是“长文档”。这里还有几个:
__doc.to_string = [[function(T) returns string
Converts a message to a string in RFC 2822 format.]]
__doc.to_orig_string = [[function(T) returns string
Returns the string originally used to create the message,
which may or may comply with RFC 2822.]]
还有各种特殊字段,如\uu doc.\uu overview
,\uu doc.T
,等等\u doc
字段进行爬网并提供信息。现在这段代码不是很通用,实现也很混乱。但以下是一些示例输出:
整个包的概述(请注意未记录项目的列表,这对保持我的诚实至关重要):
一个模块的简要概述:
: nr@yorkie 5874 ; osbf3 internals -short msg
msg: T = The representation of a message
msg.add_header = function(T, tag, contents)
msg.del_header = function(T, tag, ...)
msg.fingerprint = function(string) returns string
msg.has_sfid = function(msg.T) returns bool
msg.header_indices = function(msg, tag, ...) returns iterator
msg.headers_tagged = function(msg, tag, ...) returns iterator
msg.of_string = function(s, uncertain) returns T or nil
msg.sfid = function(msg.T, [msgspec]) returns string or calls error
msg.synopsis = function(T, w) returns string
msg.to_orig_string = function(T) returns string
msg.to_string = function(T) returns string
一项职能的文件编制:
% osbf3 internals msg.synopsis
msg.synopsis = function(T, w) returns string
Returns a string of width w (default 60) which is a synopsis of the
message T. The synopsis is formed from the Subject: line and the
first few words of the body.
我们的服务器已关闭,但如果有人想玩,我会在我有机会的时候发布此代码的链接。代码示例中额外的空行是由markdown中的一个错误引起的,Jeff将其标记为“按设计”,因此我想我们必须假设此问题不会得到解决。噢,太棒了!我喜欢这个主意!谢谢请在您准备好共享代码时更新您的答案,否则我将不知道您发布了它!同时,回答被接受!您可以尝试使用块来代替标记缩进的代码块。这通常对Lua更好,因为SO和markdown对它的着色效果不是很好,并且通常对引用程序输出更好,因为它根本不是代码。
% osbf3 internals msg.synopsis
msg.synopsis = function(T, w) returns string
Returns a string of width w (default 60) which is a synopsis of the
message T. The synopsis is formed from the Subject: line and the
first few words of the body.