-- This module searches through the specified Lua module, and if it finds the text "FIXME" it adds it to a tracking category.localtrackingCategory='Lua modules with fixme tags'localp={}-- Gets a title object for the specified page, and defaults to the-- title object for the current page if it is not specified or if-- there are any errors.localfunctiongetTitleObject(page)localcurrentTitle=mw.title.getCurrentTitle()ifpagethen-- Get the title object, passing the function through pcall -- in case we are over the expensive function count limit.localnoError,titleObject=pcall(mw.title.new,page)ifnotnoErrorornottitleObjectthenreturncurrentTitleelsereturntitleObjectendelsereturncurrentTitleendendlocalfunction_main(page)page=getTitleObject(page)-- This module should only be used to search for other modules.ifpage.nsText~='Module'thenreturnend-- Match the base page if we are being called from a sandbox or a /doc page.localsubpage=page.subpageTextifpage.isSubpageand(subpage=='doc'orsubpage=='sandbox')thenpage=getTitleObject(page.baseText)end-- The module shouldn't match itself.ifpage.prefixedText=='Module:Fixme'thenreturnend-- Get the page content.localcontent=page:getContent()ifnotcontentthenreturnend-- Find any "FIXME" text.localfixmeExists=falselocalfixmePattern='%WFIXME%W'forsingleLineCommentinmw.ustring.gmatch(content,'%-%-([^\n]*)')doifmw.ustring.find(singleLineComment,fixmePattern)thenfixmeExists=trueendendifnotfixmeExiststhenformultiLineCommentinmw.ustring.gmatch(content,'(%-%-%[(=*)%[.-%]%2%])')doifmw.ustring.find(multiLineComment,fixmePattern)thenfixmeExists=trueendendend-- If any FIXMEs were found, return the tracking category.iffixmeExiststhenreturnmw.ustring.format('[[Category:%s|%s]]',trackingCategory,page.text)endendfunctionp.main(frame)-- If we are being called from #invoke, then the page name is the first positional-- argument. If not, it is the frame parameter.localpageifframe==mw.getCurrentFrame()thenpage=frame:getParent().args[1]localframePage=frame.args[1]ifframePagethenpage=framePageendelsepage=frameendreturn_main(page)endreturnp