summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO28
-rw-r--r--cfg.mk6
m---------m412
-rwxr-xr-xmacro.py13
-rwxr-xr-xmacro2html.py36
5 files changed, 27 insertions, 68 deletions
diff --git a/TODO b/TODO
index 9456fc6..88bae11 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-#+TITLE: Autoconf Archive TODO -*- mode:org;coding:utf-8;fill-column:79; -*-
+#+TITLE: Autoconf Archive TODO -*- mode:org;fill-column:79; -*-
* TODO Document our new mailing lists.
@@ -21,32 +21,6 @@
been changed in Git. Other branches, like 'maint', aren't tracked; there is
only a moderate amount of traffic.
-
-* TODO Decide how to handle non-ASCII content in m4 files
-
- Several macros contain non-ASCII characters, for example:
-
- : $ grep@ Ludo m4/*.m4
- : m4/_ac_c_ifdef.m4:# Copyright (c) 2008 Ludovic Courtès <ludo@chbouib.org>
- : m4/ac_cxx_compiler_vendor.m4:# Copyright (c) 2008 Ludovic Courtès <ludo@chbouib.org>
- : m4/ac_cxx_cppflags_std_lang.m4:# Copyright (c) 2008 Ludovic Courtès <ludo@chbouib.org>
- : m4/ac_cxx_cxxflags_std_lang.m4:# Copyright (c) 2008 Ludovic Courtès <ludo@chbouib.org>
- : m4/ac_cxx_ldflags_std_lang.m4:# Copyright (c) 2008 Ludovic Courtès <ludo@chbouib.org>
- : m4/ac_libtoolize_cflags.m4:# Copyright (c) 2008 Ludovic Courtès <ludo@chbouib.org>
-
- The encoding currently in use is "latin1", but the m4 files don't expose
- that information. The situation can be improved as follows:
-
- 1) Add machine-readable charset declarations (i.e. for Emacs) to all m4
- files. (Or just to those that actually use non-ASCII?)
-
- 2) Encode all files in UTF-8, like everyone else seems to do. (But add
- charset declarations anyway?)
-
- 3) Restrict m4 files to ASCII.
-
- Pure ASCII is my favorite.
-
* TODO Figure out how to generate the AUTHORS file
The file should contain the people who committed to Git and the people who
diff --git a/cfg.mk b/cfg.mk
index cf0914d..f3b308d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -26,11 +26,11 @@ ALL_RECURSIVE_TARGETS += website
website: $(HTML_FILES)
$(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 $<
+ @$(srcdir)/macro2html.py "$<" "$@"
$(HTMLDIR)/%.html : $(STAGEDIR)/%.html
- @echo publish $*
- @tidy -quiet -ascii --indent yes --indent-spaces 1 --tidy-mark no -wrap 80 --hide-comments yes $< >$@
+ @echo generating $*.html
+ @tidy -quiet -ascii --indent yes --indent-spaces 1 --tidy-mark no -wrap 80 --hide-comments yes "$<" >"$@"
$(STAGEDIR)/.dirCreated:
@$(MKDIR_P) $(STAGEDIR)
diff --git a/m4 b/m4
-Subproject 15c3cc5e5fdd75385ec266a935dc25519754596
+Subproject ad017ae36905e9ec0e6ad17e8b73c8b70e1a0c0
diff --git a/macro.py b/macro.py
index d3fe9fa..45b06cd 100755
--- a/macro.py
+++ b/macro.py
@@ -6,14 +6,13 @@ import re
import os.path as path
import sys
import textwrap
-import encodings
-def loadFile(path, encoding):
- with closing( encodings.search_function(encoding).streamreader(open(path)) ) as fd:
+def loadFile(path):
+ with closing( open(path) ) as fd:
return fd.read()
-def writeFile(path, encoding, buffer):
- with closing( encodings.search_function(encoding).streamwriter(open(path, "w")) ) as fd:
+def writeFile(path, buffer):
+ with closing( open(path, "w") ) as fd:
fd.write(buffer)
def splitSections(buffer):
@@ -61,10 +60,10 @@ def collapseText(lines, width = 72):
return body
class Macro:
- def __init__(self, filePath, encoding):
+ def __init__(self, filePath):
self.name = path.splitext(path.basename(filePath))[0]
# header and body are separated by an empty line.
- (header,body) = loadFile(filePath, encoding).split("\n\n", 1)
+ (header,body) = loadFile(filePath).split("\n\n", 1)
self.body = body.split('\n')
# drop initial header (if present)
header = re.sub(r"^\n*# =+\n#[^\n]*\n# =+\n(#\n)+", '', header, 1)
diff --git a/macro2html.py b/macro2html.py
index 7a81316..d49d9c9 100755
--- a/macro2html.py
+++ b/macro2html.py
@@ -2,17 +2,8 @@
assert __name__ == "__main__"
-import os.path as path
+import sys
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()
tmpl = """\
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
@@ -105,17 +96,14 @@ def formatAuthor(a):
else:
return "Copyright &copy; %(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__)
+if len(sys.argv) != 3:
+ raise Exception("invalid command line syntax: %s" % ' '.join(map(repr, sys.argv)))
+(m4File,outFile) = sys.argv[1:]
+assert outFile != m4File
+m = Macro(m4File)
+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, tmpl % m.__dict__)