diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2012-03-07 12:47:38 -0500 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2012-03-07 12:47:38 -0500 |
commit | c4d376b33ef504be226d8090ee59c64bbb963696 (patch) | |
tree | 492bbba9247f4050a3a77fd8744040874f6399d3 | |
parent | 6ef663ee541eef65dd93b2664902afee773ae137 (diff) |
Removed `scripts/update_doc` in favor of using `src/Makefile`.
-rw-r--r-- | doc/gen_manual.lua | 66 | ||||
-rw-r--r-- | doc/markdowndoc.lua (renamed from scripts/markdowndoc.lua) | 18 | ||||
-rw-r--r-- | modules/lua/adeptsensedoc.lua (renamed from scripts/adeptsensedoc.lua) | 23 | ||||
-rw-r--r-- | modules/lua/luadoc.patch (renamed from scripts/luadoc.patch) | 0 | ||||
-rwxr-xr-x | scripts/update_doc | 108 | ||||
-rw-r--r-- | src/Makefile | 19 |
6 files changed, 105 insertions, 129 deletions
diff --git a/doc/gen_manual.lua b/doc/gen_manual.lua new file mode 100644 index 00000000..5fa06bfe --- /dev/null +++ b/doc/gen_manual.lua @@ -0,0 +1,66 @@ +-- Copyright 2007-2012 Mitchell mitchell.att.foicica.com. See LICENSE. + +local HTML = [[ + <!doctype html> + <html> + <head> + <title>%(title)</title> + <link rel="stylesheet" href="../style.css" type="text/css" /> + <meta charset="utf-8" /> + </head> + <body> + <div id="content"> + <div id="nav"> + <h2>Manual</h2> + %(nav) + </div> + <div id="toc"> + <h2>Contents</h2> + %(toc) + </div> + <div id="main"> + %(main) + </div> + </div> + </body> + </html> +]] + +-- Get manual pages. +local pages = {} +local lfs = require 'lfs' +for file in lfs.dir('manual/') do + if file:find('^%d+_.-%.md$') then pages[#pages + 1] = file end +end +table.sort(pages) +pages[#pages + 1] = '../../README.md' +pages[#pages + 1] = '../../CHANGELOG.md' +pages[#pages + 1] = '../../THANKS.md' + +-- Create the navigation list. +local navfile = 'manual/.nav.md' +local f = io.open(navfile, 'wb') +for _, page in ipairs(pages) do + local name = page:match('^%A+(.-)%.md$'):gsub('(%l)(%u)', '%1 %2') + if page:find('^%.%./') then page = page:match('^%A+(.+)$') end + f:write('* [', name, '](', page:gsub('%.md$', '.html'), ')\n') +end +f:close() +local p = io.popen('markdown "'..navfile..'"') +local nav = p:read('*all') +p:close() + +-- Write HTML. +for _, page in ipairs(pages) do + local name = page:match('^%A+(.-)%.md$'):gsub('(%l)(%u)', '%1 %2') + local p = io.popen('markdown -f toc -T "manual/'..page..'"') + local toc, main = p:read('*all'):match('^(.-\n</ul>\n)(.+)$') + p:close() + if page:find('^%.%./') then page = page:match('^%A+(.+)$') end + f = io.open('manual/'..page:gsub('%.md$', '.html'), 'wb') + local html = HTML:gsub('%%%(([^)]+)%)', { + title = name..' - Textadept Manual', nav = nav, toc = toc, main = main + }) + f:write(html) + f:close() +end diff --git a/scripts/markdowndoc.lua b/doc/markdowndoc.lua index be86b980..80918253 100644 --- a/scripts/markdowndoc.lua +++ b/doc/markdowndoc.lua @@ -5,11 +5,10 @@ local io_open, io_popen = io.open, io.popen local string_format, string_rep = string.format, string.rep local table_concat = table.concat ---- -- Markdown doclet for Luadoc. -- Requires Discount (http://www.pell.portland.or.us/~orc/Code/discount/). -- @usage luadoc -d [output_path] -doclet path/to/markdowndoc [file(s)] -module('markdowndoc') +local M = {} local NAVFILE = '%s* [%s](%s)\n' local FUNCTION = '<a id="%s" />\n### `%s` (%s)\n\n' @@ -34,11 +33,11 @@ local HTML = [[ <body> <div id="content"> <div id="nav"> - <div class="title">Modules</div> + <h2>Modules</h2> %(nav) </div> <div id="toc"> - <div class="title">Contents</div> + <h2>Contents</h2> %(toc) </div> <div id="main"> @@ -106,7 +105,7 @@ end -- Called by LuaDoc to process a doc object. -- @param doc The LuaDoc doc object. -function start(doc) +function M.start(doc) local modules, files = doc.modules, doc.files -- Create the navigation list. @@ -120,7 +119,8 @@ function start(doc) end h[#h + 1] = self end - local navfile = options.output_dir..'/api/.nav.md' + (require 'lfs').mkdir(M.options.output_dir..'/api') + local navfile = M.options.output_dir..'/api/.nav.md' local f = io_open(navfile, 'wb') write_nav(f, hierarchy) f:close() @@ -138,7 +138,7 @@ function start(doc) local module = modules[name] local filename = filedocs[module.doc] - local mdfile = options.output_dir..'/api/'..name..'.md' + local mdfile = M.options.output_dir..'/api/'..name..'.md' local f = io_open(mdfile, 'wb') -- Write the header and description. @@ -211,7 +211,7 @@ function start(doc) local toc, main = p:read('*all'):match('^(.-\n</ul>\n)(.+)$') p:close() toc = toc:gsub('(<a.-)%b()(</a>)', '%1%2') -- strip function parameters - f = io_open(options.output_dir..'/api/'..name..'.html', 'wb') + 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 }) @@ -219,3 +219,5 @@ function start(doc) f:close() end end + +return M diff --git a/scripts/adeptsensedoc.lua b/modules/lua/adeptsensedoc.lua index e18a4fb4..89379ea6 100644 --- a/scripts/adeptsensedoc.lua +++ b/modules/lua/adeptsensedoc.lua @@ -1,16 +1,17 @@ -- Copyright 2007-2012 Mitchell mitchell.att.foicica.com. See LICENSE. ---- -- Adeptsense doclet for LuaDoc. -- This module is used by LuaDoc to create an adeptsense for Lua with a fake -- ctags file and an api file. +-- To preserve formatting, the included `luadoc.patch` file must be applied to +-- your instance of LuaDoc. It will not affect the look of HTML web pages, only +-- the look of plain-text Adeptsense api files. -- Since LuaDoc does not recognize module fields, this doclet parses the Lua -- modules for comments of the form "-- * `field_name`" to generate a field tag -- and apidoc. Multiple line comments for fields must be indented flush with --- `field_name` (3 spaces). Indenting more than this preserves formatting in the --- apidoc. +-- `field_name` (3 spaces). -- @usage luadoc -d [output_path] -doclet path/to/adeptsensedoc [file(s)] -module('adeptsensedoc', package.seeall) +local M = {} local CTAGS_FMT = '%s\t_\t0;"\t%s\t%s' local string_format = string.format @@ -86,7 +87,7 @@ end -- Called by LuaDoc to process a doc object. -- @param doc The LuaDoc doc object. -function start(doc) +function M.start(doc) -- require 'luarocks.require' -- local profiler = require 'profiler' -- profiler.start() @@ -115,7 +116,7 @@ function start(doc) -- Parse out module fields (-- * `FIELD`: doc) and insert them into the -- module's LuaDoc. for _, file in ipairs(doc.files) do - local module, field, docs + local module_name, field, docs -- Adds the field to its module's LuaDoc. local function add_field() local doc = table.concat(docs, '\n') @@ -138,14 +139,14 @@ function start(doc) for line in f:lines() do if not field and line:find('^module%(') then -- Get the module's name to add the parsed fields to. - module = line:match("^module%('([^']+)'") + module_name = line:match("^module%('([^']+)'") elseif line:find('^%-%- %* `') then -- New field; if another field was parsed right before this one, add -- the former field to its module's LuaDoc. if field then add_field() end field, docs = {}, {} local name, doc = line:match('^%-%- %* `([^`]+)`([^\r\n]*)') - field.module = name:match('^_G%.(.-)%.[^%.]+$') or module or + field.module = name:match('^_G%.(.-)%.[^%.]+$') or module_name or name:match('^[^%.]+') field.name = name:match('[^%.]+$') if doc ~= '' then @@ -216,14 +217,14 @@ function start(doc) end table.sort(ctags) table.sort(apidoc) - local f = io.open(options.output_dir..'/tags', 'w') + local f = io.open(M.options.output_dir..'/tags', 'w') f:write(table.concat(ctags, '\n')) f:close() - f = io.open(options.output_dir..'api', 'w') + f = io.open(M.options.output_dir..'api', 'w') f:write(table.concat(apidoc, '\n')) f:close() -- profiler.stop() end -return _M +return M diff --git a/scripts/luadoc.patch b/modules/lua/luadoc.patch index 175b5942..175b5942 100644 --- a/scripts/luadoc.patch +++ b/modules/lua/luadoc.patch diff --git a/scripts/update_doc b/scripts/update_doc deleted file mode 100755 index ee824678..00000000 --- a/scripts/update_doc +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/lua --- Copyright 2007-2012 Mitchell mitchell.att.foicica.com. 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. -if luadoc then - os.execute('rm -r ../doc/api/*') - os.execute('luadoc -d ../doc -doclet markdowndoc '.. - '../modules ../core ../lexers/lexer.lua') -end - --- Generate the Manual. -if manual then - local HTML = [[ - <!doctype html> - <html> - <head> - <title>%(title)</title> - <link rel="stylesheet" href="../style.css" type="text/css" /> - <meta charset="utf-8" /> - </head> - <body> - <div id="content"> - <div id="nav"> - <div class="title">Manual</div> - %(nav) - </div> - <div id="toc"> - <div class="title">Contents</div> - %(toc) - </div> - <div id="main"> - %(main) - </div> - </div> - </body> - </html> - ]] - - -- Get manual pages. - local pages = {} - local lfs = require 'lfs' - for file in lfs.dir('../doc/manual/') do - if file:find('^%d+_.-%.md$') then pages[#pages + 1] = file end - end - table.sort(pages) - pages[#pages + 1] = '../../README.md' - pages[#pages + 1] = '../../CHANGELOG.md' - pages[#pages + 1] = '../../THANKS.md' - - -- Create the navigation list. - local navfile = '../doc/manual/.nav.md' - local f = io.open(navfile, 'wb') - for _, page in ipairs(pages) do - local name = page:match('^%A+(.-)%.md$'):gsub('(%l)(%u)', '%1 %2') - if page:find('^%.%./') then page = page:match('^%A+(.+)$') end - f:write('* [', name, '](', page:gsub('%.md$', '.html'), ')\n') - end - f:close() - local p = io.popen('markdown "'..navfile..'"') - local nav = p:read('*all') - p:close() - - -- Write HTML. - for _, page in ipairs(pages) do - local name = page:match('^%A+(.-)%.md$'):gsub('(%l)(%u)', '%1 %2') - local p = io.popen('markdown -f toc -T "../doc/manual/'..page..'"') - local toc, main = p:read('*all'):match('^(.-\n</ul>\n)(.+)$') - p:close() - if page:find('^%.%./') then page = page:match('^%A+(.+)$') end - f = io.open('../doc/manual/'..page:gsub('%.md$', '.html'), 'wb') - local html = HTML:gsub('%%%(([^)]+)%)', { - title = name..' - Textadept Manual', nav = nav, toc = toc, main = main - }) - f:write(html) - f:close() - end -end - --- Generate Doxygen documentation. -if doxygen then - os.execute('cd ../; doxygen Doxyfile') -end - --- Create Lua adeptsense for textadept. -if adeptsense then - os.execute('luadoc -d ../modules/lua -doclet adeptsensedoc '.. - '../modules ../core ../lexers/lexer.lua') -end diff --git a/src/Makefile b/src/Makefile index d9b3f4f5..99d70744 100644 --- a/src/Makefile +++ b/src/Makefile @@ -22,6 +22,7 @@ WINDRES = LDL = -ldl LUAJIT_LIB = libluajit.a LUAJIT_MAKE = +LUADOC = luadoc # Win32 (WIN32=1) ifdef WIN32 @@ -40,6 +41,7 @@ WINDRES = i486-mingw32-windres LDL = LUAJIT_LIB = lua51.dll LUAJIT_MAKE = HOST_CC="gcc -m32" CROSS=i486-mingw32- TARGET_SYS=Windows +LUADOC = luadoc_start.bat endif # Mac OSX (OSX=1) @@ -61,6 +63,7 @@ WINDRES = LDL = LUAJIT_LIB = libluajit.a LUAJIT_MAKE = +LUADOC = luadoc endif # No debugging unless DEBUG=1. @@ -177,6 +180,19 @@ clean: rm -f ../$(TEXTADEPT) *.o *.a *.dll cd luajit && make clean +doc: manual luadoc adeptsense doxygen +manual: + cd ../doc && lua gen_manual.lua +luadoc: ../modules ../core ../lexers/lexer.lua + cd ../doc && $(LUADOC) -d . -doclet markdowndoc $^ +adeptsense: ../modules ../core ../lexers/lexer.lua + cd ../modules && $(LUADOC) -d lua --doclet lua/adeptsensedoc $^ +doxygen: Doxyfile + cd ../ && doxygen $< +cleandoc: + rm -f ../doc/manual/*.html + rm -rf ../doc/api ../doc/doxygen + # Package (only for Linux x86_64) # Pass 'VERSION=[release version]' to 'make'. @@ -205,8 +221,7 @@ MODULESDIR = $(RELEASEDIR32)/modules MODULESPKG = ../releases/$(RELEASEDIR32).modules.zip release: ../$(TEXTADEPT) ../$(TEXTADEPT32) ../$(TEXTADEPTWIN32) \ - ../$(TEXTADEPTMAC) ../$(TEXTADEPTLPNG12) - sh -c 'cd ../scripts && ./update_doc' + ../$(TEXTADEPTMAC) ../$(TEXTADEPTLPNG12) doc hg archive $(RELEASEDIR32) rm $(RELEASEDIR32)/.hg* cp -r ../doc $(RELEASEDIR32) |