public void writeEclDoc(EclDocWriter w) throws IOException { String desc = getDocumentation().getDescription(); desc = CoreUtils.isBlank(desc) ? getName() : desc; w.text(desc); // -- EclDocParameter inputParam = null; ArrayList<EclDocParameter> params = new ArrayList<EclDocParameter>(); for (EclDocParameter p : getParameters()) { if (p.isInput()) { inputParam = p; continue; } if (p.isInternal()) continue; params.add(p); } if (inputParam != null) { w.dl(); { w.dt("Input:"); writeParam(inputParam, w); } w.close(); } if (params.size() > 0) { w.dl(); { w.dt("Parameters:"); for (EclDocParameter p : params) writeParam(p, w); } w.close(); } // -- String returns = getDocumentation().getReturns(); if (!CoreUtils.isBlank(returns)) { w.dl(); { w.dt("Output:"); w.dd(returns); } w.close(); } String example = getDocumentation().getExample(); if (!CoreUtils.isBlank(example)) { w.dl(); { w.dt("Example:"); w.dd(); { w.pre(example); } w.close(); } w.close(); } }
private static void writeParam(EclDocParameter param, EclDocWriter w) throws IOException { w.dd(); { w.b(param.getName()); int lower = param.getLowerBound(); int upper = param.getUpperBound(); if (upper != lower) { if (lower == 0 && upper == 1) { w.raw(" optional"); } else { w.raw(" ("); if (upper >= lower) { w.raw(lower); w.raw(", "); w.raw(upper); } else { w.raw(lower); w.raw(", "); w.raw("∞"); } w.raw(")"); } } else if (lower != 1) { w.raw(" "); w.raw(lower); } w.raw(" "); w.raw(param.getFriendlyTypeName()); if (param.isOptional()) { String literal = param.getFriendlyDefaultLiteral(); if (!CoreUtils.isBlank(literal)) { w.raw(" = "); w.raw(literal); } } String paramDesc = param.getDocumentation().getDescription(); if (!CoreUtils.isBlank(paramDesc)) { w.raw(": "); w.raw(paramDesc); } } w.close(); }