From 96c85498c019e381d0aeed2e33e626563563ea8c Mon Sep 17 00:00:00 2001
From: mitchell <70453897+667e-11@users.noreply.github.com>
Date: Wed, 7 Mar 2012 09:28:43 -0500
Subject: Documentation overhaul with Discount (Markdown implementation). The
standard LuaDoc template is no longer used. Instead, the new
`scripts/markdowndoc.lua` has the template for LuaDoc and
`scripts/update_doc` has the template for the Manual. Also added README,
CHANGELOG, and THANKS files.
---
scripts/update_doc | 156 ++++++++++++++++++++---------------------------------
1 file changed, 59 insertions(+), 97 deletions(-)
(limited to 'scripts/update_doc')
diff --git a/scripts/update_doc b/scripts/update_doc
index 74d1dd72..ccd42444 100755
--- a/scripts/update_doc
+++ b/scripts/update_doc
@@ -23,115 +23,77 @@ end
-- Generate LuaDoc.
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]+)')
- if match and match:find('^%s*[*+] ') then match = match..' ' end
- 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/MultiMarkdown.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
- p:close()
-
- -- Modify default CSS.
- os.execute("sed -i 's/pre.example/pre, pre.example/;' ../doc/luadoc.css")
+ 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
- p = io.popen('ls -1 ../doc/manual/*.md')
- for mdfile in p:lines() do
- local htmlfile = mdfile:match('^(.+).md$')..'.html'
- html = [[
-
-
+ local HTML = [[
+
+
- Textadept Manual
-
-
+ %(title)
+
+
-
-
-
-
-
- %sidebar%
-
-
-
-
- %content%
-
-
-
-
-
-
-
+
+
+
Manual
+ %(nav)
+
+
+
Contents
+ %(toc)
+
+
+ %(main)
+
+
-
- ]]
-
- local sidebar_md = io.popen('../doc/MultiMarkdown.pl ../doc/sidebar.md')
- html = html:gsub('%%sidebar%%', sidebar_md:read('*all'))
- sidebar_md:close()
- local content_md = io.popen('../doc/MultiMarkdown.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()
+
+ ]]
+
+ -- 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()
- local f = io.open(htmlfile, 'w')
+ -- 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\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
- p:close()
end
-- Generate Doxygen documentation.
--
cgit v1.2.3