%{
--------------------------------------------------------------------------------
--
--  This file is part of the Doxyrest toolkit.
--
--  Doxyrest is distributed under the MIT license.
--  For details see accompanying license.txt file,
--  the public copy of which is also available at:
--  http://tibbo.com/downloads/archive/doxyrest/license.txt
--
--------------------------------------------------------------------------------

if FORCE_INCLUDE_FILE then
}
.. include:: $FORCE_INCLUDE_FILE
%{
end -- if

if INTRO_FILE then
}
.. include:: $INTRO_FILE

%{
else
}
$(getTitle(INDEX_TITLE, 1))

%{
end --if

if #g_groupArray > 0 then
}
.. toctree::
	:hidden:

%{
	table.sort(g_groupArray, cmpGroups)
	local groupTree = ""

	for i = 1, #g_groupArray do
		local group = g_groupArray[i]
		local targetFileName = getItemFileName(group)
		prepareCompound(group)
		generateFile(targetFileName, "group.rst.in", group)
		groupTree = groupTree .. getGroupTree(group)
}
	$(targetFileName)
%{
	end -- for
}

.. rubric:: Further Reading:

$groupTree

%{
end -- if

if #g_pageArray > 0 or #EXTRA_PAGE_LIST > 0 then
}
.. toctree::
	:hidden:

%{
	table.sort(g_pageArray, cmpTitles)
	local pageTree = ""

	for i = 1, #g_pageArray do
		local page = g_pageArray[i]
		local targetFileName = getItemFileName(page)

		generateFile(targetFileName, "page.rst.in", page)

		if targetFileName ~= INTRO_FILE then
			pageTree = pageTree .. getPageTree(page, targetFileName)
}
	$(targetFileName)
%{
		end -- if
	end -- for

	for i = 1, #EXTRA_PAGE_LIST do
		local fileName = EXTRA_PAGE_LIST[i]
		local docName = string.gsub(fileName, "%.rst$", "")
		pageTree = pageTree .. "|\t:doc:`" .. docName .."`\n"
}
	$(fileName)
%{
	end -- for
}

.. rubric:: Related Pages:

$pageTree

%{
end -- if

if #g_exampleArray > 0 then
}
.. toctree::
	:hidden:

%{
	table.sort(g_exampleArray, cmpNames)
	local exampleList = ""

	for i = 1, #g_exampleArray do
		local example = g_exampleArray[i]
		local targetFileName = getItemFileName(example)
		local docName = string.gsub(targetFileName, "%.rst$", "")

		generateFile(targetFileName, "example.rst.in", example)
		exampleList = exampleList .. "|\t:doc:`" .. docName .."`\n"
}
	$(targetFileName)
%{
	end -- for
}

.. rubric:: Examples:

$exampleList

%{
end -- if

generateFile("global.rst", "global.rst.in")
}
.. rubric:: Reference and Index:

.. toctree::
	:hidden:

	global.rst

|	:doc:`global`
|	:ref:`genindex`

