[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz metacode/pegboard.py metacode/uml.py metaco...
From: |
Asko Soukka |
Subject: |
[Gzz-commits] gzz metacode/pegboard.py metacode/uml.py metaco... |
Date: |
Mon, 13 Jan 2003 08:39:41 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Asko Soukka <address@hidden> 03/01/13 08:39:40
Modified files:
metacode : pegboard.py uml.py umldoc.py umlpegboard.py
umlrst.py umltool.py
doc : Gzz_Storm.rst gzz.css
doc/pegboard/raw_blocks--benja: peg.rst
doc/uml : .cvsignore
Added files:
metacode : mputils.py
doc/pegboard/coding_standard--vegai: .cvsignore
doc/pegboard/raw_blocks--benja: .cvsignore
doc/pegboard/tests_output_cleanup--vegai: .cvsignore
doc/pegboard/vob_addtolistgl--tjl: .cvsignore
doc/pegboard/vobmatcher_keymap--tjl: .cvsignore
Log message:
MP-directive, quick (text) implementation of explicit backlinks
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/mputils.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/pegboard.py.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/uml.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/umldoc.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/umlpegboard.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/umlrst.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/umltool.py.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/Gzz_Storm.rst.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/gzz.css.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/coding_standard--vegai/.cvsignore?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/raw_blocks--benja/.cvsignore?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/raw_blocks--benja/peg.rst.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/tests_output_cleanup--vegai/.cvsignore?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/vob_addtolistgl--tjl/.cvsignore?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/vobmatcher_keymap--tjl/.cvsignore?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/uml/.cvsignore.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: gzz/doc/Gzz_Storm.rst
diff -u gzz/doc/Gzz_Storm.rst:1.2 gzz/doc/Gzz_Storm.rst:1.3
--- gzz/doc/Gzz_Storm.rst:1.2 Thu Jan 9 19:23:37 2003
+++ gzz/doc/Gzz_Storm.rst Mon Jan 13 08:39:39 2003
@@ -23,7 +23,7 @@
.. _MIME: http://www.nacs.uci.edu/indiv/ehood/MIME/MIME.html
.. _cryptographic hash: http://www.rsasecurity.com/rsalabs/faq/2-1-6.html
-.. uml::
+.. uml:: stormblock
jlinkpackage gzz.storm
class Block
Index: gzz/doc/gzz.css
diff -u gzz/doc/gzz.css:1.12 gzz/doc/gzz.css:1.13
--- gzz/doc/gzz.css:1.12 Fri Jan 3 13:05:06 2003
+++ gzz/doc/gzz.css Mon Jan 13 08:39:39 2003
@@ -201,4 +201,3 @@
td.field-name {
font-weight: bold }
-
Index: gzz/doc/pegboard/raw_blocks--benja/peg.rst
diff -u gzz/doc/pegboard/raw_blocks--benja/peg.rst:1.2
gzz/doc/pegboard/raw_blocks--benja/peg.rst:1.3
--- gzz/doc/pegboard/raw_blocks--benja/peg.rst:1.2 Sun Jan 12 09:13:45 2003
+++ gzz/doc/pegboard/raw_blocks--benja/peg.rst Mon Jan 13 08:39:39 2003
@@ -4,8 +4,8 @@
:Author: Benja Fallenstein
:Date: 2003-01-12
-:Revision: $Revision: 1.2 $
-:Last-Modified: $Date: 2003/01/12 14:13:45 $
+:Revision: $Revision: 1.3 $
+:Last-Modified: $Date: 2003/01/13 13:39:39 $
:Type: Architecture
:Scope: Minor
:Status: Current
@@ -51,7 +51,7 @@
on our choice of what to put into the header).
Knowing the content's SHA-1 is important for interoperability
-with systems like `Bitzi <http://bitzi.com>`_, which provide
+with systems like `Bitzi <http://bitzi.com>`__, which provide
ratings for digital data identified by its content hash:
We want to retrieve the Bitzi rating for the content of
some Storm block. Forming a Storm id from the content's hash
Index: gzz/doc/uml/.cvsignore
diff -u gzz/doc/uml/.cvsignore:1.2 gzz/doc/uml/.cvsignore:1.3
--- gzz/doc/uml/.cvsignore:1.2 Wed Dec 18 06:37:00 2002
+++ gzz/doc/uml/.cvsignore Mon Jan 13 08:39:39 2003
@@ -7,3 +7,4 @@
*.gen.mp
*.gen.png
*.gen.log
+*.gen.refers
Index: gzz/metacode/pegboard.py
diff -u gzz/metacode/pegboard.py:1.26 gzz/metacode/pegboard.py:1.27
--- gzz/metacode/pegboard.py:1.26 Wed Dec 18 10:56:09 2002
+++ gzz/metacode/pegboard.py Mon Jan 13 08:39:38 2003
@@ -20,13 +20,16 @@
# because of hardcoded pegroot and css.
import sys, os, os.path, string
-import umlrst
+import umlrst, umltool
import docutils
from docutils import Component
from docutils import frontend, io, readers, parsers, writers, nodes
from docutils.core import publish_cmdline, Publisher
from docutils.frontend import OptionParser, ConfigParser
+#registers UML reST-directives
+umlrst.__rst_init__()
+
#collects error messages
fails = 'XXX\n'
@@ -166,6 +169,9 @@
pub.set_writer('html')
file = pegroot+'/'+pegdir+'/'+rstfile[0:len(rstfile)-4]
args = '-stg --stylesheet ../'+css+' %s.rst %s.gen.html' % (file,file)
+
+ #saves using contexts for diagrams
+ umltool.settings['context'] = pegroot+'/'+pegdir+'/'+rstfile
pub.process_command_line(argv=args.split())
#conversion may fail because of bad restructuredtext
@@ -386,6 +392,10 @@
#converts pegboard.rst, reads results into buffer and opens pegboard.html for
writing
print 'Generating '+pegroot+'/pegboard.gen.html'
args = '-stg --stylesheet '+css+' '+pegroot+'/pegboard.rst
'+pegroot+'/pegboard.gen.html'
+
+#saves using contexts for diagrams
+umltool.settings['context'] = pegroot+'/pegboard.rst'
+
publish_cmdline(writer_name='html', argv=args.split())
Index: gzz/metacode/uml.py
diff -u gzz/metacode/uml.py:1.23 gzz/metacode/uml.py:1.24
--- gzz/metacode/uml.py:1.23 Wed Dec 18 07:13:29 2002
+++ gzz/metacode/uml.py Mon Jan 13 08:39:38 2003
@@ -15,9 +15,10 @@
# file for more details.
#
-import sys, umltool
+import sys, umltool, mputils
-umltool.set_to_root("")
+umltool.set_transition_paths("")
+mputils.settings['tmpdir'] = "./"
for path in sys.argv[1:]:
umltool.run(path)
Index: gzz/metacode/umldoc.py
diff -u gzz/metacode/umldoc.py:1.13 gzz/metacode/umldoc.py:1.14
--- gzz/metacode/umldoc.py:1.13 Tue Jan 7 03:48:29 2003
+++ gzz/metacode/umldoc.py Mon Jan 13 08:39:38 2003
@@ -48,56 +48,51 @@
"""
import sys, os.path
-import umltool, umlrst
+import umltool, umlrst, mputils
import docutils.core
# must be run in the main directory of gzz module
umltool.settings['css'] = 'doc/gzz.css'
-def _slashify(path):
- """Add a trailing slash if not already there.
- """
- return (path+"/").replace("//","/")
+mputils.__rst_init__()
+umlrst.__rst_init__()
def _rstFiles(path):
- files = [f for f in os.listdir(path+'/') \
- if os.path.isfile(path+'/'+f) and not f.startswith('.')
+ files = [f for f in os.listdir(mputils._slashify(path)) \
+ if os.path.isfile(mputils._slashify(path)+f) and not
f.startswith('.')
and '#' not in f and '~' not in f]
rstfiles = [f for f in files if f.endswith('.rst')]
return rstfiles
def run_convert(path):
- umltool.set_to_root(path)
-
if os.path.isdir(path):
- umltool.set_to_root(_slashify(path))
rstfiles = _rstFiles(path)
for rstfile in rstfiles:
- rst2html(path+"/"+rstfile)
+ rst2html(mputils._slashify(path)+rstfile)
elif os.path.isfile(path) or os.path.isfile(path+'.rst'):
rst2html(path)
else:
+ umltool.set_transition_paths(path)
umltool.run(path)
def run_embed(path):
- umltool.set_to_root(path)
-
if os.path.isdir(path):
- umltool.set_to_root(_slashify(path))
rstfiles = _rstFiles(path)
for rstfile in rstfiles:
- print "Embed",path+"/"+rstfile
- umlrst.embed_diagram(path+"/"+rstfile)
+ print "Embed",mputils._slashify(path)+rstfile
+ umlrst.embed_diagrams(mputils._slashify(path)+rstfile)
elif os.path.isfile(path) or os.path.isfile(path+'.rst'):
print "Embed",path
- umlrst.embed_diagram(path)
+ umlrst.embed_diagrams(path)
def rst2html(path):
+ umltool.set_transition_paths(path)
+ umltool.settings['context'] = path
#the first pass - converts rst into html
if path.endswith(".rst"): path = path[0:len(path)-4]
args = '-stg --stylesheet '+umltool.settings['to_css']\
Index: gzz/metacode/umlpegboard.py
diff -u gzz/metacode/umlpegboard.py:1.1 gzz/metacode/umlpegboard.py:1.2
--- gzz/metacode/umlpegboard.py:1.1 Wed Dec 18 10:59:11 2002
+++ gzz/metacode/umlpegboard.py Mon Jan 13 08:39:38 2003
@@ -15,24 +15,32 @@
# file for more details.
import os, os.path
-import umlrst
+import umlrst, mputils
#relative or absolute location of pegboard directory
pegroot = 'doc/pegboard'
-pegdirs = [d for d in os.listdir(pegroot+'/')
- if os.path.isdir(pegroot+'/'+d) and d != 'CVS']
+mputils.__rst_init__()
+umlrst.__rst_init__()
-for pegdir in pegdirs:
- pegfiles = [f for f in os.listdir(pegroot+'/'+pegdir+'/') \
- if os.path.isfile(pegroot+'/'+pegdir+'/'+f) and not
f.startswith('.')
- and '#' not in f and '~' not in f]
+pegdirs = [d for d in os.listdir(mputils._slashify(pegroot))
+ if os.path.isdir(mputils._slashify(pegroot)+d) and d != 'CVS']
+for pegdir in pegdirs:
+ pegfiles = [f for f in os.listdir(mputils._slashify(pegroot)\
+ +mputils._slashify(pegdir))\
+ if os.path.isfile(mputils._slashify(pegroot)\
+ +mputils._slashify(pegdir)+f)\
+ and not f.startswith('.')
+ and '#' not in f and '~' not in f]
+
rstfiles = [f for f in pegfiles if f.endswith('.rst')]
#########################
#UMLDOC: the second pass#
#########################
for rstfile in rstfiles:
- file = pegroot+'/'+pegdir+'/'+rstfile
- umlrst.embed_diagram(file)
+ file = mputils._slashify(pegroot)\
+ +mputils._slashify(pegdir)\
+ +rstfile
+ umlrst.embed_diagrams(file)
Index: gzz/metacode/umlrst.py
diff -u gzz/metacode/umlrst.py:1.13 gzz/metacode/umlrst.py:1.14
--- gzz/metacode/umlrst.py:1.13 Tue Jan 7 05:22:24 2003
+++ gzz/metacode/umlrst.py Mon Jan 13 08:39:38 2003
@@ -17,18 +17,24 @@
import os.path
import docutils.parsers.rst.directives, docutils.nodes, docutils.core
-import umltool
+import umltool, mputils
-umltool.settings['tmpdir'] = 'doc/uml'
-
-#Environmental variable MPINPUTS should be relative to tmpdir,
-#or be an absolute path.
-os.putenv("MPINPUTS", "../../metacode")
-
-#TEXFMOUTPUT should change the output directory of metapost, but it didn't
-#seem to do that. Instead of this, metapost is currently run in tmpdir.
-#os.putenv("TEXMFOUTPUT", umltool.settings['tmpdir'])
+def __rst_init__():
+ """
+ Initializes Docutils Directives.
+ """
+ uml_directive.arguments = (1, 0, 0)
+ uml_directive.options = {}
+ uml_directive.content = 1
+
+ docutils.parsers.rst.directives._directives['uml'] = uml_directive
+
+ uml_refer_directive.arguments = (1, 0, 0)
+ uml_refer_directive.options = {}
+ uml_refer_directive.content = 0
+ docutils.parsers.rst.directives._directives['uml-refer'] =
uml_refer_directive
+
def uml_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
"""
@@ -38,8 +44,8 @@
reST document tree.
"""
attributes = {'name': arguments[0]}
+ uml_node = docutils.nodes.comment('', 'UML:'+attributes['name'])
if content:
- uml_node = docutils.nodes.comment('', 'UML:'+attributes['name'])
#splits content into uml and mp parts
files = ['', '']
@@ -54,34 +60,54 @@
temp += line + "\n"
files[current] = temp
- # XXX fatal error if diagram with the same name already exists
- # Anyway, this needs more thinking. This check should be global,
+ # XXX fatal error should be made if diagram with the same name
+ # already exists Anyway, this needs more thinking.
+ # This check should be global,
# but following asserts would need to make clean tmpdir before
# every remake...
-# assert not os.path.isfile(umltool.settings['tmpdir']+"/"\
-# +attributes['name']+".gen.uml"), "file "\
-# +attributes['name']+".gen.uml already exists"
-# assert not os.path.isfile(umltool.settings['tmpdir']+"/"\
-# +attributes['name']+".uml")
-
+
#writes uml and mp sourcefiles and converts them into png and html
- uml =
open(umltool.settings['tmpdir']+"/"+attributes['name']+".gen.uml", "w")
- mp = open(umltool.settings['tmpdir']+"/"+attributes['name']+".gen.mp",
"w")
+
+ uml = open(mputils._slashify(mputils.settings['tmpdir'])\
+ +attributes['name']+".gen.uml", "w")
uml.write(files[0])
- mp.write(files[1])
uml.close()
+
+ mp = open(mputils._slashify(mputils.settings['tmpdir'])\
+ +attributes['name']+".gen.mp", "w")
+ mp.write(files[1])
mp.close()
- return [uml_node]
+ add_refer_context(attributes['name'], 1)
-uml_directive.arguments = (1, 0, 0)
-uml_directive.options = {}
-uml_directive.content = 1
+ return [uml_node]
-docutils.parsers.rst.directives._directives['uml'] = uml_directive
+def add_refer_context(name, top = 0):
+ if umltool.settings.has_key('context'):
+ if (os.path.isfile(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers")):
+ old_refers = open(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers", "r").read()
+ if old_refers.find(umltool.settings['context']) == -1:
+ if top:
+ refers =
open(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers", "w")
+ refers.write(umltool.settings['context']+"\n"+old_refers)
+ refers.close()
+ else:
+ refers =
open(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers", "a")
+ refers.write(umltool.settings['context']+"\n")
+ refers.close()
+ else:
+ refers = open(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers", "a")
+ refers.write(umltool.settings['context']+"\n")
+ refers.close()
+
def uml_refer_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
+ content_offset, block_text, state, state_machine):
"""
Adds a comment node "<!-- UML: foo -->" into reST document tree.
Excepts that diagram foo exists or is later generated from some
@@ -89,21 +115,15 @@
"""
attributes = {'name': arguments[0]}
uml_node = docutils.nodes.comment('', 'UML:'+attributes['name'])
-
- return [uml_node]
-
-uml_refer_directive.arguments = (1, 0, 0)
-uml_refer_directive.options = {}
-uml_refer_directive.content = 0
+ add_refer_context(attributes['name'])
-docutils.parsers.rst.directives._directives['uml-refer'] = uml_refer_directive
+ return [uml_node]
def create_diagram(diagram_orig, diagram_dest="", scale=1.0):
return (umltool.run(diagram_orig, diagram_dest, scale))
-def embed_diagram(path):
- if not umltool.settings.has_key('to_root'):
- umltool.set_to_root(path)
+def embed_diagrams(path):
+ umltool.set_transition_paths(path)
#the second pass - adds uml into html
if path.endswith(".rst"): path = path[0:len(path)-4]
@@ -117,30 +137,42 @@
#This should work also with non-generated UML-diagrams. Checks
first
#for generated and then if non-generated diagram exists.
- if
(os.path.isfile(umltool.settings['tmpdir']+"/"+name+".gen.uml")):
+ if (os.path.isfile(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.uml")):
prefix = name + ".gen"
else: prefix = name
- assert
(os.path.isfile(umltool.settings['tmpdir']+"/"+prefix+".uml")\
- and
os.path.isfile(umltool.settings['tmpdir']+"/"+prefix+".mp")),\
- "file "+ prefix+".uml or "+prefix+".mp not found"
print "Embedding %s into %s" % (prefix, path)
- implicit_targets = create_diagram(prefix)
+ context_name = name+"_"+path.replace("/","_")
+ if context_name.endswith(".gen"):
+ context_name = context_name[0:len(context_name)-4]
+ implicit_targets = create_diagram(prefix, context_name, 1.0)
for target in implicit_targets:
embed_implicit(path, name, target)
- assert
(os.path.isfile(umltool.settings['tmpdir']+"/"+name+".gen.html")\
- and
os.path.isfile(umltool.settings['tmpdir']+"/"+name+".gen.png")),\
- "file "+name+".gen.html or "+name+".gen.png not found"
-
#Cut&Pastes imagemap into html
- imgmap =
open(umltool.settings['tmpdir']+"/"+name+".gen.html").read()
+ imgmap =
open(mputils.settings['tmpdir']+"/"+context_name+".gen.html").read()
out.write("<map id=\""+name+"\" name=\""+name+"\">\n")
out.write(imgmap[imgmap.find('>',imgmap.find('<map'))+1:\
imgmap.find('</map>')])
out.write("</map>\n")
- out.write("<img
src=\""+umltool.settings['to_tmpdir']+"/"+name+".gen.png"\
- +"\" usemap=\"#"+name+"\" alt=\""+name+"\" />")
+
+ out.write("<div class=\"uml-explicit\">\n")
+ if (os.path.isfile(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers")):
+ refers = open(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers").readlines()
+ out.write("<strong>"+name+"</strong>: \n")
+ for refer in refers:
+ out.write("[<a href=\""\
+ +mputils.transition_path(path,
refer.replace(".rst", ".gen.html")).replace("\n","")\
+
+"#"+name+"\">"+refer.split("/")[-1].split(".")[0]+"</a>]\n")
+ out.write("<br/>\n")
+ out.write("<a id=\""+name+"\"></a>\n")
+ out.write("<img
src=\""+mputils._slashify(mputils.settings['to_tmpdir'])\
+ +context_name+".gen.png"\
+ +"\" usemap=\"#"+name+"\" alt=\""+name+"\" />\n")
+ out.write("</div>\n")
html = html[html.find("-->", insert)+3:len(html)]
insert = html.find("<!-- UML:")
out.write(html)
@@ -161,12 +193,14 @@
if slash != -1:
path = (oldpath[0:slash+1] + path).replace("//", "/")
- tmp = umltool.settings.copy()
- umltool.set_to_root(path)
+ umltool_backup = umltool.settings.copy()
+ mputils_backup = mputils.settings.copy()
+
+ umltool.set_transition_paths(path)
slash = oldpath.rfind("/")
if slash != -1:
- umltool.settings['to_context'] = umltool.merge_paths(path,
oldpath[0:slash])
- else: umltool.settings['to_context'] = umltool.merge_paths(path, oldpath)
+ umltool.settings['to_context'] = mputils.transition_path(path,
oldpath[0:slash])
+ else: umltool.settings['to_context'] = mputils.transition_path(path,
oldpath)
#the second pass - adds uml into html
if path.endswith(".rst"): path = path[0:len(path)-4]
@@ -183,30 +217,47 @@
#This should work also with non-generated UML-diagrams. Checks
first
#for generated and then if non-generated diagram exists.
- if
(os.path.isfile(umltool.settings['tmpdir']+"/"+name+".gen.uml")):
+ if (os.path.isfile(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.uml")):
old_prefix = name + ".gen"
else: old_prefix = name
print "Embedding %s into %s" % (name, path)
- new_prefix = name+"_"+path.replace("/","_")
- if new_prefix.endswith(".gen"):
- new_prefix = new_prefix[0:len(new_prefix)-4]
- create_diagram(old_prefix, new_prefix, 0.5)
+ context_name = name+"_"+path.replace("/","_")
+ if context_name.endswith(".gen"):
+ context_name = context_name[0:len(context_name)-4]
+ create_diagram(old_prefix, context_name, 0.5)
#Cut&Pastes imagemap into html
- imgmap =
open(umltool.settings['tmpdir']+"/"+new_prefix+".gen.html").read()
+ imgmap = open(mputils._slashify(mputils.settings['tmpdir'])\
+ +context_name+".gen.html").read()
out.write("<map id=\""+name+"\" name=\""+name+"\">\n")
out.write(imgmap[imgmap.find('>',imgmap.find('<map'))+1:\
imgmap.find('</map>')])
out.write("</map>\n")
+ out.write("<div class=\"uml-implicit\">\n")
+ if (os.path.isfile(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers")):
+ refers = open(mputils._slashify(mputils.settings['tmpdir'])\
+ +name+".gen.refers").readlines()
+ out.write("<small><strong>"+name+"</strong>: \n")
+ for refer in refers:
+ out.write("[<a href=\""\
+ +mputils.transition_path(path,
refer.replace(".rst", ".gen.html")).replace("\n","")\
+
+"#"+name+"\">"+refer.split("/")[-1].split(".")[0]+"</a>]\n")
+ out.write("</small><br/>\n")
+
+ out.write("<a id=\""+name+"\"></a>\n")
out.write("<img "\
- +"src=\""+umltool.settings['to_tmpdir']+"/"\
- +new_prefix+".gen.png"\
- +"\" usemap=\"#"+name+"\" alt=\""+name+"\" />")
+
+"src=\""+mputils._slashify(mputils.settings['to_tmpdir'])\
+ +context_name+".gen.png"\
+ +"\" usemap=\"#"+name+"\" alt=\""+name+"\" />\n")
+ out.write("</div>\n")
html = html[insert+5:len(html)]
out.write(html)
out.close()
- umltool.settings = tmp
+ umltool.settings = umltool_backup
+ mputils.settings = mputils_backup
Index: gzz/metacode/umltool.py
diff -u gzz/metacode/umltool.py:1.19 gzz/metacode/umltool.py:1.20
--- gzz/metacode/umltool.py:1.19 Wed Jan 8 03:44:26 2003
+++ gzz/metacode/umltool.py Mon Jan 13 08:39:38 2003
@@ -16,11 +16,10 @@
#
from __future__ import nested_scopes
-import re
-import os
-import sys
-import random
-import string
+import re, os, sys
+import random, string
+
+import mputils
settings = {
'javadoc': 'doc/javadoc',
@@ -28,28 +27,20 @@
jlinkpackage = None
-def set_to_root(path):
+def set_transition_paths(path):
+ """
+ Creates necessary transition paths. Although, don't know
+ where this really should be.
+ """
depth = path.count("/")
settings['to_root'] = "".join(["../" for i in range(depth)])
- settings['to_javadoc'] = merge_paths(path, settings['javadoc'])
- if settings.has_key('tmpdir'):
- settings['to_tmpdir'] = merge_paths(path, settings['tmpdir'])
+ settings['to_javadoc'] = mputils.transition_path(path, settings['javadoc'])
+ if mputils.settings.has_key('tmpdir'):
+ mputils.settings['to_tmpdir'] = mputils.transition_path(path,\
+ mputils.settings['tmpdir'])
if settings.has_key('css'):
- settings['to_css'] = merge_paths(path, settings['css'])
-
-def merge_paths(fromd, to):
- depth = fromd.count("/")
- from_parts = fromd.split("/")
- to_parts = to.split("/")
- parts = len(from_parts)<len(to_parts) and len(from_parts) or len(to_parts)
- for i in range(parts):
- if from_parts[i] != to_parts[i]:
- parts = i
- break
- result = "".join(["../" for i in range(depth-parts)]) \
- +"".join([to_parts[i+parts]+"/" for i in
range(len(to_parts)-parts)])
- return (result[0:len(result)-1])
-
+ settings['to_css'] = mputils.transition_path(path, settings['css'])
+
def matchRemove(p, s):
"Match pattern p in s and remove the match, return (match, ns)"
m = re.match(p,s)
@@ -114,7 +105,7 @@
return self.name
def jlinkstr(self, box):
if self.jlink != None:
- """ If focus is set and matches, focus jlink. """
+ """ If focus is set and 'focus' matches, focus jlink. """
#trimming jlink to comparable
name = self.jlink
if name.rfind("#") != -1:
@@ -769,36 +760,14 @@
self.name,
self.name)
-def roundDown(x):
- return int(float(x) - 5)
-def roundUp(x):
- return int(float(x) + 5)
-
-class psbbox:
- def __init__(self, els):
- self.x=(roundDown(els[0]), roundUp(els[2]))
- self.y=(roundUp(els[1]), roundDown(els[3]))
- self.scale = 1 # 1 point = 1 pixel
- self.w = self.scale*(self.x[1]-self.x[0])
- self.h = self.scale*(self.y[0]-self.y[1])
- def mapPoint(self, x, y):
- return (self.scale * (x - self.x[0]),
- self.h - self.scale * (y - self.y[1])); # reverse y
- def pstopnm(self, scale):
- dpi = 72.0
- return ["%s"%r for r in [ "-llx", self.x[0]/dpi, "-lly", self.y[1]/dpi,
- "-urx", self.x[1]/dpi, "-ury", self.y[0]/dpi,
- "-xsize", self.w * scale, "-ysize", self.h * scale,
- "-xborder", 0, "-yborder", 0]]
-
def run(prefix_in, prefix_out="", scale=1.0):
if prefix_out == "": prefix_out = prefix_in
if not prefix_out.endswith(".gen"): prefix_out = prefix_out + ".gen"
settings['focus'] = prefix_out;
- if settings.has_key('tmpdir'):
- path = settings['tmpdir'] + "/"
+ if mputils.settings.has_key('tmpdir'):
+ path = mputils._slashify(mputils.settings['tmpdir'])
else: path = '';
s = open(path+prefix_in+".uml").read()
@@ -826,13 +795,8 @@
end
""" % locals())
gen3.close()
-
- syscmd = "/usr/bin/mpost --file-line-error-style "+\
- "--interaction nonstopmode "+\
- "%s" % prefix_out+".3 |grep -B2 \!";
- if settings.has_key('tmpdir'):
- os.system("cd "+path+";"+syscmd)
- else: os.system(syscmd)
+
+ mputils.mp2png(prefix_out, scale)
log = open(path+prefix_out+".log").read()
print "LINKS"
@@ -847,19 +811,8 @@
else:
links.append(jlink(els))
print links
- print "BBOX", bbox
- bbox = psbbox(bbox[1:])
+ bbox = mputils.psbbox(bbox[1:])
for link in links: link.mapCorners(bbox.mapPoint)
-
- scaling = 2
- list = bbox.pstopnm(scaling)
- scaling = int(scaling / scale)
- print "PSTOPNM: ", list
- syscmd = ("pstopnm -verbose "+" ".join(list)+" <"+path+prefix_out\
- +""".1 | pnmscale -reduce %s |
- pnmtopng >"""%scaling+path+prefix_out+".png")
- print "Command:",syscmd
- os.system(syscmd)
htmlcode = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz metacode/pegboard.py metacode/uml.py metaco...,
Asko Soukka <=