Skip to content

Commit 104d644

Browse files
committed
first build commit
1 parent ecb687a commit 104d644

Some content is hidden

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

73 files changed

+8037
-39
lines changed

apidocs/Application.cfc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
component{
2+
3+
this.name = "colddoc_" & hash(getCurrentTemplatePath());
4+
this.sessionManagement = true;
5+
this.sessionTimeout = createTimeSpan(0,0,1,0);
6+
7+
// mappings
8+
this.mappings[ "/colddoc" ] = getDirectoryFromPath( getCurrentTemplatePath() );
9+
10+
rootPath = REReplaceNoCase( this.mappings[ "/colddoc" ], "apidocs(\\|\/)$", "" );
11+
this.mappings[ "/root" ] = rootPath;
12+
this.mappings[ "/javaloader" ] = rootPath & "modules/javaloader/model";
13+
14+
// request start
15+
public boolean function onRequestStart(String targetPage){
16+
return true;
17+
}
18+
19+
}

apidocs/ColdDoc.cfc

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
<cfcomponent hint="Core class for ColdDoc documentation generation framework" output="false">
2+
3+
<!------------------------------------------- PUBLIC ------------------------------------------->
4+
5+
<cffunction name="init" hint="Constructor" access="public" returntype="ColdDoc" output="false">
6+
<cfscript>
7+
variables.instance = {};
8+
9+
return this;
10+
</cfscript>
11+
</cffunction>
12+
13+
<cffunction name="generate" hint="generates the documentation" access="public" returntype="void" output="false">
14+
<cfargument name="inputSource" hint="either, the string directory source, OR an array of structs containing inputDir and inputMapping key" type="any" required="yes">
15+
<cfargument name="inputMapping" hint="the base mapping for the folder. Only required if the inputSource is a string." type="string" required="false" default="">
16+
<cfscript>
17+
var qMetaData = 0;
18+
var source = 0;
19+
20+
if(NOT hasStrategy())
21+
{
22+
throwException("colddoc.StrategyNotSetException", "No Template Strategy has been set.",
23+
"Create a Template Strategy, and set it with setStrategy() before calling generate()");
24+
}
25+
26+
if(isSimpleValue(arguments.inputSource))
27+
{
28+
source = [{ inputDir=arguments.inputSource, inputMapping=arguments.inputMapping }];
29+
}
30+
else
31+
{
32+
source = arguments.inputSource;
33+
}
34+
35+
qMetaData = buildMetaDataCollection(source);
36+
37+
getStrategy().run(qMetaData);
38+
</cfscript>
39+
</cffunction>
40+
41+
<cffunction name="getStrategy" hint="Returns the current document templating strategy that is being userd" access="public" returntype="any" output="false"
42+
colddoc:generic="colddoc.strategy.AbstractTemplateStrategy">
43+
<cfreturn instance.strategy />
44+
</cffunction>
45+
46+
<cffunction name="setStrategy" hint="Set the document templating strategy that is going to be used" access="public" returntype="void" output="false">
47+
<cfargument name="strategy" hint="The strategy object that is called to generate the doc. Usually extends colddoc.strategy.AbstractTemplateStrategy."
48+
type="any" required="true" colddoc:generic="colddoc.strategy.AbstractTemplateStrategy">
49+
<cfset instance.strategy = arguments.strategy />
50+
</cffunction>
51+
52+
<cffunction name="hasStrategy" hint="whether this object has a strategy" access="public" returntype="boolean" output="false">
53+
<cfreturn StructKeyExists(instance, "strategy") />
54+
</cffunction>
55+
56+
<!------------------------------------------- PACKAGE ------------------------------------------->
57+
58+
<!------------------------------------------- PRIVATE ------------------------------------------->
59+
60+
<cffunction name="buildMetaDataCollection" hint="builds the searchable meta data collection" access="private" returntype="query" output="false">
61+
<cfargument name="inputSource" hint="an array of structs containing inputDir and inputMapping" type="array" required="yes"> <!--- of struct --->
62+
63+
<cfscript>
64+
var qFile = 0;
65+
var qMetaData = QueryNew("package,name,extends,metadata,type,implements,fullextends");
66+
var cfcPath = 0;
67+
var packagePath = 0;
68+
var cfcName = 0;
69+
var meta = 0;
70+
var i = 0;
71+
var implements = 0;
72+
var fullextends = 0;
73+
</cfscript>
74+
75+
<cfloop index="i" from="1" to="#ArrayLen(arguments.inputSource)#">
76+
77+
<cfdirectory action="list" directory="#arguments.inputSource[i].inputDir#" recurse="true" name="qFiles" filter="*.cfc">
78+
79+
<cfloop query="qFiles">
80+
<cfscript>
81+
currentPath = replace(directory, arguments.inputSource[i].inputDir, "");
82+
currentPath = reReplace(currentPath, "[/\\]", "");
83+
currentPath = reReplace(currentPath, "[/\\]", ".", "all");
84+
85+
if(len(currentPath))
86+
{
87+
packagePath = ListAppend(arguments.inputSource[i].inputMapping, currentPath, ".");
88+
}
89+
else
90+
{
91+
packagePath = arguments.inputSource[i].inputMapping;
92+
}
93+
94+
cfcName = ListGetAt(name, 1, ".");
95+
96+
try
97+
{
98+
if (Len(packagePath)) {
99+
meta = getComponentMetaData(packagePath & "." & cfcName);
100+
}
101+
else {
102+
meta = getComponentMetaData(cfcName);
103+
}
104+
105+
//let's do some cleanup, in case CF sucks.
106+
if(Len (packagePath) AND NOT meta.name contains packagePath)
107+
{
108+
meta.name = packagePath & "." & cfcName;
109+
}
110+
111+
QueryAddRow(qMetaData);
112+
QuerySetCell(qMetaData, "package", packagePath);
113+
QuerySetCell(qMetaData, "name", cfcName);
114+
QuerySetCell(qMetaData, "metadata", meta);
115+
QuerySetCell(qMetaData, "type", meta.type);
116+
117+
implements = getImplements(meta);
118+
implements = listQualify(arrayToList(implements), ':');
119+
120+
QuerySetCell(qMetaData, "implements", implements);
121+
122+
fullextends = getInheritence(meta);
123+
fullextends = listQualify(arrayToList(fullextends), ':');
124+
125+
QuerySetCell(qMetaData, "fullextends", fullextends);
126+
127+
//so we cane easily query direct desendents
128+
if(StructKeyExists(meta, "extends"))
129+
{
130+
if(meta.type eq "interface")
131+
{
132+
QuerySetCell(qMetaData, "extends", meta.extends[structKeyList(meta.extends)].name);
133+
}
134+
else
135+
{
136+
QuerySetCell(qMetaData, "extends", meta.extends.name);
137+
}
138+
}
139+
else
140+
{
141+
QuerySetCell(qMetaData, "extends", "-");
142+
}
143+
144+
}
145+
catch(Any exc)
146+
{
147+
warnError(packagePath & "." & cfcName, exc);
148+
}
149+
</cfscript>
150+
</cfloop>
151+
152+
</cfloop>
153+
154+
<cfreturn qMetaData />
155+
</cffunction>
156+
157+
<cffunction name="warnError" hint="Warn the user that there was an error through cftrace" access="private" returntype="void" output="false">
158+
<cfargument name="cfcName" hint="the name of the cfc" type="string" required="Yes">
159+
<cfargument name="error" hint="the error struct" type="any" required="Yes">
160+
<cfset var dump = 0 />
161+
<!---
162+
<cfset _trace(error)>
163+
--->
164+
<cfsetting showdebugoutput="true">
165+
<cftrace category="ColdDoc" inline="true" type="Warning" text="Warning, the following script has errors: #arguments.cfcName#, #toString(arguments.error)#">
166+
</cffunction>
167+
168+
<cffunction name="getImplements" hint="gets an array of the interfaces that this metadata implements" access="private" returntype="array" output="false">
169+
<cfargument name="metadata" hint="the metadata to look at" type="struct" required="Yes">
170+
<cfscript>
171+
var localmeta = arguments.metadata;
172+
var interfaces = {};
173+
var key = 0;
174+
var imeta = 0;
175+
176+
if(arguments.metadata.type neq "component")
177+
{
178+
return ArrayNew(1);
179+
}
180+
181+
while(StructKeyExists(localmeta, "extends"))
182+
{
183+
if(StructKeyExists(localmeta, "implements"))
184+
{
185+
for(key in localmeta.implements)
186+
{
187+
imeta = localmeta.implements[local.key];
188+
interfaces[imeta.name] = 1;
189+
}
190+
}
191+
localmeta = localmeta.extends;
192+
}
193+
194+
interfaces = structKeyArray(interfaces);
195+
196+
arraySort(interfaces, "textnocase");
197+
198+
return interfaces;
199+
</cfscript>
200+
</cffunction>
201+
202+
<cffunction name="getInheritence" hint="gets an array of the classes that this metadata extends, in order of extension" access="private" returntype="array" output="false">
203+
<cfargument name="metadata" hint="the metadata to look at" type="struct" required="Yes">
204+
<cfscript>
205+
{
206+
var localmeta = arguments.metadata;
207+
//ignore top level
208+
var inheritence = [];
209+
210+
while(StructKeyExists(localmeta, "extends"))
211+
{
212+
//manage interfaces
213+
if(localmeta.type eq "interface")
214+
{
215+
localmeta = localmeta.extends[structKeyList(localmeta.extends)];
216+
}
217+
else
218+
{
219+
localmeta = localmeta.extends;
220+
}
221+
222+
ArrayPrepend(inheritence, localmeta.name);
223+
}
224+
225+
return inheritence;
226+
}
227+
</cfscript>
228+
</cffunction>
229+
230+
231+
<cffunction name="_trace">
232+
<cfargument name="s">
233+
<cfset var g = "">
234+
<cfsetting showdebugoutput="true">
235+
<cfsavecontent variable="g">
236+
<cfdump var="#arguments.s#">
237+
</cfsavecontent>
238+
<cftrace text="#g#">
239+
</cffunction>
240+
241+
<cffunction name="_dump">
242+
<cfargument name="s">
243+
<cfargument name="abort" default="true">
244+
<cfset var g = "">
245+
<cfdump var="#arguments.s#">
246+
<cfif arguments.abort>
247+
<cfabort>
248+
</cfif>
249+
</cffunction>
250+
251+
<cffunction name="throwException" access="private" hint="Throws an Exception" output="false">
252+
<cfargument name="type" hint="The type of exception" type="string" required="Yes">
253+
<cfargument name="message" hint="The message to accompany the exception" type="string" required="Yes">
254+
<cfargument name="detail" type="string" hint="The detail message for the exception" required="No" default="">
255+
<cfthrow type="#arguments.type#" message="#arguments.message#" detail="#arguments.detail#">
256+
</cffunction>
257+
258+
259+
</cfcomponent>

