[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] navidoc ./TODO-navidoc ./config.py ./rst2any.py...
From: |
Asko Soukka |
Subject: |
[Gzz-commits] navidoc ./TODO-navidoc ./config.py ./rst2any.py... |
Date: |
Wed, 26 Mar 2003 10:36:17 -0500 |
CVSROOT: /cvsroot/navidoc
Module name: navidoc
Changes by: Asko Soukka <address@hidden> 03/03/26 10:36:17
Modified files:
. : TODO-navidoc config.py rst2any.py
navidoc : __init__.py
navidoc/directives: __init__.py pegboard.py
navidoc/mp : __init__.py
navidoc/utils : path.py
navidoc/writers: __init__.py
Added files:
navidoc : parser.py
navidoc/directives: latex.py mp.py
navidoc/mp : uml.mp uml.py
navidoc/writers: latex2e.py
Log message:
some unfinished stuff
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/TODO-navidoc.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/config.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/rst2any.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/parser.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/__init__.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/latex.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/mp.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/__init__.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/pegboard.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/mp/uml.mp?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/mp/uml.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/mp/__init__.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/utils/path.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/writers/latex2e.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/writers/__init__.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: navidoc/TODO-navidoc
diff -u navidoc/TODO-navidoc:1.2 navidoc/TODO-navidoc:1.3
--- navidoc/TODO-navidoc:1.2 Mon Mar 24 03:18:33 2003
+++ navidoc/TODO-navidoc Wed Mar 26 10:36:17 2003
@@ -3,7 +3,9 @@
0.1alpha1: First separate release
humppake:
- move old UML-stuff to navidoc
- - move old Latex-stuff to navidoc
+ - figure out need of restructuring
+ - document our current UML software
+ (metacode/uml*, used by doc/uml/*)
anybody:
- util to create new peg
- creates directory
@@ -12,14 +14,6 @@
- creates a proper .cvsignore
0.2alpha1: Rewriting
- humppake:
- - document our current UML software
- (metacode/uml*, used by doc/uml/*)
- - figure out need of restructuring
-
- humppake, benja:
- - PEG the new architecture
-
anybody:
Design issues
-------------
Index: navidoc/config.py
diff -u navidoc/config.py:1.5 navidoc/config.py:1.6
--- navidoc/config.py:1.5 Fri Mar 21 05:36:27 2003
+++ navidoc/config.py Wed Mar 26 10:36:17 2003
@@ -19,7 +19,7 @@
# MA 02111-1307 USA
#
-# $Id: config.py,v 1.5 2003/03/21 10:36:27 humppake Exp $
+# $Id: config.py,v 1.6 2003/03/26 15:36:17 humppake Exp $
__docformat__ = 'reStructuredText'
@@ -28,6 +28,16 @@
from navidoc.utils.debug import DebugFilter
+# global settings needed all around
+mp_directory = '../mptemp'
+mp_eps_only = 0
+
+# global settings needed all around, these
+# should be automaticly re-set before compiling reST
+working_directory = '.'
+input_filename = ''
+output_filename = ''
+
# general debug filter
dbg = DebugFilter()
@@ -35,12 +45,6 @@
if os.path.isfile("./docutils.conf"):
docutils = "./docutils.conf"
else: docutils = ""
-
-# global settings needed all around, these
-# should be automaticly re-set before compiling reST
-working_directory = '.'
-input_filename = ''
-output_filename = ''
# pegs will be sorted after their priority
pegboard_priorities = {'Current': 1,
Index: navidoc/navidoc/__init__.py
diff -u navidoc/navidoc/__init__.py:1.6 navidoc/navidoc/__init__.py:1.7
--- navidoc/navidoc/__init__.py:1.6 Mon Mar 24 03:08:13 2003
+++ navidoc/navidoc/__init__.py Wed Mar 26 10:36:17 2003
@@ -19,7 +19,7 @@
# MA 02111-1307 USA
#
-#$Id: __init__.py,v 1.6 2003/03/24 08:08:13 humppake Exp $
+#$Id: __init__.py,v 1.7 2003/03/26 15:36:17 humppake Exp $
#
# Written by Asko Soukka
@@ -31,6 +31,7 @@
import config
import navidoc.directives
+import navidoc.writers
# Because docutils' own relative path has problems with
# paths beginning with '../', we use our own :-)
Index: navidoc/navidoc/directives/__init__.py
diff -u navidoc/navidoc/directives/__init__.py:1.3
navidoc/navidoc/directives/__init__.py:1.4
--- navidoc/navidoc/directives/__init__.py:1.3 Fri Mar 21 08:23:36 2003
+++ navidoc/navidoc/directives/__init__.py Wed Mar 26 10:36:17 2003
@@ -19,14 +19,31 @@
# MA 02111-1307 USA
#
+# $Id: __init__.py,v 1.4 2003/03/26 15:36:17 humppake Exp $
+
#
# Written by Asko Soukka
#
__docformat__ = 'reStructuredText'
-import docutils.parsers.rst.directives
+from docutils.parsers.rst import directives
from navidoc.directives.pegboard import pegboard_directive
+from navidoc.directives.latex import bibliography_directive
+#from navidoc.directives.mp import mp_directive, uml_directive,
uml_refer_directive
+
+directives._directives['pegboard'] = pegboard_directive
+#directives._directives['mp'] = mp_directive
+#directives._directives['uml'] = uml_directive
+#directives._directives['uml-refer'] = uml_refer_directive
+directives._directives['bibliography'] = bibliography_directive
+
+# some additional options and changes for latex writer
+from docutils.parsers.rst.directives import images
+
+images.image.options['height'] = directives.unchanged;
+images.image.options['width'] = directives.unchanged;
+images.image.options['label'] = directives.unchanged;
+images.image.options['environment'] = directives.unchanged;
-docutils.parsers.rst.directives._directives['pegboard'] = pegboard_directive
Index: navidoc/navidoc/directives/pegboard.py
diff -u navidoc/navidoc/directives/pegboard.py:1.8
navidoc/navidoc/directives/pegboard.py:1.9
--- navidoc/navidoc/directives/pegboard.py:1.8 Mon Mar 24 03:08:13 2003
+++ navidoc/navidoc/directives/pegboard.py Wed Mar 26 10:36:17 2003
@@ -19,6 +19,8 @@
# MA 02111-1307 USA
#
+# $Id: pegboard.py,v 1.9 2003/03/26 15:36:17 humppake Exp $
+
#
# Written by Benja Fallensten, Vesa Kaihlavirta, Asko Soukka
#
@@ -136,6 +138,8 @@
rstfiles = [f for f in peg['files'] if f.endswith('.rst')]
for rstfile in rstfiles:
+ config.input_filename = rstfile
+ config.output_filename = ''
pub = Publisher()
pub.set_reader('standalone', None, 'restructuredtext')
filename = _slashify(config.working_directory)+rstfile
@@ -145,8 +149,10 @@
try:
pub.set_io()
document = pub.reader.read(pub.source, pub.parser,
pub.settings)
+ config.output_filename = rstfile[0:len(rstfile)-4]+'.gen.html'
pub.apply_transforms(document)
- peg['ignore'].append(rstfile[0:len(rstfile)-4]+'.gen.html')
+ peg['ignore'].append(config.output_filename)
+ config.output_filename = ''
#conversion have succeeded so far, parsing peg's metadata
#from its document tree
@@ -181,7 +187,8 @@
elif file[len(file)-4:len(file)] in ('.rst', '.txt'):
peg['html'] = file
break
-
+ config.intput_filename = ''
+
#finally adds peg's metadata into pegtable
pegtable.append(peg)
Index: navidoc/navidoc/mp/__init__.py
diff -u navidoc/navidoc/mp/__init__.py:1.1 navidoc/navidoc/mp/__init__.py:1.2
--- navidoc/navidoc/mp/__init__.py:1.1 Tue Mar 18 09:32:53 2003
+++ navidoc/navidoc/mp/__init__.py Wed Mar 26 10:36:17 2003
@@ -1 +1,173 @@
+#
+# Copyright (c) 2002, 2003 Tuomas Lukka, Asko Soukka
+#
+# This file is part of Navidoc.
+#
+# Navidoc is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Navidoc is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General
+# Public License along with Navidoc; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+# $Id: __init__.py,v 1.2 2003/03/26 15:36:17 humppake Exp $
+
#
+# Written by Tuomas Lukka, Asko Soukka
+#
+
+__docformat__ = 'reStructuredText'
+
+import os, os.path
+
+from navidoc.utils.path import *
+from navidoc.parser import *
+
+import config
+
+dbg = config.dbg.shorthand('mp')
+dbg_fail = config.dbg.shorthand('mp.fail')
+
+class NamedMPElement(NamedElement):
+ def repl(self, s):
+ s = s.replace("%%", self.var)
+ s = s.replace("%name%", self.name)
+ if "stereo" in dir(self):
+ s = s.replace("%stereo%", self.stereo or "")
+ return s
+ def draw_code(self):
+ s = """
+ drawmeasuredpic(%%);
+ """
+ return self.repl(s)
+
+class SimpleElement(NamedMPElement):
+ def __init__(self, var, s, list):
+ dbg("Simple element: %s %s %s" % (self, s, list))
+ self.var = var or s
+ self.name = s
+ self.do_contents(list)
+
+def create_uml(diagram, extension='', scale=1.0):
+ """
+ """
+ if not os.path.isfile(_slashify(config.mp_directory)+diagram+'.gen.uml'):
+ raise
MetapostException(_slashify(config.mp_directory)+diagram+'.gen.uml'+' not
found')
+ if not os.path.isfile(_slashify(config.mp_directory)+diagram+'.gen.mp'):
+ raise
MetapostException(_slashify(config.mp_directory)+diagram+'.gen.mp'+' not found')
+
+ s = open(_slashify(config.mp_directory)+diagram+'.gen.uml').read()
+ l = parseIndented(s)
+ m = mplist(l)
+
+ if len(extension) > 0: extension = '_'+extension
+
+ dir = _slashify(config.mp_directory)
+ gen1 = open(dir+diagram+extension+'.gen.mp.1', 'w')
+ gen1.write(m.setupCode()+'\n')
+ gen1.close()
+ gen2 = open(dir+diagram+extension+'.gen.mp.2', 'w')
+ gen2.write(m.drawCode()+"\n")
+ gen2.close()
+ gen3 = open(dir+diagram+extension+".gen.mp.3", "w")
+ gen3.write("""
+ prologues := 1;
+ input general.mp
+ input uml.mp
+
+ beginfig(1)
+ input %(diagram+extension)s.gen.mp.1
+ input %(diagram)s.gen.mp
+ input %(diagram+extension)s.gen.mp.2
+ endfig
+ end
+ """ % locals())
+ gen3.close()
+
+ mp2png(diagram+extension, scale)
+
+def mp2png(diagram, scale=1.0):
+ """
+ """
+ config.dbg.out('navidoc', 'Compiling diagram '+diagram)
+
+ syscmd = 'mpost --file-line-error-style ' \
+ + '--interaction nonstopmode ' \
+ + diagram +'.gen.mp.3 >/dev/null'
+
+ dbg(syscmd)
+ os.system('cd '+config.mp_directory+';'+syscmd)
+
+ log = open(_slashify(config.mp_directory)+diagram+'.gen.log').read()
+ if log.find("\n"+'!') != -1:
+ dbg_fail('Error occurred while processing the diagram. The log is
shown below.')
+ dbg_fail(log)
+
+ links = []
+ log = log.replace("\n",'') # mpost splits lines awkwardly in the log.
+
+ bbox = 0
+ scaling = 2
+ list = ''
+
+ # grep all linked areas from log file
+ for link in re.findall('LINKRECT\((.*?)\)', log):
+ els = link.split(',')
+ if els[0] == '"bbox"':
+ bbox = els
+ dbg(bbox)
+
+ # scales the bounding box and prepares it for pstopnm
+ if (bbox):
+ bbox = psbbox(bbox[1:])
+ list = bbox.pstopnm(scaling)
+ dbg(bbox)
+
+ scaling = int(scaling / scale)
+
+ syscmd = ('pstopnm '+' '.join(list)+'
<'+_slashify(config.mp_directory)+diagram+'.gen' \
+ +'.mp.1 2>/dev/null | pnmscale -reduce '+scaling+' 2>/dev/null |
' \
+ +'pnmtopng >'+_slashify(config.mp_directory)+diagram+'.gen.png
2>/dev/null')
+
+ dbg(syscmd)
+ os.system(syscmd)
+
+class psbbox:
+ """
+ PostScriptBoundingBox.
+ """
+ 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 map_point(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]]
+
+class MetapostException(Exception):
+ def __init__(self, value):
+ self.value = value
+ def __str__(self):
+ return self.value
+
+def roundDown(x):
+ return int(float(x) - 5)
+def roundUp(x):
+ return int(float(x) + 5)
Index: navidoc/navidoc/utils/path.py
diff -u navidoc/navidoc/utils/path.py:1.5 navidoc/navidoc/utils/path.py:1.6
--- navidoc/navidoc/utils/path.py:1.5 Mon Mar 24 03:08:13 2003
+++ navidoc/navidoc/utils/path.py Wed Mar 26 10:36:17 2003
@@ -19,7 +19,7 @@
# MA 02111-1307 USA
#
-#$Id: path.py,v 1.5 2003/03/24 08:08:13 humppake Exp $
+#$Id: path.py,v 1.6 2003/03/26 15:36:17 humppake Exp $
#
# Written by Asko Soukka
@@ -56,9 +56,13 @@
Returns a relative path from the source to the target.
"""
if source == None or len(source) == 0: return target
- if source.startswith('../') or target.startswith('../'):
- source = os.path.normpath(os.path.abspath(source))
- target = os.path.normpath(os.path.abspath(target))
+
+ ## Condition removed because because of docutils sending
+ # relative and absolute paths mixed.
+ #
+ # if source.startswith('../') or target.startswith('../'):
+ source = os.path.normpath(os.path.abspath(source))
+ target = os.path.normpath(os.path.abspath(target))
depth = source.count('/')
source_parts = source.split('/')
Index: navidoc/navidoc/writers/__init__.py
diff -u navidoc/navidoc/writers/__init__.py:1.1
navidoc/navidoc/writers/__init__.py:1.2
--- navidoc/navidoc/writers/__init__.py:1.1 Tue Mar 18 09:32:53 2003
+++ navidoc/navidoc/writers/__init__.py Wed Mar 26 10:36:17 2003
@@ -1 +1,33 @@
+#
+# Copyright (c) 2003 Asko Soukka
+#
+# This file is part of Navidoc.
+#
+# Navidoc is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Navidoc is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General
+# Public License along with Navidoc; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+# $Id: __init__.py,v 1.2 2003/03/26 15:36:17 humppake Exp $
+
#
+# Written by Asko Soukka
+#
+
+__docformat__ = 'reStructuredText'
+
+from navidoc.writers import latex2e
+from docutils.writers import _writer_aliases
+
+_writer_aliases['latex'] = 'latex2e'
Index: navidoc/rst2any.py
diff -u navidoc/rst2any.py:1.12 navidoc/rst2any.py:1.13
--- navidoc/rst2any.py:1.12 Mon Mar 24 03:08:13 2003
+++ navidoc/rst2any.py Wed Mar 26 10:36:17 2003
@@ -89,6 +89,8 @@
config.output_filename = os.path.basename(output)
dbg_config('Output file: '+config.output_filename)
args = '--config '+config.docutils+' '+input+' '+output
+
+ config.mp_eps_only = 0
docutils.core.publish_cmdline(writer_name='html', argv=args.split())
if latex:
@@ -97,6 +99,8 @@
config.output_filename = os.path.basename(output)
dbg_config('Output file: '+config.output_filename)
args = '--config '+config.docutils+' '+input+' '+output
+
+ config.mp_eps_only = 1
docutils.core.publish_cmdline(writer_name='latex', argv=args.split())
config.output_filename = ''
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] navidoc ./TODO-navidoc ./config.py ./rst2any.py...,
Asko Soukka <=