Skip to content

Commit

Permalink
Added initial *generated* documentation
Browse files Browse the repository at this point in the history
* removed harmful setActive
  • Loading branch information
Radu Andries committed Aug 29, 2017
1 parent 8eb0d84 commit 308e24d
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 4 deletions.
100 changes: 100 additions & 0 deletions LuaMethods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# TileEntityKineticGenerator

## get_kinetic_production

# TileEntitySteamKineticGenerator

## get_steam_info

## get_water_info

## get_output

## get_turbine_damage

# TileEntityLiquidHeatExchanger

## get_input_tank

## get_output_tank

# TileEntityHeatSourceInventory

## get_heat

# TileEntitySteamGenerator

## get_pressure

## set_pressure

## get_water_input

## set_water_input

## get_calcification

## get_heat_input

## get_system_heat

## get_output_info

## get_water_info

# TileEntityStirlingGenerator

## get_production

# TileEntityElectricBlock

## get_energy

## get_capacity

## get_output

# TileEntityElectricMachine

## get_energy_info

# TileEntityNuclearReactorElectric

## get_eu_output

## get_heat

## get_emit_heat

## get_hot_fluid

## get_cold_fluid

# TileEntityCondenser
This tile entity is used by the condenser
## get_progress
Gets the progress of the operation.

Returns: *(int, int)* - current progress over maximum progress
## get_input_tank
Gets information about the input tank
## get_output_tank
Gets information about the output tank
# TileEntityBlock

## is_active

# TileEntityLiquidTankElectricMachine

## get_fluid_info

# TileEntityFluidRegulator

## get_output_rate

## set_output_rate

## get_mode

## set_mode

28 changes: 26 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ apply plugin: 'kr.motd.sphinx'


version = "1.0"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"
group= "it.antani" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "AntaniCC"

sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
compileJava {
Expand All @@ -30,6 +30,10 @@ repositories {
}
}

sourceSets {
doclet
}

minecraft {
version = "1.10.2-12.18.3.2185"
runDir = "run"
Expand Down Expand Up @@ -66,6 +70,8 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html

docletCompile files("${System.getProperty('java.home')}/../lib/tools.jar")

}

processResources
Expand All @@ -87,3 +93,21 @@ processResources
exclude 'mcmod.info'
}
}

task docletJar(type: Jar) {
from sourceSets.doclet.output
baseName 'LuaDoclet'

dependsOn docletClasses
}

task generateLuaDocs(type: Javadoc){
dependsOn docletJar
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath

title = null

options.doclet = 'it.antani.LuaDocumenter'
options.docletpath = [docletJar.archivePath]
}
82 changes: 82 additions & 0 deletions src/doclet/java/it/antani/LuaDocumenter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package it.antani;

import com.sun.javadoc.*;
import com.sun.tools.javadoc.ClassDocImpl;

import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Paths;

public class LuaDocumenter {
public static boolean start(RootDoc root) {

try {
ClassDoc[] classes = root.classes();
BufferedWriter writer = Files.newBufferedWriter(Paths.get(getPath(root.options())));
for(ClassDoc clazz : classes){
for(AnnotationDesc ann : clazz.annotations()){
if(ann.annotationType().toString().equals("it.antani.cc.annotations.AcceptsTileEntity")){
writeClass(writer, clazz, ann);
}
}
}
writer.flush();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}

private static String getPath(String[][] options){
for(String[] opt: options){
if(opt[0].equals("-d")){
return opt[1] + File.separator + "luaDoc.md";
}
}
throw new RuntimeException("No -d param was provided");
}

public static int optionLength(String option) {
if(option.equals("-d")) {
return 2;
}
return 0;
}

public static boolean validOptions(String options[][],
DocErrorReporter reporter) {
return true;
}


private static void writeClass(BufferedWriter writer, ClassDoc clazz, AnnotationDesc ann) throws IOException{
String tileEntity = ((ClassDocImpl)ann.elementValues()[0].value().value()).asClassDoc().name();
writer.write("# " + tileEntity);
writer.newLine();
writer.write(clazz.commentText());
writer.newLine();
for (MethodDoc m : clazz.methods()){
boolean lua = false;
String method = "";
for(AnnotationDesc mann : m.annotations()){
if(mann.annotationType().toString().equals("it.antani.cc.annotations.LuaMethod")){
lua = true;
method = mann.elementValues()[0].value().value().toString();
break;
}
}
if(lua){
writer.write("## " + method);
writer.newLine();
writer.write(m.commentText());
writer.newLine();
}
}
}


}
14 changes: 14 additions & 0 deletions src/main/java/it/antani/cc/impl/CondenserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@

import java.lang.reflect.Field;

/**
* This tile entity is used by the condenser
*/
@AcceptsTileEntity(TileEntityCondenser.class)
public class CondenserImpl {

/**
* Gets the progress of the operation.
*
* Returns: *(int, int)* - current progress over maximum progress
*/
@LuaMethod("get_progress")
public Object[] getProgress(TileEntityCondenser te, IComputerAccess access, ILuaContext context, Object[] args) throws NoSuchFieldException, IllegalAccessException {
Field f1 = TileEntityCondenser.class.getDeclaredField("progress");
Expand All @@ -23,11 +31,17 @@ public Object[] getProgress(TileEntityCondenser te, IComputerAccess access, ILua
return new Object[] { f1.get(te), f2.get(te) };
}

/**
* Gets information about the input tank
*/
@LuaMethod("get_input_tank")
public Object[] getInputFluid(TileEntityCondenser te, IComputerAccess access, ILuaContext context, Object[] args) throws NoSuchFieldException, IllegalAccessException {
return Utils.getFluidInfo(te.getInputTank());
}

/**
* Gets information about the output tank
*/
@LuaMethod("get_output_tank")
public Object[] getOutput(TileEntityCondenser te, IComputerAccess access, ILuaContext context, Object[] args) throws NoSuchFieldException, IllegalAccessException {
return Utils.getFluidInfo(te.getOutputTank());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/it/antani/cc/impl/CoreIc2Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public Object[] isActive(TileEntityBlock te, IComputerAccess access, ILuaContext
return new Object[] { te.getActive() };
}

@LuaMethod("set_active")
/*@LuaMethod("set_active")
public Object[] setActive(TileEntityBlock te, IComputerAccess access, ILuaContext context, Object[] args) throws NoSuchFieldException, IllegalAccessException, LuaException {
context.issueMainThreadTask(new LuaTileActivator(te, (boolean) args[0]));
return null;
}
}*/

}

0 comments on commit 308e24d

Please sign in to comment.