Include docs for both bukkit and canary event helpers.

This commit is contained in:
walterhiggins 2014-11-09 11:52:10 +00:00
parent 55b07fd4a6
commit 3ec582f653
5 changed files with 1625 additions and 174 deletions

View file

@ -11,7 +11,8 @@
<!-- compiles against these libraries -->
<property name="lib.canary" location="lib/CanaryMod-1.7.10-1.1.3-SNAPSHOT-shaded.jar"/>
<property name="lib.bukkit" location="lib/bukkit-1.7.9-R0.2.jar"/>
<!-- property name="lib.bukkit" location="lib/bukkit-1.7.9-R0.2.jar"/ -->
<property name="lib.bukkit" location="lib/bukkit-1.7.10-R0.1-SNAPSHOT.jar"/>
<property name="build" location="target/classes"/>
<property name="dist" location="target/" />
@ -29,6 +30,7 @@
<classpath>
<pathelement path="${build}"/>
<pathelement path="${lib.canary}"/>
<pathelement path="${lib.bukkit}"/>
</classpath>
<arg value="@{src}"/>
<js-args/>
@ -82,10 +84,14 @@
<target name="generate-api-ref-entries" depends="copy-js,compile-docs,init">
<jscript src="src/docs/js/generateApiDocs.js" out="${dist}/apiref.md" err="${dist}/gen-api-error.log">
<jscript src="src/docs/js/generateApiDocs.js"
out="${dist}/apiref.md"
err="${dist}/gen-api-error.log">
<arg value="${dist}/js"/>
</jscript>
<jscript src="src/docs/js/generateItemsDoc.js" out="${dist}/items.md" err="${dist}/gen-items-error.log" />
<jscript src="src/docs/js/generateItemsDoc.js"
out="${dist}/items.md"
err="${dist}/gen-items-error.log" />
<concat destfile="${dist}/apiref-con.md">
<fileset file="${dist}/apiref.md" />
<fileset file="${dist}/items.md" />
@ -93,11 +99,11 @@
</target>
<target name="gen-events-helper-canary" depends="compile-docs,init">
<mkdir dir="${dist}/js/lib"/>
<jscript src="src/docs/js/generateEventsHelper.js" out="${dist}/js/lib/events-helper.js" err="${dist}/gen-events-canary-error.log">
<jscript src="src/docs/js/generateEventsHelper.js"
out="${dist}/js/lib/events-helper-canary.js"
err="${dist}/gen-events-canary-error.log">
<arg value="canary"/>
<arg value="${lib.canary}"/>
<arg value="blockDestroy"/>
@ -107,10 +113,12 @@
<target name="gen-events-helper-bukkit" depends="compile-docs,init">
<mkdir dir="${dist}/js/lib"/>
<jscript src="src/docs/js/generateEventsHelper.js" out="${dist}/js/lib/events-helper.js" err="${dist}/gen-events-bukkit-error.log">
<jscript src="src/docs/js/generateEventsHelper.js"
out="${dist}/js/lib/events-helper-bukkit.js"
err="${dist}/gen-events-bukkit-error.log">
<arg value="bukkit"/>
<arg value="${lib.canary}"/>
<arg value="Break"/>
<arg value="${lib.bukkit}"/>
<arg value="blockBreak"/>
<arg value="org.bukkit.event.block.BlockBreakEvent"/>
</jscript>
</target>
@ -133,13 +141,17 @@ Walter Higgins
</target>
<target name="gen-toc-apiref" depends="compile-docs,generate-api-ref-entries, init" description="Generate Table of Contents for API Reference">
<jscript src="src/docs/js/generateTOC.js" out="${dist}/toc-apiref.md" err="${dist}/gen-toc-error.log">
<jscript src="src/docs/js/generateTOC.js"
out="${dist}/toc-apiref.md"
err="${dist}/gen-toc-error.log">
<arg value="${dist}/apiref-con.md"/>
</jscript>
</target>
<target name="gen-toc-ypgpm" depends="compile-docs,init" description="Generate Table of Contents for Young Programmers Guide">
<jscript src="src/docs/js/generateTOC.js" out="${dist}/toc-ypgpm.md" err="${dist}/gen-ypgpm-error.log">
<jscript src="src/docs/js/generateTOC.js"
out="${dist}/toc-ypgpm.md"
err="${dist}/gen-ypgpm-error.log">
<arg value="src/docs/templates/ypgpm.md"/>
</jscript>
</target>
@ -157,7 +169,7 @@ Walter Higgins
<target name="zip_js" depends="zip_lib, zip_modules, zip_plugins">
</target>
<target name="copy-js" depends="gen-events-helper-canary,init">
<target name="copy-js" depends="gen-events-helper-canary,gen-events-helper-bukkit,init">
<copy todir="${dist}/js">
<fileset dir="src/main/js"/>
</copy>

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ var File = java.io.File,
entry = null;
var content = [
'/*********************',
'## Events Helper Module',
'## Events Helper Module (' + args[0] + ' version)',
'The Events helper module provides a suite of functions - one for each possible event.',
'For example, the events.' + args[2] + '() function is just a wrapper function which calls events.on(' + args[3] + ', callback, priority)',
'This module is a convenience wrapper for easily adding new event handling functions in Javascript. ',
@ -29,13 +29,18 @@ var content = [
'',
'***/'
];
var canary = false;
if (args[0] == 'canary'){
canary = true;
}
for (var i = 0; i< content.length; i++){
out.println(content[i]);
}
while ( ( entry = zis.nextEntry) != null) {
var name = new String( entry.name );
var re1 = /org\/bukkit\/event\/.+Event\.class$/;
if (args[0] == 'canary'){
if (canary){
re1 = /net\/canarymod\/hook\/.+Hook\.class$/;
}
if ( re1.test(name) ) {
@ -43,6 +48,7 @@ while ( ( entry = zis.nextEntry) != null) {
try {
clz = java.lang.Class.forName(name);
}catch ( e) {
err.println('Warning: could not Class.forName("' + name + '")');
clz = engine.eval(name);
}
var isAbstract = Modifier.isAbstract(clz.getModifiers());
@ -51,28 +57,28 @@ while ( ( entry = zis.nextEntry) != null) {
}
var parts = name.split('.');
var shortName = null;
if (args[0] == 'canary'){
if (canary){
shortName = name.replace('net.canarymod.hook.','');
}
if (args[0] == 'bukkit'){
if (!canary){
shortName = name.replace('org.bukkit.event.','');
}
var fname = parts.reverse().shift().replace(/^(.)/,function(a){
return a.toLowerCase();});
if (args[0] == 'bukkit'){
if (!canary){
fname = fname.replace(/Event$/,'');
}
if (args[0] == 'canary'){
if (canary){
fname = fname.replace(/Hook$/,'');
}
var javaDoc = canary ? 'https://ci.visualillusionsent.net/job/CanaryLib/javadoc/net/canarymod/hook/' : 'http://jd.bukkit.org/rb/apidocs/org/bukkit/event/';
var comment = [
'/*********************',
'### events.' + fname + '()',
'',
'#### Parameters ',
'',
' * callback - A function which is called whenever the ['+ shortName + ' event](http://jd.bukkit.org/rb/apidocs/org/bukkit/event/' + shortName.replace('.','/') + '.html) is fired',
' * callback - A function which is called whenever the ['+ shortName + ' event](' + javaDoc + shortName.replace('.','/') + '.html) is fired',
'',
' * priority - optional - see events.on() for more information.',
'',

View file

@ -64,13 +64,14 @@ myBlockBreakListener.unregister();
[buk]: http://jd.bukkit.org/dev/apidocs/index.html?org/bukkit/event/Event.html
***/
var helper;
if (__plugin.canary){
module.exports = require('events-canary');
helper = require('events-helper-canary');
} else {
module.exports = require('events-bukkit');
helper = require('events-helper-bukkit');
}
var helper = require('events-helper');
for ( var func in helper ) {
module.exports[func] = helper[func];
};