More actions
No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
end | end | ||
displayText = displayText:sub(1, fragmentIndex) | displayText = displayText:sub(1, fragmentIndex) | ||
return string.format( "[https://github.com/teamstarcup/starcup/blob/ | return string.format( "[https://github.com/teamstarcup/starcup/blob/810c9b5a047d7a4c6df4f58be5683a49151812bf/%s %s]", argPath, displayText ) | ||
end | end | ||
return SourceLink | return SourceLink |
Revision as of 05:47, 23 May 2025
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/810c9b5a047d7a4c6df4f58be5683a49151812bf/%s %s]", argPath, displayText )
end
return SourceLink