|
|
| Line 6: |
Line 6: |
| local p = {} | | local p = {} |
|
| |
|
| -- TODO: Change requirements for lua-based template | | -- TODO: (Low-ish priority): rewrite to eliminate redundant code |
| -- FROM: detect whether a corresponding page exists
| |
| -- TO: detect whether it invokes ANYTHING at all
| |
|
| |
|
| -- Produces a hatnote that is placed on the top of a documentation page (either | | -- Produces a hatnote that is placed on the top of a documentation page (either |
| Line 18: |
Line 16: |
| -- - whether a template has an accompanying module (overridable/toggleable) | | -- - whether a template has an accompanying module (overridable/toggleable) |
| -- - what functions from which modules are invoked | | -- - what functions from which modules are invoked |
|
| |
| -- Helper function
| |
| -- Categorizes pages if they're in the right namespace, and based on the nature
| |
| -- of the page
| |
| local function categorize(namespace, pagename, is_lua_based_template)
| |
| local is_lua_based_template = is_lua_based_template or false
| |
| local cats = ""
| |
|
| |
| if pagename:match("/doc$") then
| |
| -- Documentation subpages
| |
| if namespace == "Template" then
| |
| cats = "[[Category:Template documentation]]"
| |
| elseif namespace == "Module" then
| |
| cats = "[[Category:Module documentation]]"
| |
| end
| |
| else
| |
| -- Main pages
| |
| if namespace == "Template" then
| |
| cats = "[[Category:Templates]]"
| |
| if is_lua_based_template then
| |
| cats = cats .. " [[Category:Lua-based templates]]"
| |
| end
| |
| elseif namespace == "Module" then
| |
| cats = "[[Category:Lua modules]]"
| |
| else
| |
| --cats = "[[Category:Templates in the incorrect namespace]]"
| |
| end
| |
| end
| |
|
| |
| return cats
| |
| end
| |
|
| |
|
| -- Helper function: categorize modules | | -- Helper function: categorize modules |