コンテンツにスキップ

モジュール:Docbunto

提供: Undertale Wiki

このモジュールについての説明文ページを モジュール:Docbunto/doc に作成できます

--- Docbunto is an automatic documentation generator for Scribunto modules.
--  The module is based on LuaDoc and LDoc. It produces documentation in
--  the form of MediaWiki markup, using <code>@tag</code>-prefixed comments
--  embedded in the source code of a Scribunto module. The taglet parser &
--  doclet renderer Docbunto uses are also publicly exposed to other modules.
--  
--  Docbunto code items are introduced by a block comment
--  (<code>--[[]]--</code>), an inline comment with three hyphens
--  (<code>---</code>), or an inline <code>@tag</code> comment.
--  The module can use static code analysis to infer variable names, item
--  privacy (<code>local</code> keyword), tables (<code>{}</code> constructor) and functions
--  (<code>function</code> keyword). MediaWiki formatting is supported.
--  
--  Items are usually rendered in the order they are defined, if they are
--  public items, or emulated classes extending the Lua primitives.
--  
--  @module             docbunto
--  @alias              p
--  @require            Module:User error
--  @author             [[dev:User:8nml]]
--  @author             [[wikipedia:User:Awesome Aasim]]
--  @attribution        [[github:stevedonovan]] (LDoc)
--  <nowiki>
require('strict')

local p = {}

--  Module dependencies.
local parser = require('Module:Docbunto/parser')
local renderer = require('Module:Docbunto/renderer')

--  Docbunto package items.

--- Generates Lua documentation of the current module.
--  @function           p.main
--  @param              {Frame} frame Scribunto frame object.
--  @return             {string} Module documentation output.
function p.main(frame)
	local title = mw.title.getCurrentTitle()
	if
		title.namespace == 8 and
		title.text == 'Scribunto-doc-page-does-not-exist'
	then
		return
	end
	local modname = mw.title.getCurrentTitle().fullText:gsub('/doc', '')
	local data = parser(modname)
	if not data then
		return require('Module:User error')(
			'Missing Lua documentation! Check other modules to see examples how to write Lua module documentation',
			'Modules with missing documentation'
		)
	end
	return renderer(data, frame, modname)
end

return p

--  <nowiki>