Module:Documentation: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
osrsw>Gaz Lloyd
+
m 15 revisions imported
 
(10 intermediate revisions by 6 users not shown)
Line 1: Line 1:
-- <nowiki>
-- <nowiki>
-- [[Template:Documentation]]
local dependencyList = require( 'Module:DependencyList' )
--
local yn = require( 'Module:Yesno' )
 
local p = {}
local p = {}


Line 8: Line 7:
     local title = mw.title.getCurrentTitle()
     local title = mw.title.getCurrentTitle()
     local args = frame:getParent().args
     local args = frame:getParent().args
     local template = args[1] or mw.ustring.gsub( title.fullText, '/doc$', '' )
     local page = args[1] or mw.ustring.gsub( title.fullText, '/doc$', '' )
    local addDependencyList = yn( args.DependencyList or true )
     local ret, cats, ret1, ret2, ret3
     local ret, cats, ret1, ret2, ret3
    local onModule = title.namespace == 828
      
      
     -- subpage header
     -- subpage header
Line 18: Line 19:
             :tag( 'tr' )
             :tag( 'tr' )
                 :tag( 'td' )
                 :tag( 'td' )
                     :wikitext( '[[File:Information icon-grey.svg|40px|Documentation]]' )
                    :css( 'width', '40px' )
                     :wikitext( '[[File:Information icon-grey.svg|35px|centre|link=]]' )
                     :done()
                     :done()
                 :tag( 'td' )
                 :tag( 'td' )
                     :tag( 'b' )
                     :tag( 'b' )
                         :wikitext( 'This is a documentation subpage for [[' .. template .. ']].' )
                         :wikitext( 'This is a documentation subpage for [[' .. page .. ']].' )
                         :done()
                         :done()
                     :tag( 'div' )
                     :tag( 'div' )
                         :css( 'font-size', '0.85em' )
                         :css({ ['font-size'] = '0.85em', ['line-height'] = '1.4em' })
                         :wikitext( 'It contains usage information, categories, and other content that is not part of the original template page.' )
                         :wikitext(
                        string.format(
                        'It contains usage information, categories, and other content that is not part of the original %s page.',
                            onModule and 'module' or 'template'
                        )
                    )
                         :done()
                         :done()
                     :done()
                     :done()
                 :done()
                 :done()
             :done()
             :done()
   
        cats = ''


         if title.nsText == 'Template' then
         if title.namespace == 10 then -- Template namespace
             cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
             cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
            ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
        elseif title.namespace == 116 then -- Calculator namespace
        cats = ''
        ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
        elseif title.namespace == 828 then -- Module namespace
        cats = '[[Category:Module documentation|' .. title.baseText .. ']]'
        ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
        else
        cats = ''
        ret2 = ''
         end
         end
          
          
         return tostring( ret ) .. cats
         return tostring( ret ) .. ret2 .. cats
     end
     end
      
      
     -- template header
     -- template header
     -- don't use mw.html as we aren't closing the main div tag
     -- don't use mw.html as we aren't closing the main div tag
    -- @todo when <https://github.com/Wikia/app/pull/7475> is merged, clean this up a bit
     ret1 = '<div class="documentation" style="clear:both;">'
     ret1 = '<div class="documentation">'
 
   
     ret2 = mw.html.create( nil )
     ret2 = mw.html.create( 'div' )
        :tag( 'div' )
        :addClass( 'doc-header' )
            :addClass( 'doc-header documentation-header')
        :tag( 'span' )
            :tag( 'span' )
            :addClass( 'doc-title' )
            :addClass( 'doc-title documentation-title' )
            :wikitext( 'Template documentation' )
            :wikitext( string.format('%s documentation', onModule and 'Module' or 'Template') )
            :done()
             :done()
             :done()
         :tag( 'span' )
         :tag( 'div' )
             :addClass( 'doc-editlinks' )
             :addClass( 'doc-transclusion documentation-subheader' )
             :addClass( 'plainlinks' )
            :tag( 'span' )
            :wikitext(
            :addClass( 'documentation-documentation' )
                '[[' .. tostring( mw.uri.fullUrl( template .. '/doc', {action='edit'} ) ) .. ' edit]] ' ..
            :wikitext( 'This documentation is transcluded from [[' .. page .. '/doc]]. ' )
                '[<span class="jsPurgeLink">[' .. tostring( mw.uri.fullUrl( title.fullText .. '/doc', {action='purge'} ) ) .. ' purge]</span>]'
            :done()
            )
             :tag( 'span' )
            :addClass( 'doc-editlinks documentation-links plainlinks' )
            :wikitext(
            '[[' .. tostring( mw.uri.fullUrl( page .. '/doc', {action='edit'} ) ) .. ' edit]] ' ..
            '[[' .. tostring( mw.uri.fullUrl( page .. '/doc', {action='history'} ) ) .. ' history]] ' ..
                '[<span class="jsPurgeLink">[' .. tostring( mw.uri.fullUrl( title.fullText, {action='purge'} ) ) .. ' purge]</span>]'
            )
            :done()
             :done()
             :done()
        :done()
   
    ret3 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
          
          
     ret3 = mw.html.create( 'div' )
     return ret1 .. tostring( ret2 ) .. '<div class="documentation-content">' .. ret3
        :addClass( 'doc-transclusion' )
        :wikitext( 'This documentation is transcluded from [[' .. template .. '/doc]].' )
        :done()
       
    return ret1 .. tostring( ret2 ) .. tostring( ret3 )
