public void output(Output out) { out.write("("); val.output(out); out.write("."); for (char c : el) out.write(c); out.write(")"); }
public static void main(String[] args) throws Exception { System.out.println("Scan http api"); ApiDocs apiDocs = scan(args); Output output = createOutput(args); String outputDir = getOutputDir(args); System.out.println("Output class: " + output.getClass().getName()); System.out.println("Output dir: " + outputDir); output.output(apiDocs, outputDir, getOutputArgs(args)); }
@Override public void compile() { Debugger debugContext = DinaCompiler.getDebugger(); int variablesWithValue = 0; int variablesAmount = getVariablesAmount(); for (int variableIndex = 0; variableIndex < variablesAmount; variableIndex++) { Variable variable = getVariable(variableIndex); if (variable.getValue() != null) { if (constructor == null) { constructor = new Function(ParserConstants.CONSTRUCTOR); constructor.setStatement(new Block()); constructor.getStatement().setFunction(constructor); } Assignment assignment = new Assignment(variable, variable.getValue()); constructor.getStatement().insertNode(assignment, variablesWithValue); variablesWithValue++; } } if (constructor != null) { Output.writeSystemInformation(Constants.BEGIN_FUNCTION); constructor.compile(); if (Debugger.DEVELOPMENT_MODE) { debugContext.putFunction("<constructor>", constructor.getAddress()); } Output.writeSystemInformation(Constants.END_FUNCTION); } int functionsAmount = functions.size(); for (int functionIndex = 0; functionIndex < functionsAmount; functionIndex++) { Function function = functions.getValue(functionIndex); Output.writeSystemInformation(Constants.BEGIN_FUNCTION); function.compile(); if (Debugger.DEVELOPMENT_MODE) { debugContext.putFunction( function.getSignatureLabel() + function.getNodeType().getSignature(), function.getAddress()); } Output.writeSystemInformation(Constants.END_FUNCTION); } if (destructor != null) { Output.writeSystemInformation(Constants.BEGIN_FUNCTION); destructor.compile(); if (Debugger.DEVELOPMENT_MODE) { debugContext.putFunction("<destructor>", destructor.getAddress()); } Output.writeSystemInformation(Constants.END_FUNCTION); } }
/** * Search for the requested comments in the given method. If it does not have comments, return * documentation from the overriden method if possible. If the overriden method does not exist or * does not have documentation to inherit, search for documentation to inherit from implemented * methods. * * @param input the input object used to perform the search. * @return an Output object representing the documentation that was found. */ public static Output search(Input input) { Output output = new Output(); if (input.isInheritDocTag) { // Do nothing because "method" does not have any documentation. // All it has it {@inheritDoc}. } else if (input.taglet == null) { // We want overall documentation. output.inlineTags = input.isFirstSentence ? input.method.firstSentenceTags() : input.method.inlineTags(); output.holder = input.method; } else { input.taglet.inherit(input, output); } if (output.inlineTags != null && output.inlineTags.length > 0) { return output; } output.isValidInheritDocTag = false; Input inheritedSearchInput = input.copy(); inheritedSearchInput.isInheritDocTag = false; if (input.method.overriddenMethod() != null) { inheritedSearchInput.method = input.method.overriddenMethod(); output = search(inheritedSearchInput); output.isValidInheritDocTag = true; if (output != null && output.inlineTags.length > 0) { return output; } } // NOTE: When we fix the bug where ClassDoc.interfaceTypes() does // not pass all implemented interfaces, we will use the // appropriate method here. MethodDoc[] implementedMethods = (new ImplementedMethods(input.method, null)).build(false); for (int i = 0; i < implementedMethods.length; i++) { inheritedSearchInput.method = implementedMethods[i]; output = search(inheritedSearchInput); output.isValidInheritDocTag = true; if (output != null && output.inlineTags.length > 0) { return output; } } return output; }
@Test public void testDate() { new TypeScriptGenerator(settings(DateMapping.asDate, "AsDate")) .generateTypeScript(Input.from(Dates.class), Output.to(new File("target/test-date.d.ts"))); }