yUML and ColdFusion
I just tried to write a quick script in Python that scans CFCs and generates a yUML URL to diagram. I pointed my script to my root CFC path and I got a 13K strlen URL. I pasted it in the address bar to see what happened and I got the following:
Request-URI Too Large The requested URL's length exceeds the capacity limit for this server. Apache/2.2.3 (Debian) Phusion_Passenger/2.0.2 Server at Ess000235.gtcust.grouptelecom.net Port 80
I wonder what the limitation is. I suppose I’ll have to do a CFC per diagram and then bind them together somehow. I’m choosing Python so this script can be part of my build script.
Here’s the code so far, which of course, could be optimized:
import re import os # UML Syntax # http://yuml.me/diagram/class/[User|Property1;Property2|Method1();Method2()] # http://yuml.me/diagram/class/ # [ # User # | # Property1; # Property2 # | # Method1(); # Method2() # ] # Master Path ROOT_PATH = 'C:\\temp\\cf-yuml' def SearchForFile( rootpath, searchfor, includepath = 0 ): # Search for a file recursively from a root directory. # rootpath = root directory to start searching from. # searchfor = regexp to search for, e.g.: # search for *.jpg : \.exe$ # includepath = appends the full path to the file # this attribute is optional # Returns a list of filenames that can be used to loop # through. # # TODO: Use the glob module instead. Could be faster. names = [] append = "" for root, dirs, files in os.walk( rootpath ): for name in files: if re.search( searchfor, name ): if includepath == 0: root = "" else: append = "\\" names.append( root + append + name ) return names def getCFCInfo ( FILE, path ): FILE.seek( 0, 0 ) CFCLines = FILE.readlines() CFCFunctions = [] CFCProperties = [] CFC = {} for i in CFCLines: # Get names of methods if re.search( "^<cffunction", i , re.IGNORECASE | re.MULTILINE ): CFCFunctions.append( re.search( r'name\s*=\s*"([\w$-]+)"', i, re.DOTALL | re.IGNORECASE).group(1) ) # Get names of properties if re.search( "^<cfproperty", i , re.IGNORECASE | re.MULTILINE ): CFCProperties.append( re.search( r'name\s*=\s*"([\w$-]+)"', i, re.DOTALL | re.IGNORECASE).group(1) ) CFC = { "properties":CFCProperties, "methods":CFCFunctions } # Generate URL strFunctions = "" strProperties = "" for i in CFCFunctions: strFunctions += i + "();" for i in CFCProperties: strProperties += i + ";" CFCFileName = re.search(r"\\([\w-]+)\.cfc$", path, re.DOTALL | re.IGNORECASE).group(1) return "[" + CFCFileName + "|" + ( strProperties.strip()[:-1] + "|" if strProperties.strip()[:-1] else "" ) + strFunctions.strip()[:-1] + "]" URL = "" for i in SearchForFile( ROOT_PATH, "\.cfc$", 1 ): CFCFile = open( i, "r" ) URL += getCFCInfo( CFCFile, i ) + "," CFCFile.close() URL = URL[:-1] print "http://yuml.me/diagram/class/" + URL
I'll keep working on this as time goes on. So far it just goes through all the CFC's from the path you point to. It will crawl through all sub directories. There's no relationship between classes, however. Not yet at least.
Categories