Template talk:Elinks-api

From Warcraft Wiki
Jump to navigation Jump to search

Design

This template was designed collaboratively by DDC and Ketho on 29 April 2020. The <code> element below summarizes the design using lua, updated as of 15 May 2020. DDC (talk) 22:45, 15 May 2020 (UTC)

-- what system and version are we dealing with?
namespace = namespace or pagename:find(.) and pagename:sub(1,pagename:find(.)-1)
system = system or namespace and namespace:sub(3)
patch = patch or "live"

-- what kind of page is this?
isEvent = t==e or not t and pagename:upper() == pagename
isFunction = t==a or not t and pagename:sub(1,4) == "API "
isObject = t==o or not t and pagename:sub(1,9) == "UIOBJECT "
isMethod = t==w or t==wm
isHandler = t==wh or not t and pagename:sub(1,10) == "UIHANDLER "

-- what is the name of this thing, really?
fullName = isFunction and pagename:sub(4):gsub(" ", "_")
           or isEvent and pagename:gsub(" ", "_") 
           or pagename
partName = isFunction and fullname:explode(".", -1) 
           or fullname
docsAlias = isEvent and makeTitleCase(fullName:gsub("_","")) or partName

-- make as many links as possible for the circumstances
if (patch == "live") then
   GetheSearchLink(partName)  -- the fullName may contain characters not permitted by GitHub
   TLY_GlobeLink(fullName)
end
if (namespace or system) then TLYBADLink(fullName, patch) end
if (system and patch == "live") then MrBudsLink(isFunction and "function" or "event", system, partName) end

-- August 2020 modification, adding wowprogramming
if (wowprog) then
  if (wowprog ~= "") then
    WP_CustomLink(wowprog)
  elseif (isFunction) then
    WP_APILink(partname)
  elseif (isEvent) then
    WP_EventLink(partname)
  elseif (isObject) then
    WP_WidgetLink(partname)
  elseif (isMethod) then
    WP_WidgetMethod(fullname)
  elseif (isHandler) then
    WP_WidgetHandler(fullname)
  end
end

WoW Programming

Ketho, I see you are inserting a wowprog parameter. Would you like me to automate it using the amended snippet above, which priorities the custom link but produces the automatic link for funcs, events, widgets, etc. if you supply an empty parameter? DDC (talk) 16:54, 8 August 2020 (UTC)

Yes, I changed my mind. I think the wowprogramming references are still useful even though it only documents older API. It would be nice to have some kind of automation for empty "wowprog" parameters, if that isn't too much work for you. Ketho 17:15, 8 August 2020 (UTC)
Done via Module:Elinks-api. wowprog is now just a flag; its value doesn't matter. DDC (talk) 04:46, 11 August 2020 (UTC)