dev
Documentation icon Module documentation
[create]

The documentation for this module is missing. Click here to create it.

local docbunto = require('Dev:Docbunto')
local CommandLine = require('Dev:CLI')

local commands = {}

function commands.build(args)
    local identity = function(self, str) return str end

    local ft = require('Dev:FrameTools')
    ft.preprocessMock = identity
    mw.getCurrentFrame().preprocess = identity
    if (mw.getCurrentFrame():getParent()) then
    	mw.getCurrentFrame():getParent().preprocess = identity
    end

    mw.log(docbunto.main(ft.makePseudoFrame({}, args, {})))
end

function commands.taglet(args)
    local file = args.file or table.remove(args, 1)
    mw.log(require('Dev:Json').encode(docbunto.taglet(file, args), { indent = true }))
end

return CommandLine:new{
    description = 'Docbunto, an automatic documentation generator for Scribunto modules.',
    commands = commands,
    words = {
        build = {
            description = 'Build unprocessed module documentation - useful for testcases.',
            options = { 1, 'all', 'boilerplate', 'code', 'colon', 'simple', 'sort', 'ulist' }
        },
        taglet = {
            description = 'Dumps a JSON representation of a module documentation taglet to console.',
            options = { 1, 'boilerplate', 'colon', 'sort' }
        }
    },
    options = {
        { name = 1, alias = 'file', description = 'Module name without namespace.', type = 'string', required = true },
        { name = 'all', alias = 'a', description = 'Include local items in documentation.' },
        { name = 'boilerplate', alias = 'b', description = 'Boilerplate comment removal in source files.' },
        { name = 'box', alias = 'B', description = 'Render infobox from module information.' },
        { name = 'code', alias = 'C', description = 'Only document Docbunto code items.' },
        { name = 'colon', alias = 'c', description = 'Colon mode.' },
        { name = 'card', alias = 'e', description = 'Render endmatter card & affix it to output.' },
        { name = 'footer', alias = 'f', description = 'Add auto generated content message below documentation.' },
        { name = 'migration', alias = 'm', description = 'Migration flag from infobox generation to code.' },
        { name = 'simple', alias = 'S', description = 'Limit documentation to descriptions only.' },
        { name = 'sort', alias = 's', description = 'Sort documentation items in alphabetical order.' },
        { name = 'ulist', alias = 'u', description = 'Indent documentation items as unordered lists.' },
        { name = 'verbose', alias = 'v', description = 'Show the code description of a package function when documenting function modules.' },
    }
}