Module:Documentation: Difference between revisions

osrsw>Habblet
m copy changes from rsw:Module:Documentation
m 15 revisions imported
 
(7 intermediate revisions by 4 users not shown)
Line 8: Line 8:
     local args = frame:getParent().args
     local args = frame:getParent().args
     local page = 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 addDependencyList = yn( args.DependencyList or true )
    local addDependencyList = true
     local ret, cats, ret1, ret2, ret3
     local ret, cats, ret1, ret2, ret3
     local onModule = title.namespace == 828
     local onModule = title.namespace == 828
Line 21: Line 20:
                 :tag( 'td' )
                 :tag( 'td' )
                     :css( 'width', '40px' )
                     :css( 'width', '40px' )
                     :wikitext( '[[File:Information icon-grey.svg|35px|center|link=]]' )
                     :wikitext( '[[File:Information icon-grey.svg|35px|centre|link=]]' )
                     :done()
                     :done()
                 :tag( 'td' )
                 :tag( 'td' )
Line 42: Line 41:
         if title.namespace == 10 then -- Template namespace
         if title.namespace == 10 then -- Template namespace
             cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
             cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
             ret2 = addDependencyList and dependencyList._main() or ''
             ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
         elseif title.namespace == 116 then -- Calculator namespace
         elseif title.namespace == 116 then -- Calculator namespace
         cats = ''
         cats = ''
         ret2 = addDependencyList and dependencyList._main() or ''
         ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
         elseif title.namespace == 828 then -- Module namespace
         elseif title.namespace == 828 then -- Module namespace
         cats = '[[Category:Module documentation|' .. title.baseText .. ']]'
         cats = '[[Category:Module documentation|' .. title.baseText .. ']]'
         ret2 = addDependencyList and dependencyList._main() or ''
         ret2 = addDependencyList and dependencyList._main(nil, args.category, args.isUsed) or ''
         else
         else
         cats = ''
         cats = ''
Line 59: Line 58:
     -- 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
     ret1 = '<div class="documentation">'
     ret1 = '<div class="documentation" style="clear:both;">'


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