end
end


return p
return p
-- </nowiki>

Latest revision as of 17:12, 25 August 2026

Documentation for this module may be created at Module:Documentation/doc

-- <nowiki>
local dependencyList = require( 'Module:DependencyList' )
local yn = require( 'Module:Yesno' )
local p = {}

function p.doc( frame )
    local title = mw.title.getCurrentTitle()
    local args = frame:getParent().args
    local page = args[1] or mw.ustring.gsub( title.fullText, '/doc$', '' )
    local addDependencyList = yn( args.DependencyList or true )
    local ret, cats, ret1, ret2, ret3
    local onModule = title.namespace == 828
    
    -- subpage header
    if title.subpageText == 'doc' then
        ret = mw.html.create( 'table' )
            :addClass( 'messagebox' )
            :addClass( 'info' )
            :tag( 'tr' )
                :tag( 'td' )
                    :css( 'width', '40px' )
                    :wikitext( '[[File:Information icon-grey.svg|35px|centre|link=]]' )
                    :done()
                :tag( 'td' )
                    :tag( 'b' )
                        :wikitext( 'This is a documentation subpage for [[' .. page .. ']].' )
                        :done()
                    :tag( 'div' )
                        :css({ ['font-size'] = '0.85em', ['line-height'] = '1.4em' })
                        :wikitext(
                        	string.format(
                        		'It contains usage information, categories, and other content that is not part of the original %s page.',
                        	    onModule and 'module' or 'template'
                        	)
                    	)
                        :done()
                    :done()
                :done()
            :done()

        if title.namespace == 10 then -- Template namespace
            cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
            ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
        elseif title.namespace == 116 then -- Calculator namespace
        	cats = ''
        	ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
        elseif title.namespace == 828 then -- Module namespace
        	cats = '[[Category:Module documentation|' .. title.baseText .. ']]'
        	ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
        else
        	cats = ''
        	ret2 = ''
        end
        
        return tostring( ret ) .. ret2 .. cats
    end
    
    -- template header
    -- don't use mw.html as we aren't closing the main div tag
    ret1 = '<div class="documentation" style="clear:both;">'

    ret2 = mw.html.create( nil )
        :tag( 'div' )
            :addClass( 'doc-header documentation-header')
            :tag( 'span' )
            	:addClass( 'doc-title documentation-title' )
            	:wikitext( string.format('%s documentation', onModule and 'Module' or 'Template') )
            	:done()
            :done()
        :tag( 'div' )
            :addClass( 'doc-transclusion documentation-subheader' )
            :tag( 'span' )
            	:addClass( 'documentation-documentation' )
            	:wikitext( 'This documentation is transcluded from [[' .. page .. '/doc]]. ' )
            	:done()
            :tag( 'span' )
            	:addClass( 'doc-editlinks documentation-links plainlinks' )
            	:wikitext(
	            	'[[' .. tostring( mw.uri.fullUrl( page .. '/doc', {action='edit'} ) ) .. ' edit]] ' ..
	            	'[[' .. tostring( mw.uri.fullUrl( page .. '/doc', {action='history'} ) ) .. ' history]] ' ..
	                '[<span class="jsPurgeLink">[' .. tostring( mw.uri.fullUrl( title.fullText, {action='purge'} ) ) .. ' purge]</span>]'
	            )
	            :done()
            :done()
    
    ret3 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
        
    return ret1 .. tostring( ret2 ) .. '<div class="documentation-content">' .. ret3
end

return p

-- </nowiki>