Automatically creates documentation of a Lua module by extracting its documentation markup.


This module makes use of the syntax defined in ExpLua to retrieve documentation for a module. For example, with Module:codedoc/sample one could use the following Lua invoke in a talk page to show its code:


See generated docs in Module talk:Codedoc/sample.


The syntax is:


The module name must contain the syntax as described, otherwise it will not retrieve anything.

Documentation syntax

As described by the ExpLua author[1]:

For the whole file:

--| Begins a module/file comment, e.g., "this file does *this*".
--by Pedro Miller Rabinovitch <>
--$Id: myfile.lua,v 1.12 2003/10/17 00:13:56 miller Exp $
--TODO lots of stuff.

(Both --by and --TODO can be abbreviated to --b and --T)

Preceding each function:

--% This is the purpose of the function, i.e., what it *does*.
--- And this is the second line, which will concatenated to
--- the others.
--@ first (string) Text of the first parameter
--@ what (table) The second parameter is the table used for an
--- example
--@ [...] (any) Optional parameters to the called whatever
--: (number) Number of whatevers done or nil if an error occured
function Module:MyFunction( first, what, ... )


The syntax relies on adding comments with special characters that have a specific meaning, as described below:

  • --| — is used to describe the module itself
  • --by — contains author info
  • --TODO — contains any todo notes
  • --% — describes the purpose of the function
  • --@ — contains information about the parameters (format: "parameter name (parameter type) description")
  • --: — contains the description of the values returned by a function (format: "return type and description")

Note that by default the module details (author, etc.) are hidden by a setting in the script, but this can be overwritten.


Installing modules

To get a brief introduction to lua read the basics page first. On Wikia, one can use modules by either accessing a module remotely or copying all its contents to a Wiki. Modules accessed remotely from dev.wikia are subject to change while 'correctly' copied modules are controlled by a particular wiki.

Using a module "remotely" using Module:Devmodule

Create Module:Devmodule and copy the following code to remotely access modules in dev's repository. See more details in Global Lua Modules/Devmodule.
--[[This imports modules from dev.wikia]]
return require("Dev:Devmodule")

Loading modules remotely from dev.wikia

Create Module:Codedoc in your wiki and add the following code:
--This loads modules directly from
return require("Dev:Codedoc")

Using Module:Codedoc in another wiki

To use modules without depending on dev see this page. Create Template:Codedoc in your wiki and add the following code:

Using template in a page

You can use this module in a page using syntax such as:

Module information



Creates docs for a module..
pagestringA page to read the docs from e.g. Bananas.
Return typeReturn purpose
stringA string containing the documentation of a module.


Creates tables contains function parameters and return types..
functionTabletableA table containing all functions in the code, related docs.
Return typeReturn purpose
tableA table based on mw.html containing the function docs.


Entry point for documenting..
frametableA frame object containing a module name as first parameter.
Return typeReturn purpose
stringThe documentation of a particular module.


Gets a default mpage, generally a subpage(e.g"/links") of "Global lua modules"..
Return typeReturn purpose
stringThe default page containing documentation.



Start a Discussion Discussions about Global Lua Modules/Codedoc