From 20662bc83a232c31ce27b6341bcad3a23a0a94c1 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 8 Mar 2012 10:04:53 -0500 Subject: Added header and footer to Manual and LuaDoc. --- doc/markdowndoc.lua | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'doc/markdowndoc.lua') diff --git a/doc/markdowndoc.lua b/doc/markdowndoc.lua index 3dade210..a93c97c6 100644 --- a/doc/markdowndoc.lua +++ b/doc/markdowndoc.lua @@ -32,6 +32,9 @@ local HTML = [[
+ @@ -106,8 +112,22 @@ end -- Called by LuaDoc to process a doc object. -- @param doc The LuaDoc doc object. function M.start(doc) + local template = { + title = 'Textadept API', header = '', toc = '', main = '', footer = '' + } local modules, files = doc.modules, doc.files + -- Create the header and footer, if given a template. + local header, footer = '', '' + if M.options.template_dir ~= 'luadoc/doclet/html/' then + local p = io.popen('markdown "'..M.options.template_dir..'header.md"') + template.header = p:read('*all') + p:close() + p = io.popen('markdown "'..M.options.template_dir..'footer.md"') + template.footer = p:read('*all') + p:close() + end + -- Create the navigation list. local hierarchy = {} for _, name in ipairs(modules) do @@ -125,9 +145,15 @@ function M.start(doc) write_nav(f, hierarchy) f:close() local p = io_popen('markdown "'..navfile..'"') - local nav = p:read('*all') + template.nav = p:read('*all') p:close() + -- Write index.html. + f = io_open(M.options.output_dir..'/api/index.html', 'wb') + local html = HTML:gsub('%%%(([^)]+)%)', template) + f:write(html) + f:close() + -- Create a map of doc objects to file names so their Markdown doc comments -- can be extracted. local filedocs = {} @@ -207,25 +233,16 @@ function M.start(doc) f:close() -- Write HTML. + template.title = name..' - Textadept API' local p = io_popen('markdown -f toc -T "'..mdfile..'"') - local toc, main = p:read('*all'):match('^(.-\n\n)(.+)$') + template.toc, template.main = p:read('*all'):match('^(.-\n\n)(.+)$') p:close() - toc = toc:gsub('()', '%1%2') -- strip function parameters + template.toc = template.toc:gsub('()', '%1%2') -- strip params f = io_open(M.options.output_dir..'/api/'..name..'.html', 'wb') - local html = HTML:gsub('%%%(([^)]+)%)', { - title = name..' - Textadept API', nav = nav, toc = toc, main = main - }) + local html = HTML:gsub('%%%(([^)]+)%)', template) f:write(html) f:close() end - - -- Write index.html. - f = io_open(M.options.output_dir..'/api/index.html', 'wb') - local html = HTML:gsub('%%%(([^)]+)%)', { - title = 'Textadept API', nav = nav, toc = '', main = '' - }) - f:write(html) - f:close() end return M -- cgit v1.2.3