모듈:HelpNavigation

최근 편집: 2018년 9월 25일 (화) 20:45

이 모듈에 대한 설명문서는 모듈:HelpNavigation/설명문서에서 만들 수 있습니다

local p = {}

function p.helpArray(frame) 
    return p._helpArray(frame.args[1],frame)
end

function p._helpArray(title,frame)
    local titlesRawText = frame:expandTemplate{title=title}

    local helpTitlesArray = {}
    for word in string.gmatch(titlesRawText, '%[%[([^:]*:[^\|]+)') do
        helpTitlesArray[table.getn(helpTitlesArray)+1] = word
    end

    return helpTitlesArray
end
    

function p.previous(frame) 	
	local helpTitlesArray = p._helpArray(frame.args[2],frame)
	for i,v in ipairs(helpTitlesArray) do 
		if string.match(v,':(.+)') == string.match(frame.args[1],':(.+)') and i-1 > 0 then return helpTitlesArray[i-1] end
	end
	return nil
end

function p.next(frame)
	local helpTitlesArray = p._helpArray(frame.args[2],frame)
	for i,v in ipairs(helpTitlesArray) do 
		if string.match(v,':(.+)') == string.match(frame.args[1],':(.+)') and i+1 <= table.getn(helpTitlesArray) then return helpTitlesArray [i+1] end
	end
	return nil
end

return p