Skip to content

Commit da8e979

Browse files
committed
Adding new version of java-generate
1 parent 080f227 commit da8e979

File tree

134 files changed

+8062
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+8062
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
4+
import sys
5+
import os
6+
import re
7+
from xml.dom import minidom
8+
9+
linePrefix = " *"
10+
startString = linePrefix + " ( begin auto-generated from %s )"
11+
endString = "%s ( end auto-generated )" % linePrefix
12+
shortString = "@generate"
13+
xmlDirectory = "somwhere/"
14+
15+
def main():
16+
maker = DescriptionIntegrator( codeDirectory=sys.argv[1], xmlDirectory=sys.argv[2] )
17+
# answer = raw_input("Replace descriptions in %s with those in %s? (Y/N): " % (codeDirectory, xmlDirectory))
18+
answer = "y"
19+
20+
if( answer[0] == "Y" or answer[0] == "y" ):
21+
maker.run()
22+
23+
def prefixedString( input ):
24+
return "%s %s" % (linePrefix, input)
25+
26+
class DescriptionIntegrator:
27+
28+
def __init__(self, xmlDirectory="", codeDirectory=""):
29+
self.xmlDirectory = xmlDirectory
30+
self.codeDirectory = codeDirectory
31+
32+
def run(self):
33+
for root, dirs, files in os.walk( self.codeDirectory ):
34+
for name in files:
35+
if name[-4:] == "java":
36+
self.addDescriptionsToFile( os.path.join(root,name) )
37+
38+
def addDescriptionsToFile(self, f):
39+
input = open(f,'r+')
40+
text = input.read()
41+
input.close()
42+
didEdit = False
43+
44+
portions = text.split("\n")
45+
for line in portions:
46+
if( line.find( shortString ) != -1):
47+
parts = line.split(" ")
48+
[xml] = [ p for p in parts if p[-3:] == "xml" ]
49+
description = self.getDescription(xml)
50+
51+
index = portions.index(line)
52+
portions.insert( index, startString % xml )
53+
endIndex = self.insertDescription(description, portions, index+1 )
54+
portions.insert( endIndex, endString )
55+
portions.remove( line )
56+
didEdit = True
57+
elif( line.find("begin auto-generated") != -1 ):
58+
parts = line.split(" ")
59+
[xml] = [ p for p in parts if p[-3:] == "xml" ]
60+
description = self.getDescription(xml)
61+
index = portions.index(line) + 1
62+
self.removeOldDescription(portions, index)
63+
self.insertDescription( description, portions, index )
64+
didEdit = True
65+
if( didEdit == True ):
66+
output = open(f, 'w')
67+
output.write( '\n'.join(portions) )
68+
69+
def insertDescription(self, description, list, startIndex):
70+
parts = description.split("\n")
71+
for p in parts:
72+
list.insert( startIndex, prefixedString(p) )
73+
startIndex += 1
74+
return startIndex
75+
76+
def removeOldDescription(self, list, startIndex):
77+
lastIndex = list.index( endString, startIndex )
78+
numIndices = lastIndex - startIndex
79+
for i in range(0, numIndices):
80+
list.pop( startIndex )
81+
82+
def getDescription(self, xml):
83+
doc = minidom.parse( self.xmlDirectory + xml )
84+
elements = doc.getElementsByTagName("description")
85+
return elements[0].firstChild.nodeValue
86+
87+
88+
if __name__ == '__main__':
89+
main()
90+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>ReferenceGenerator</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#Tue Jun 08 18:03:33 PDT 2010
2+
eclipse.preferences.version=1
3+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6+
org.eclipse.jdt.core.compiler.compliance=1.5
7+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12+
org.eclipse.jdt.core.compiler.source=1.5
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
#remove everything old
3+
rm -rf ../tmp
4+
#generate everything anew
5+
javadoc -doclet ProcessingWeblet -docletpath bin/ -public \
6+
-webref ../tmp/web-android \
7+
-localref ../tmp/local-android \
8+
-includeXMLTag android \
9+
-templatedir ../templates \
10+
-examplesdir ../api_examples \
11+
-includedir ../api_examples/include \
12+
-imagedir images \
13+
-corepackage processing.xml \
14+
-rootclass PGraphics \
15+
-rootclass PConstants \
16+
../../../processing/android/core/src/processing/android/core/*.java \
17+
../../../processing/android/core/src/processing/android/xml/*.java \
18+
../../../processing/net/src/processing/net/*.java \
19+
../../../processing/serial/src/processing/serial/*.java
20+
# ../../../processing/video/src/processing/video/*.java \
21+
22+
#copy over the css and sample images
23+
cp -r ../../css ../tmp/web-android
24+
cp -r ../../css ../tmp/local-android
25+
mkdir ../tmp/web-android/images
26+
mkdir ../tmp/local-android/images
27+
cp -r ../../content/api_media/*.jpg ../tmp/web-android/images/
28+
cp -r ../../content/api_media/*.gif ../tmp/web-android/images/
29+
cp -r ../../content/api_media/*.png ../tmp/web-android/images/
30+
cp -r ../../content/api_media/*.jpg ../tmp/local-android/images/
31+
cp -r ../../content/api_media/*.gif ../tmp/local-android/images/
32+
cp -r ../../content/api_media/*.png ../tmp/local-android/images/
5.18 KB
Binary file not shown.
16.3 KB
Binary file not shown.
4.58 KB
Binary file not shown.
3.03 KB
Binary file not shown.
2.13 KB
Binary file not shown.

0 commit comments

Comments
 (0)