Skip to main content
Ben Nadel at RIA Unleashed (Nov. 2010) with: Erica Lebrun
Ben Nadel at RIA Unleashed (Nov. 2010) with: Erica Lebrun

ColdFusion Cheat Sheet: Ripping HomeSite's Help Directories

By
Published in Comments (2)

I am making a real push right now to learn more about the ColdFusion language as a whole. I know there are a lot of functions that exist that I either don't know about and/or don't use. That's about to change. In an effort to learn ColdFusion, I have made my own ColdFusion cheat sheet. Now, I saw "my own", but really, it's just a stripped down version of my HomeSite 5.5 help files:

ColdFusion Function Cheat Sheet

The HomeSite help docs have a lot of stuff that I am not interested in such as the Examples, History, and Usage. I am stripping those out. Further more, I am putting it all on one page (about 100+ printable pages) so that I can easily scroll through and search for stuff. Again, nothing here is new, only that I find it more accessible.

Perhaps the most interesting aspect about it is the way it was created. HomeSite stores the function help files as individual files. I read each one in, strip it down, and then output it:

<!---
	Read in the directory files from the Functions help
	file (copied over from HomeSite program files).
--->
<cfdirectory
	action="LIST"
	name="qFunctions"
	directory="#ExpandPath( './CFMLFunctions/' )#"
	sort="NAME ASC"
	/>


<!--- Loop over every file in the help directory. --->
<cfloop query="qFunctions">

	<!--- Read in the file. --->
	<cffile
		action="READ"
		variable="strFileData"
		file="#ExpandPath( './CFMLFunctions/#qFunctions.name#' )#"
		/>

	<!--- Get rid of body. --->
	<cfset strFileData = strFileData.ReplaceFirst(
		"^[\w\W]+?<body[^>]*>",
		""
		) />

	<!--- Get rid of post-body. --->
	<cfset strFileData = strFileData.ReplaceFirst(
		"</body[^>*]>[\w\W]*",
		""
		) />

	<!--- Get rid of post usage. --->
	<cfset strFileData = strFileData.ReplaceFirst(
		"<h(3|4)[^>]*>((?!Usage).)*Usage[\w\W]*",
		""
		) />

	<!--- Get rid of example. --->
	<cfset strFileData = strFileData.ReplaceFirst(
		"<h(3|4)[^>]*>((?!Example).)*Example[\w\W]*",
		""
		) />

	<!--- Get rid of history. --->
	<cfset strFileData = strFileData.ReplaceFirst(
		"<h(3|4)[^>]*>((?!History).)*History[\w\W]*?(<h(3|4))",
		"$3"
		) />

	<!--- Get rid of category. --->
	<cfset strFileData = strFileData.ReplaceFirst(
		"<h(3|4)[^>]*>((?!Category).)*Category[\w\W]*?(<h(3|4))",
		"$3"
		) />

	<!--- Get rid of 'see also'. --->
	<cfset strFileData = strFileData.ReplaceFirst(
		"<h(3|4)[^>]*>((?!See).)*See[\w\W]*?(<h(3|4))",
		"$3"
		) />

	<!--- Fix table. --->
	<cfset strFileData = strFileData.ReplaceAll(
		"<table",
		"<table border=""1"""
		) />

	<!--- Output file data (Remember: it is a Java string). --->
	#strFileData.ToString()#

</cfloop>

This is a smaller version of what I did, but the end result is a rather nice version of the ColdFusion Function definitions. The help docs themselves were not totally consistent, so not all of the headers come out looking perfect, but it's pretty darn close.

One cool thing about what I am doing above is that I am reading the file data in as a string but then I am using the underlying Java String::ReplaceAll() and Java String::ReplaceFirst() methods. Sweeeet.

I will be doing the CFML tags in the same way and those will be accessible at http://www.bennadel.com/cfml/.

Want to use code from this post? Check out the license.

Reader Comments

357 Comments

Maybe consider using frames. THe left frame would just be an alpha list of the funcs/tags.

Of course, it is nice having it as one simple page. Right now I use cfQuickDocs for all my doc needs, but I may download yours for times when I'm offline.

15,841 Comments

Yeah, the frames thing would be nice for presentation, but exactly as your are saying, its nice to have them all in one page to just scroll through. The problem is, there is too much info and printing it out to read on the train (as I did), is akin to just having a CFMX reference book. I guess the difference is that the help docs are *free* and you would have to buy a book. But I think its gonna be nice to be able to just hit up bennadel.com/cfml/ to get a quick guide.

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel