retroforth/tools/generate-html-docs.retro
crc e4a838d588 generate & include html documentation files
FossilOrigin-Name: 03f8a1f5293ceeb245b4e6315578c114c69eb4341027fad8eba5ec8c8dbca5fa
2021-01-21 12:40:28 +00:00

81 lines
1.5 KiB
Forth
Executable file

#!/usr/bin/env retro
This tool is intended to be used to create an HTML version of the
standard documentation.
Our structure will look like:
Book Root Directory
|-- index.html
|-- chapters/...
Begin by defining some helper functions for writing to a
file.
~~~
'tools/book-chapters.retro include
'FID var
:file:s:put [ @FID file:write ] s:for-each ;
:file:nl ASCII:CR @FID file:write ;
:unix:mkdir 'mkdir_-p_%s s:format unix:system ;
~~~
Create the directories needed.
~~~
'Create_directories s:put nl
{ 'chapters
'chapters/building
'chapters/general
'chapters/internals
'chapters/tech-notes
'chapters/techniques
'chapters/toolchain
'chapters/toolchain/info
'chapters/toolchain/man
'html
} [ dup tab s:put nl unix:mkdir ] a:for-each
~~~
# Create the Index file
~~~
'Generate_`index.html` s:put nl
'html/index.html file:open-for-writing !FID
{ '<html>
'<head>
'____<meta_name="dtb:uid"_content="works.forth.retro-manual"/>
'____<title>Retro_Forth:_Manual</title>
'</head>
'<body>
'<h1>Retro_Forth</h1>
} [ file:s:put file:nl ] a:for-each
:a:unpack [ ] a:for-each ;
TOC [ a:unpack '____&bull;_<a_href="chapters/%s.html">%s</a><br> s:format file:s:put file:nl ] a:for-each
{ '</body>
'</html>
} [ file:s:put file:nl ] a:for-each
@FID file:close
~~~
# Generate the Chapters
~~~
'Convert_chapters_to_XHTML s:put nl
'retro_tools/epub/chapters-to-xhtml.retro unix:system
~~~
# Relocate Files
~~~
'Relocate_files s:put nl
'rm_-rf_doc/html unix:system
'mv_chapters_html unix:system
'mv_html_doc unix:system
~~~