[Synopsis-changes] Synopsis/Synopsis/Synopsis/dist/command build_doc.py,1.1,1.2
Stefan Seefeld stefan at synopsis.fresco.orgThu Oct 9 05:50:53 UTC 2003
- Previous message: [Synopsis-changes] Synopsis/Synopsis/docs/RefManual index.html,1.4,1.5
- Next message: [Synopsis-changes] Synopsis/Synopsis/Synopsis/dist/command build_doc.py,1.2,1.3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvs/synopsis/Synopsis/Synopsis/dist/command
In directory frida:/tmp/cvs-serv13611/Synopsis/dist/command
Modified Files:
build_doc.py
Log Message:
more work on build_doc command
Index: build_doc.py
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/dist/command/build_doc.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -d -r1.1 -r1.2
--- build_doc.py 18 Sep 2003 02:54:14 -0000 1.1
+++ build_doc.py 9 Oct 2003 05:50:51 -0000 1.2
@@ -1,16 +1,151 @@
-import os, sys, string
+import os, sys, string, re, stat
+from stat import *
+import os.path
+from shutil import *
+import glob
from distutils.command import build
-from distutils.dir_util import mkpath
from distutils.spawn import spawn, find_executable
-from shutil import *
+from distutils.dep_util import newer, newer_group
+from distutils.dir_util import copy_tree, remove_tree
+from distutils.file_util import copy_file
+
+
+class Target:
+ def __init__(self, cmd, rule, dependencies, **kw):
+
+ self.cmd = cmd
+ self.rule = rule
+ self.dependencies = dependencies
+ self.dict = kw
+ self.mtime = 0
+ # assume output is a single file
+ if kw.has_key('output') and os.path.exists(kw['output']):
+ self.mtime = os.stat(kw['output'])[ST_MTIME]
+
+ def announce(self, msg):
+ self.cmd.announce(msg)
+
+ def needs_update(self):
+ """Return true if any of the dependencies was modified after self"""
+ latest = 0
+ for d in self.dependencies:
+ if isinstance(d, Target):
+ if d.mtime > latest: latest = d.mtime
+ else: # assume a filename
+ mtime = os.stat(d)[ST_MTIME]
+ if mtime > latest: latest = mtime
+ # always consider input as an implicit dependency
+ if self.dict.has_key('input'):
+ for i in self.dict['input']:
+ mtime = os.stat(i)[ST_MTIME]
+ if mtime > latest: latest = mtime
+ return latest > self.mtime
+
+ def process(self):
+ for d in self.dependencies:
+ d.process()
+ if self.rule and self.needs_update():
+ dict = self.dict.copy()
+ # if input is given, it is a list, so convert it to a string here
+ if self.dict.has_key('input'):
+ dict['input'] = string.join(self.dict['input'])
+ command = self.rule%dict
+ self.announce(command)
+ spawn(string.split(command))
class build_doc(build.build):
+ """Defines the specific procedure to build synopsis' documentation."""
description = "build documentation"
def run(self):
+ """Run this command, i.e. do the actual document generation."""
+ self.manual()
+
+ def manual(self):
+
+ synopsis = "synopsis -c config.py"
+ py_sources = []
+ hh_sources = []
+ cc_sources = []
+ py = re.compile(r'.*\.py$')
+ hh = re.compile(r'.*\.hh$')
+ cc = re.compile(r'.*\.cc$')
+ def add_py(arg, dirname, names):
+ #exclude the dist stuff for now
+ if dirname == 'Synopsis/dist/command':
+ return
+ arg.extend(map(lambda f, d=dirname: os.path.join(d, f),
+ filter(lambda f, re=py: re.match(f), names)))
+ def add_hh(arg, dirname, names):
+ arg.extend(map(lambda f, d=dirname: os.path.join(d, f),
+ filter(lambda f, re=hh: re.match(f), names)))
+ def add_cc(arg, dirname, names):
+ arg.extend(map(lambda f, d=dirname: os.path.join(d, f),
+ filter(lambda f, re=cc: re.match(f), names)))
+
+ os.path.walk('Synopsis', add_py, py_sources)
+
+ cwd = os.getcwd()
+ os.chdir(os.path.normpath('docs/RefManual'))
+ py_syns = map(lambda f,s=self:Target(s, synopsis + " -Wc,parser=Py,linker=Py -o %(output)s %(input)s",
+ [],
+ output=re.sub('\.py$', '.syn', f),
+ input=[os.path.join('..','..',f)]),
+ py_sources)
+ py_syn = Target(self, synopsis + " -o %(output)s %(input)s", py_syns,
+ output='py.syn', input=map(lambda f:re.sub('\.py$', '.syn', f),
+ py_sources))
+ core_ast_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Core::AST' -o %(output)s %(input)%",
+ [py_syn], output="core-ast.syn", input=['py.syn'])
+ core_type_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Core::Type' -o %(output)s %(input)%",
+ [py_syn], output="core-type.syn", input=['py.syn'])
+ core_util_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Core::Util' -o %(output)s %(input)%",
+ [py_syn], output="core-util.syn", input=['py.syn'])
+ parser_cxx_py_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Parser::C++' -o %(output)s %(input)%",
+ [py_syn], output="parser-c++-py.syn", input=['py.syn'])
+ parser_cxx_cpp_syn = Target(self, synopsis + " -Wc,linker=All -o %(output)s %(input)%",
+ [py_syn], output="parser-c++-cpp.syn", input=['py.syn'])
+ parser_cxx_syn = Target(self, synopsis + " -Wc,linker=All -o %(output)s %(input)%",
+ [parser_cxx_py_syn, parser_cxx_cpp_syn], output="parser-c++.syn", input=['py.syn'])
+ parser_idl_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Parser::IDL' -o %(output)s %(input)%",
+ [py_syn], output="parser-idl.syn", input=['py.syn'])
+ parser_py_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Parser::Python' -o %(output)s %(input)%",
+ [py_syn], output="parser-py.syn", input=['py.syn'])
+ linker_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Linker' -o %(output)s %(input)%",
+ [py_syn], output="linker.syn", input=['py.syn'])
+ formatter_ascii_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::ASCII' -o %(output)s %(input)%",
+ [py_syn], output="formatter-ascii.syn", input=['py.syn'])
+ formatter_html_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::HTML' -o %(output)s %(input)%",
+ [py_syn], output="formatter-html.syn", input=['py.syn'])
+ formatter_dump_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::DUMP' -o %(output)s %(input)%",
+ [py_syn], output="formatter-dump.syn", input=['py.syn'])
+ formatter_dia_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::Dia' -o %(output)s %(input)%",
+ [py_syn], output="formatter-dia.syn", input=['py.syn'])
+ formatter_docbook_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::Docbook' -o %(output)s %(input)%",
+ [py_syn], output="formatter-docbook.syn", input=['py.syn'])
+ formatter_dot_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::Dot' -o %(output)s %(input)%",
+ [py_syn], output="formatter-dot.syn", input=['py.syn'])
+ formatter_html_simple_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::HTML_Simple' -o %(output)s %(input)%",
+ [py_syn], output="formatter-html-simple.syn", input=['py.syn'])
+ formatter_texi_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::TexInfo' -o %(output)s %(input)%",
+ [py_syn], output="formatter-texi.syn", input=['py.syn'])
+
+ all_syn = Target(self, synopsis + " -Wc,linker=All -o %(output)s %(input)s",
+ [py_syn], output="all.syn", input=['py.syn'])
+
+ html = Target(self, synopsis + " -Wc,formatter=HTML %(input)s",
+ [all_syn], output="html", input=['all.syn'])
+
+ html.process()
+ #for t in py_syn:
+ # t.process()
+ os.chdir(cwd)
+
+
+ def tutorial(self):
xmlto = find_executable('xmlto')
if not xmlto:
self.announce("cannot build html docs without 'xmlto'")
- Previous message: [Synopsis-changes] Synopsis/Synopsis/docs/RefManual index.html,1.4,1.5
- Next message: [Synopsis-changes] Synopsis/Synopsis/Synopsis/dist/command build_doc.py,1.2,1.3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-changes mailing list