More actions
No edit summary |
stargazer: a66e644b10 |
||
(4 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
function SourceLink.main(frame) | function SourceLink.main(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
return string.format( "[https://github.com/teamstarcup/starcup/blob/ | 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/a66e644b10ba9e610cd92c1e8a86a76a1299a526/%s %s]", argPath, displayText ) | |||
end | end | ||
return SourceLink | return SourceLink |
Latest revision as of 14:43, 27 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/a66e644b10ba9e610cd92c1e8a86a76a1299a526/%s %s]", argPath, displayText )
end
return SourceLink