From 44ccc9b2ac07047ba87d365e3b548c8adc6769b2 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Tue, 29 Mar 2011 19:09:07 -0400 Subject: Allow specific documentation to be updated; scripts/update_doc --- scripts/update_doc | 232 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 130 insertions(+), 102 deletions(-) (limited to 'scripts') diff --git a/scripts/update_doc b/scripts/update_doc index 004fef6f..ab8dbf67 100755 --- a/scripts/update_doc +++ b/scripts/update_doc @@ -1,116 +1,144 @@ #!/usr/bin/lua -- Copyright 2007-2011 Mitchell mitchellcaladbolg.net. See LICENSE. +local all = false +if #arg == 0 then all = true end + +local luadoc = all +local manual = all +local doxygen = all +local adeptsense = all + +for _, doctype in ipairs(arg) do + if doctype == 'luadoc' then + luadoc = true + elseif doctype == 'manual' then + manual = true + elseif doctype == 'doxygen' then + doxygen = true + elseif doctype == 'adeptsense' then + adeptsense = true + end +end + -- 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%('([^']+)") +if luadoc then + 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('

Functions

') + if not s then s = contents:find('

Tables

') end + contents = contents:sub(1, s - 1)..markdown..contents:sub(s) + f = io.open(filename, 'w') + f:write(contents) + f:close() 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('

Functions

') - if not s then s = contents:find('

Tables

') end - contents = contents:sub(1, s - 1)..markdown..contents:sub(s) - f = io.open(filename, 'w') - f:write(contents) - f:close() + p:close() + + -- Modify default CSS. + os.execute("sed -i 's/pre.example/pre, pre.example/;' ../doc/luadoc.css") 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 = [[ - - - - Textadept Manual - - - - -
-
- -
- - %content% - -
-
-
-

Valid XHTML 1.0!

-
-
- - - ]] - - 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) - local md = content_md:read('*all'):gsub('%%', '%%%%') - md = md:gsub('()([^<]+)()', - function(s, text, e) - return string.format('%s%s%s', s, - text:gsub(' ', '_'):lower(), text, e) - end) - html = html:gsub('%%content%%', md) - content_md:close() - - local f = io.open(htmlfile, 'w') - f:write(html) - f:close() +if manual then + p = io.popen('ls -1 ../doc/manual/*.md') + for mdfile in p:lines() do + local htmlfile = mdfile:match('^(.+).md$')..'.html' + html = [[ + + + + Textadept Manual + + + + +
+
+ +
+ + %content% + +
+
+
+

Valid XHTML 1.0!

+
+
+ + + ]] + + 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) + local md = content_md:read('*all'):gsub('%%', '%%%%') + md = md:gsub('()([^<]+)()', + function(s, text, e) + return string.format('%s%s%s', s, + text:gsub(' ', '_'):lower(), text, e) + end) + html = html:gsub('%%content%%', md) + content_md:close() + + local f = io.open(htmlfile, 'w') + f:write(html) + f:close() + end + p:close() end -p:close() - --- Modify default CSS. -os.execute("sed -i 's/pre.example/pre, pre.example/;' ../doc/luadoc.css") -- Generate Doxygen documentation. -os.execute('cd ../; doxygen Doxyfile') +if doxygen then + os.execute('cd ../; doxygen Doxyfile') +end -- Create Lua adeptsense for textadept. -os.execute(table.concat{ 'luadoc -d ../modules/lua -doclet adeptsensedoc ', - '../modules ../core ../lexers/lexer.lua' }) +if adeptsense then + os.execute(table.concat{ 'luadoc -d ../modules/lua -doclet adeptsensedoc ', + '../modules ../core ../lexers/lexer.lua' }) +end -- cgit v1.2.3