diff options
author | 2020-09-08 23:11:24 -0400 | |
---|---|---|
committer | 2020-09-08 23:11:24 -0400 | |
commit | 60e98cdfdacc7f2973e557fc6d0b28e6f9a6b139 (patch) | |
tree | 72c9b1f686c0f3c07cc209d4b91bcfa017ff2d16 | |
parent | 0ecb986767b5aeec567f01241b0c06f67c28433c (diff) | |
download | textadept-60e98cdfdacc7f2973e557fc6d0b28e6f9a6b139.tar.gz textadept-60e98cdfdacc7f2973e557fc6d0b28e6f9a6b139.zip |
Changed processing pipeline for manually generating documentation.
-rw-r--r-- | docs/_layouts/default.html | 34 | ||||
-rwxr-xr-x | scripts/fill_layout.lua | 19 | ||||
-rwxr-xr-x | scripts/gen_doc.lua | 23 | ||||
-rw-r--r-- | src/Makefile | 7 |
4 files changed, 58 insertions, 25 deletions
diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html new file mode 100644 index 00000000..84fb9667 --- /dev/null +++ b/docs/_layouts/default.html @@ -0,0 +1,34 @@ +<!doctype html> +<html lang="en"> + <head> + <title>{{ page.title }}</title> + <link rel="stylesheet" href="style.css" type="text/css" /> + <link rel="icon" href="icon.png" type="image/png" /> + <meta charset="utf-8" /> + </head> + <body> + <div id="content"> + <div id="header"> + <h1><img src="images/icon.png" alt="" /> Textadept</h1> + <ul> + <li><a href="index.html">Home</a> |</li> + <li><a href="http://foicica.com/textadept/download">Download</a> |</li> + <li><a href="media.html#book">Book</a> |</li> + <li><a href="manual.html">Manual</a> |</li> + <li><a href="api.html">API</a> |</li> + <li><a href="http://foicica.com/hg/textadept">Source</a> |</li> + <li><a href="http://foicica.com/hg/textadept_modules">Language Modules</a> |</li> + <li><a href="http://foicica.com/stats.html#Textadept">Stats</a> |</li> + <li><a href="http://foicica.com/wiki/textadept">Wiki</a> |</li> + <li><a href="http://foicica.com/lists">Mailing List</a></li> + </ul> + </div> + <div id="main"> + {{ content }} + </div> + <div id="footer"> + <p style="text-align:center;"> © 2007-2020 <a href="http://foicica.com">Mitchell</a> mitchell.att.foicica.com</p> + </div> + </div> + </body> +</html> diff --git a/scripts/fill_layout.lua b/scripts/fill_layout.lua new file mode 100755 index 00000000..34219858 --- /dev/null +++ b/scripts/fill_layout.lua @@ -0,0 +1,19 @@ +#!/usr/bin/lua +-- Filters the given file through markdown, inserts it into the template +-- specified by stdin by replacing simple {{ variable }} tags, and outputs the +-- result to stdout. + +-- Filter the file through markdown using TOC generation in order to get header +-- anchors, but ignore the actual TOC. +local name = arg[1] +local f = io.open(name, 'r') +local markdown = f:read('*a') +f:close() +local p = io.popen('markdown -f toc -T ' .. name) +local html = p:read('*a'):match('^.-\n</ul>\n(.+)$') +p:close() + +-- Fill in HTML layout (stdin) with markdown output and print the result. +local title, content = '{{ page.title }}', '{{ content }}' +io.write(io.stdin:read('*a'):gsub(title, html:match('<h%d.->([^<]+)')): + gsub(content, (html:gsub('%%', '%%%%')))) diff --git a/scripts/gen_doc.lua b/scripts/gen_doc.lua deleted file mode 100755 index fff69a12..00000000 --- a/scripts/gen_doc.lua +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/lua --- Filters the given file through markdown, replaces simple {{ variable }} --- templates, and saves the result to an HTML file of the same name for offline --- documentation generation. - --- Filter the file through markdown using TOC generation in order to get header --- anchors, but ignore the actual TOC. -local name = arg[1] -local f = io.open(name, 'r') -local markdown = f:read('*a') -f:close() -local p = io.popen('markdown -f toc -T ' .. name) -local html = p:read('*a'):match('^.-\n</ul>\n(.+)$') -p:close() - --- Fill in HTML layout with markdown content. -f = io.open('../docs/_layouts/default.html') -html = f:read('*a'):gsub('{{ page.title }}', html:match('<h%d.->([^<]+)')): - gsub('{{ content }}', (html:gsub('%%', '%%%%'))) -f:close() - --- Write to HTML file. -io.open(name:gsub('^(.+)%.md$', '%1.html'), 'wb'):write(html):close() diff --git a/src/Makefile b/src/Makefile index 8e0a2b98..2ba21b2b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -270,8 +270,11 @@ clean: ; rm -f *.o ../textadept* ta_home = $(shell dirname `pwd`) docs: manual luadoc -manual: $(addprefix ../docs/,manual.md changelog.md faq.md media.md thanks.md) - for file in $^; do ../scripts/gen_doc.lua $$file; done +manual: $(addprefix ../docs/,manual.md changelog.md faq.md media.md thanks.md) \ + | ../docs/_layouts/default.html + for file in $(basename $^); do \ + cat $| | ../scripts/fill_layout.lua $$file.md > $$file.html; \ + done sed -i -e "s/Textadept Manual/Textadept $(subst _, ,$(version)) Manual/;" \ ../docs/manual.html luadoc: ../modules ../core ../lexers/lexer.lua | ../modules/lua/lua.luadoc |