Documentation
This module generates an external link to the GitHub repository at the (hopefully) current commit hash of the main branch. It is used for pointing somewhere specific in the codebase.
Usage
{{SourceLink|Resources/Prototypes/Entities/Objects/Tools/lantern.yml#L1}}
... which generates the following link: lantern.yml
local SourceLink = {}
function SourceLink.main(frame)
local args = frame:getParent().args
local argPath = args[1]
local lastSlashIndex = argPath:reverse():find("/")
local displayText = argPath:sub(#argPath - lastSlashIndex + 2)
local fragmentIndex = displayText:find("#")
if fragmentIndex then
fragmentIndex = fragmentIndex - 1
end
displayText = displayText:sub(1, fragmentIndex)
return string.format( "[https://github.com/teamstarcup/starcup/blob/master/%s %s]", argPath, displayText )
end
return SourceLink