diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile-maint | 20 | ||||
-rw-r--r-- | SConstruct | 40 | ||||
-rw-r--r-- | canon.st | 24 | ||||
-rwxr-xr-x | macro.py | 25 | ||||
-rwxr-xr-x | macro2html.py | 123 | ||||
-rw-r--r-- | markdown.st | 34 |
7 files changed, 132 insertions, 137 deletions
@@ -4,9 +4,6 @@ # byte-compiled version of the python module /macro.pyc -# build system meta-data -/.sconsign.* - # the html tree is maintained in a separate, CVS-based repository /html/* diff --git a/Makefile-maint b/Makefile-maint index 59f2098..f083973 100644 --- a/Makefile-maint +++ b/Makefile-maint @@ -2,15 +2,16 @@ srcdir := . m4dir := $(srcdir)/m4 +htmldir := $(srcdir)/html STAGEDIR := $(srcdir)/stage M4_FILES := $(wildcard $(m4dir)/*.m4) MACROS := $(patsubst $(m4dir)/%.m4,%, $(M4_FILES)) CANON_M4_FILES := $(patsubst %,$(STAGEDIR)/%.m4,$(MACROS)) -MARKDOWN_FILES := $(patsubst %,$(STAGEDIR)/%.mdown,$(MACROS)) -HTML_FILES := $(patsubst %,$(STAGEDIR)/%.html,$(MACROS)) +RAW_HTML_FILES := $(patsubst %,$(STAGEDIR)/%.html,$(MACROS)) +HTML_FILES := $(patsubst %,$(htmldir)/%.html,$(MACROS)) -GENERATED_FILES = $(CANON_M4_FILES) $(MARKDOWN_FILES) $(HTML_FILES) +GENERATED_FILES = $(HTML_FILES) CLEAN_FILES = $(GENERATED_FILES) $(STAGEDIR)/.dirCreated $(STAGEDIR)/autoconf-archive.css .SECONDARY: $(GENERATED_FILES) @@ -18,15 +19,12 @@ CLEAN_FILES = $(GENERATED_FILES) $(STAGEDIR)/.dirCreated $(STAGEDIR)/autoconf-ar all: $(HTML_FILES) -$(STAGEDIR)/%.m4 : $(m4dir)/%.m4 $(STAGEDIR)/.dirCreated $(srcdir)/macro.py $(srcdir)/canon.st - @$(srcdir)/macro.py --template-lexer=angle-bracket --input-encoding=latin1 --output-encoding=latin1 --output-dir=$(STAGEDIR) --output-suffix=.m4 $(srcdir)/canon.st $< - @diff -ub $@ $< || (rm $@; exit 1) +$(STAGEDIR)/%.html : $(m4dir)/%.m4 $(STAGEDIR)/.dirCreated $(srcdir)/macro.py $(srcdir)/macro2html.py + @$(srcdir)/macro2html.py --input-encoding=latin-1 --output-encoding=latin-1 --output-dir=$(STAGEDIR) --output-suffix=.html $< -$(STAGEDIR)/%.mdown : $(STAGEDIR)/%.m4 $(srcdir)/macro.py $(srcdir)/markdown.st - @$(srcdir)/macro.py --template-lexer=angle-bracket --input-encoding=latin1 --output-encoding=latin1 --output-dir=$(STAGEDIR) --output-suffix=.mdown $(srcdir)/markdown.st $< - -$(STAGEDIR)/%.html : $(STAGEDIR)/%.mdown $(STAGEDIR)/autoconf-archive.css $(srcdir)/header.html - @pandoc --standalone --title-prefix='Autoconf Macro: ' --include-before-body=$(srcdir)/header.html --css=autoconf-archive.css --from=markdown --to=html -o $@ $< +$(htmldir)/%.html : $(STAGEDIR)/%.html + @echo publish $* + @tidy -quiet -ascii --indent yes --indent-spaces 1 --tidy-mark no -wrap 80 --hide-comments yes $< >$@ $(STAGEDIR)/autoconf-archive.css : $(srcdir)/autoconf-archive.css $(STAGEDIR)/.dirCreated @cp -v $< $@ diff --git a/SConstruct b/SConstruct deleted file mode 100644 index 1c3408a..0000000 --- a/SConstruct +++ /dev/null @@ -1,40 +0,0 @@ -# Build the autoconf archive - -from SCons.Script import * -import os.path as path -from macro import Macro, writeFile -from stringtemplate3 import StringTemplateGroup, StringTemplate - -__formatters = { "canon.st" : StringTemplateGroup(file = open("canon.st")) - , "markdown.st" : StringTemplateGroup(file = open("markdown.st")) - } - -def formatMacro(target, source, env): - assert len(target) == 1 - outFile = target[0] - (m4File,stFile) = source - m = Macro(m4File.path, env["inputEncoding"]) - f = __formatters[stFile.path].getInstanceOf("canon") - for (k,v) in m.__dict__.items(): - f[k] = v - writeFile(outFile.path, env["outputEncoding"], f.toString().strip() + '\n') - -##### Build Script ##### - -m4dir = "m4" -stagedir = "stage" - -cssfile = "autoconf-archive.css" -cssfile = Command(path.join(stagedir, cssfile), cssfile, Copy("$TARGET", "$SOURCE")) - -for m in Glob(path.join(m4dir, "*.m4")): - t = path.join(stagedir, path.basename(m.path)) - s = Command(t, [m, "canon.st"], formatMacro, inputEncoding = "latin1", outputEncoding = "latin1") - AddPostAction(s, "@diff -u $SOURCE $TARGET") - t = path.splitext(t)[0] + ".mdown" - s = Command(t, [s, "markdown.st"], formatMacro, inputEncoding = "latin1", outputEncoding = "utf-8") - t = path.splitext(t)[0] + ".html" - s = Command(t, [s, cssfile, "header.html"], "pandoc --standalone --title-prefix='Autoconf Macro: ' --include-before-body=header.html --css=autoconf-archive.css --from=markdown --to=html -o $TARGET $SOURCE") - AddPostAction(s, "@tidy -quiet -utf8 -modify --indent yes --indent-spaces 1 --tidy-mark no -wrap 80 --hide-comments yes $TARGET") - -Clean(".", [stagedir]) diff --git a/canon.st b/canon.st deleted file mode 100644 index 13092a3..0000000 --- a/canon.st +++ /dev/null @@ -1,24 +0,0 @@ -group formatter; - -copyrightLine(author) ::= << -Copyright (c) <author.year> <author.name><if(author.email)> \<<author.email>\><endif> ->> - -canon(m4header, name, synopsis, description, authors, license, body) ::= << -<m4header># -# SYNOPSIS -# -# <synopsis; separator="\n# "> -# -# DESCRIPTION -# -# <description:{e| <e; separator="\n# ">}; separator="\n#\n# "> -# -# LICENSE -# -# <authors:copyrightLine(); separator="\n# "> -# -# <license:{e| <e; separator="\n# ">}; separator="\n#\n# "> - -<body; separator="\n"> ->> @@ -110,28 +110,3 @@ class Macro: def __repr__(self): return repr(self.__dict__) - -if __name__ == "__main__": - from stringtemplate3 import StringTemplateGroup, StringTemplate - from optparse import OptionParser - - opts = OptionParser() - opts.add_option('', "--input-encoding", dest = "inEncode", default = "latin1") - opts.add_option('', "--output-encoding", dest = "outEncode", default = "latin1") - opts.add_option('', "--template-lexer", dest = "lexer", default = "angle-bracket") - opts.add_option('', "--output-dir", dest = "outDir", default = "stage") - opts.add_option('', "--output-suffix", dest = "suffix", default = ".m4") - (options, args) = opts.parse_args() - stFile = args.pop(0) - formatter = StringTemplateGroup(file = open(stFile), lexer = options.lexer) - for m4File in args: - (stem,suff) = path.splitext(path.basename(m4File)) - assert suff == ".m4" - outFile = path.join(options.outDir, stem + options.suffix) - assert outFile != m4File - print m4File, "->", outFile - m = Macro(m4File, options.inEncode) - f = formatter.getInstanceOf("canon") - for (k,v) in m.__dict__.items(): - f[k] = v - writeFile(outFile, options.outEncode, f.toString().strip() + '\n') diff --git a/macro2html.py b/macro2html.py new file mode 100755 index 0000000..3652670 --- /dev/null +++ b/macro2html.py @@ -0,0 +1,123 @@ +#! /usr/bin/env python + +assert __name__ == "__main__" + +import os.path as path +from macro import Macro, writeFile +from optparse import OptionParser + +opts = OptionParser() +opts.add_option('-v', "--verbose", dest = "verbose", default = False, action = "store_true") +opts.add_option('', "--input-encoding", dest = "inEncode", default = "latin-1") +opts.add_option('', "--output-encoding", dest = "outEncode", default = "latin1") +opts.add_option('', "--output-dir", dest = "outDir", default = "stage") +opts.add_option('', "--output-suffix", dest = "suffix", default = ".html") +(options, args) = opts.parse_args() +# www.nongnu.org/autoconf-archive/ +tmpl = """\ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" +"http://www.w3.org/TR/html4/strict.dtd"> +<html lang="en"> + <head> + <title> + Autoconf Macro: %(name)s + </title> + <link rel="stylesheet" type="text/css" href="autoconf-archive.css"> + <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> + </head> + <body> + <table summary="web navigation" style="width:100%%;"> + <tbody> + <tr> + <td style="width:33%%;" align="center" valign="top"> + <a href="index.html">Autoconf Archive</a> + </td> + <td style="width:33%%;" align="center" valign="top"> + <a href="macros-by-category.html">Macros by Category</a> + </td> + <td style="width:33%%;" align="center" valign="top"> + <form method="get" action="http://www.google.com/search"> + <div> + <input name="sitesearch" value="autoconf-archive.cryp.to" type= + "hidden">Search: <input name="q" maxlength="255" type="text"> + </div> + </form> + </td> + </tr> + </tbody> + </table> + <hr> + <h1> + %(name)s + </h1> + <h2> + SYNOPSIS + </h2> + <p class="indent" style="white-space:nowrap;"> +%(synopsis)s + </p> + <h2> + DESCRIPTION + </h2> + <div class="indent"> +%(description)s + </div> + <h2> + SOURCE CODE + </h2> + <p class="indent"> + Download <a href= + "http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=%(name)s.m4"> + %(name)s.m4</a> or browse the <a href= + "http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=history;f=%(name)s.m4"> + revision history</a>. + </p> + <h2> + LICENSE + </h2> + <div class="indent"> + <p style="white-space:nowrap;"> +%(authors)s + </p> +%(license)s + </div> + </body> +</html> +""" + +def quoteHtml(buf): + return buf.replace('&', "&").replace('<', "<").replace('>', ">") + +def formatParagraph(para): + assert para + assert para[0] + assert para[0][0] + if para[0][0].isspace(): + return "<pre>%s</pre>" % quoteHtml('\n'.join(para)) + else: + return "<p>%s</p>" % quoteHtml('\n'.join(para)) + +def formatAuthor(a): + assert a + a["year"] = quoteHtml(a["year"]) + a["name"] = quoteHtml(a["name"]) + if "email" in a: + a["email"] = quoteHtml(a["email"]) + return "Copyright © %(year)s %(name)s <%(email)s>" % a + else: + return "Copyright © %(year)s %(name)s" % a + +for m4File in args: + (stem,suff) = path.splitext(path.basename(m4File)) + assert suff == ".m4" + outFile = path.join(options.outDir, stem + options.suffix) + assert outFile != m4File + if options.verbose: + print m4File, "->", outFile + m = Macro(m4File, options.inEncode) + m.synopsis = "<br>\n".join([ "<code>%s</code>" % quoteHtml(l) for l in m.synopsis ]) + m.description = '\n\n'.join(map(formatParagraph, m.description)) + m.description = m.description.replace("</pre>\n\n<pre>", "\n\n") + m.authors = "<br>\n".join(map(formatAuthor, m.authors)) + m.license = '\n'.join(map(formatParagraph, m.license)) + writeFile(outFile, options.outEncode, tmpl % m.__dict__) diff --git a/markdown.st b/markdown.st deleted file mode 100644 index ee53004..0000000 --- a/markdown.st +++ /dev/null @@ -1,34 +0,0 @@ -group formatter; - -copyrightLine(author) ::= << -Copyright (c) <author.year> <author.name><if(author.email)> \\\<<author.email>\\\><endif> ->> - -canon(m4header, name, synopsis, description, authors, license, body) ::= << -% <name> -% <authors:{e|<e.name>}; separator=", "> -% - -SYNOPSIS -======== - - <synopsis; separator="\n"> - -DESCRIPTION -=========== - - <description:{e| <e; separator="\n">}; separator="\n\n"> - -SOURCE CODE -=========== - -Download [ac_check_class.m4](http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=<name>.m4) -or browse the [revision history](http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=history;f=<name>.m4). - -LICENSE -======= - -<authors:copyrightLine(); separator=" \n"> - -<license:{e| <e; separator="\n">}; separator="\n\n"> ->> |