apidocs/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ColdDoc 1.0
2+
==========
3+
4+
Thanks for taking the time to look at ColdDoc!
5+
6+
The ColdDoc home page can be found at [http://www.compoundtheory.com/?action=colddoc.index][1]
7+
8+
Documentation for ColdDoc can be found on the [GitHub Wiki][2].
9+
10+
The main Git repository and downloads can be found on [GitHub][3].
11+
12+
For support, the ColdDoc mailing list can be found on [Google Groups][4].
13+
14+
[1]: http://www.compoundtheory.com/?action=colddoc.index
15+
[2]: https://github.com/markmandel/ColdDoc/wiki
16+
[3]: https://github.com/markmandel/ColdDoc
17+
[4]: https://groups.google.com/forum/#!forum/colddoc-dev
18+

apidocs/index.cfm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<cfparam name="url.version" default="0">
2+
<cfparam name="url.path" default="#expandPath( "./JavaLoader-APIDocs" )#">
3+
<cfscript>
4+
docName = "JavaLoader-APIDocs";
5+
base = expandPath( "/javaloader" );
6+
7+
colddoc = new ColdDoc();
8+
strategy = new colddoc.strategy.api.HTMLAPIStrategy( url.path, "JavaLoader v#url.version#" );
9+
colddoc.setStrategy( strategy );
10+
11+
colddoc.generate( inputSource=base, outputDir=url.path, inputMapping="javaloader" );
12+
</cfscript>
13+
14+
<!---
15+
<cfzip action="zip" file="#expandPath('.')#/#docname#.zip" source="#expandPath( docName )#" overwrite="true" recurse="yes">
16+
<cffile action="move" source="#expandPath('.')#/#docname#.zip" destination="#url.path#">
17+
--->
18+
19+
<cfoutput>
20+
<h1>Done!</h1>
21+
<a href="#docName#/index.html">Go to Docs!</a>
22+
</cfoutput>
23+

0 commit comments

Comments
 (0)