diff options
author | 2009-07-25 23:34:13 -0400 | |
---|---|---|
committer | 2009-07-25 23:34:13 -0400 | |
commit | 033416a15fe60fe10387119e0e63bb9ed9e8aedd (patch) | |
tree | 31bc4d91e15b484c336eadf25c0008f7bd17facc /scripts/update_doc | |
parent | b9e5e58446c95344b550c0a6ab91aa57ee9468ef (diff) | |
download | textadept-033416a15fe60fe10387119e0e63bb9ed9e8aedd.tar.gz textadept-033416a15fe60fe10387119e0e63bb9ed9e8aedd.zip |
Documentation overhaul.
Diffstat (limited to 'scripts/update_doc')
-rwxr-xr-x | scripts/update_doc | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/scripts/update_doc b/scripts/update_doc new file mode 100755 index 00000000..c3360e43 --- /dev/null +++ b/scripts/update_doc @@ -0,0 +1,104 @@ +#!/usr/bin/lua +-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. + +-- Generate LuaDoc. +os.execute('rm -rf ../doc/modules/') +os.execute('cd ../; luadoc -d doc/ --nofiles modules/ core/ lexers/lexer.lua') + +-- Insert Markdown in modules into LuaDoc. +local p = io.popen('grep -r "\\-\\- Markdown:" ../*') +for file in p:lines() do + local module + + -- Open the Lua file and extract the Markdown lines. + local f = io.open(file:match('^[^:]+')) + local markdown, flag = {}, false + for line in f:lines() do + if flag and line:match('^%-%-') then + local match = line:match('^%-%- ([^\n]+)') + markdown[#markdown + 1] = match or '' + elseif flag then -- markdown ended + break + elseif line:match('^%-%- Markdown:') then + flag = true + elseif line:match('^module') then + module = line:match("^module%('([^']+)") + end + end + f:close() + + -- Convert the Markdown into HTML. + markdown = table.concat(markdown, '\n') + f = io.open('tmp', 'w') + f:write(markdown) + f:close() + f = io.popen('perl ../doc/Markdown.pl tmp') + markdown = f:read('*all') + f:close() + os.execute('rm tmp') + + -- Insert the Marked down HTML in the LuaDoc HTML file. + local filename = '../doc/modules/'..module..'.html' + f = io.open(filename) + local contents = f:read('*all') + f:close() + local s = contents:find('<h2>Functions</h2>') + if not s then s = contents:find('<h2>Tables</h2>') end + contents = contents:sub(1, s - 1)..markdown..contents:sub(s) + f = io.open(filename, 'w') + f:write(contents) + f:close() +end +p:close() + +-- Generate the Manual. +p = io.popen('ls -1 ../doc/manual/*.md') +for mdfile in p:lines() do + local htmlfile = mdfile:match('^(.+).md$')..'.html' + html = [[ + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + <html> + <head> + <title>Textadept Manual</title> + <base href="http://caladbolg.net/luadoc/textadept/" /> + <link rel="stylesheet" href="luadoc.css" type="text/css" /> + </head> + + <body> + <div id="container"> + <div id="main"> + <div id="navigation"> + + %sidebar% + + </div> + <div id="content"> + + %content% + + </div> + </div> + <div id="about"> + <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p> + </div> + </div> + </body> + </html> + ]] + + local sidebar_md = io.popen('../doc/Markdown.pl ../doc/sidebar.md') + html = html:gsub('%%sidebar%%', sidebar_md:read('*all')) + sidebar_md:close() + local content_md = io.popen('../doc/Markdown.pl '..mdfile) + html = html:gsub('%%content%%', content_md:read('*all')) + content_md:close() + + local f = io.open(htmlfile, 'w') + f:write(html) + f:close() +end +p:close() + +os.execute("sed -i 's/pre.example/pre, pre.example/;' ../doc/luadoc.css") +os.execute('cd ../; doxygen Doxyfile') |