Module:Documentation: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
osrsw>Jayden
m 1 revision imported: Merging
osrsw>IN008
mNo edit summary
Line 1: Line 1:
-- <nowiki>
-- <nowiki>
-- [[Template:Documentation]]
--


local p = {}
local p = {}
Line 8: Line 6:
     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 ret, cats, ret1, ret2, ret3
     local ret, cats, ret1, ret2
    local onModule = title.namespace == 828
      
      
     -- subpage header
     -- subpage header
Line 18: Line 17:
             :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|center|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
             cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
             cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
        elseif title.namespace == 828 then
        cats = '[[Category:Module documentation|' .. title.baseText .. ']]'
        else
        cats = ''
         end
         end
          
          
Line 43: Line 50:
     -- 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">'
     ret1 = '<div class="documentation">'
   
 
     ret2 = mw.html.create( 'div' )
     ret2 = mw.html.create( nil )
        :addClass( 'doc-header' )
        :tag('div')
        :tag( 'span' )
            :addClass( 'doc-header' )
            :addClass( 'doc-title' )
            :tag( 'span' )
             :wikitext( 'Template documentation' )
                :addClass( 'doc-title' )
                :wikitext( string.format('%s documentation', onModule and 'Module' or 'Template') )
                :done()
             :tag( 'span' )
                :addClass( 'doc-editlinks' )
                :addClass( 'plainlinks' )
                :wikitext(
                    '[[' .. tostring( mw.uri.fullUrl( page .. '/doc', {action='edit'} ) ) .. ' edit]] ' ..
                    '[<span class="jsPurgeLink">[' .. tostring( mw.uri.fullUrl( title.fullText, {action='purge'} ) ) .. ' purge]</span>]'
                )
                :done()
             :done()
             :done()
         :tag( 'span' )
         :tag( 'div' )
             :addClass( 'doc-editlinks' )
             :addClass( 'doc-transclusion' )
            :addClass( 'plainlinks' )
             :wikitext( 'This documentation is transcluded from [[' .. page .. '/doc]].' )
             :wikitext(
                '[[' .. tostring( mw.uri.fullUrl( template .. '/doc', {action='edit'} ) ) .. ' edit]] ' ..
                '[<span class="jsPurgeLink">[' .. tostring( mw.uri.fullUrl( title.fullText .. '/doc', {action='purge'} ) ) .. ' purge]</span>]'
            )
             :done()
             :done()
        :done()
          
          
    ret3 = mw.html.create( 'div' )
     return ret1 .. tostring( ret2 )
        :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>

Revision as of 17:28, 21 November 2018

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

-- <nowiki>

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 ret, cats, ret1, ret2
    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|center|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
            cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
        elseif title.namespace == 828 then
        	cats = '[[Category:Module documentation|' .. title.baseText .. ']]'
        else
        	cats = ''
        end
        
        return tostring( ret ) .. cats
    end
    
    -- template header
    -- don't use mw.html as we aren't closing the main div tag
    ret1 = '<div class="documentation">'

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

return p

-- </nowiki>