private void renderDocumentation( Element element, SignatureInfo signatureInfo, Optional<Integer> activeParameter) { if (signatureInfo.getDocumentation().isPresent()) { elemental.html.DivElement documentation = Elements.createDivElement(resources.css().documentation()); documentation.setTextContent(signatureInfo.getDocumentation().get()); element.appendChild(documentation); } if (signatureInfo.getParameters().isPresent() && activeParameter.isPresent() && signatureInfo.getParameters().get().size() > activeParameter.get()) { ParameterInfo parameterInfo = signatureInfo.getParameters().get().get(activeParameter.get()); if (parameterInfo.getDocumentation().isPresent()) { elemental.html.DivElement parameter = Elements.createDivElement(resources.css().documentationParameter()); SpanElement label = Elements.createSpanElement(resources.css().documentationParameter()); label.setTextContent(parameterInfo.getLabel()); SpanElement documentation = Elements.createSpanElement(resources.css().documentation()); documentation.setTextContent(parameterInfo.getDocumentation().get()); parameter.appendChild(label); parameter.appendChild(documentation); element.appendChild(parameter); } } }
private void renderParameters( Element parent, SignatureInfo signatureInfo, Optional<Integer> activeParameter) { int end = signatureInfo.getLabel().length(); int idx; Element element; for (int i = signatureInfo.getParameters().get().size() - 1; i >= 0; i--) { ParameterInfo parameterInfo = signatureInfo.getParameters().get().get(i); idx = signatureInfo.getLabel().lastIndexOf(parameterInfo.getLabel(), end); int signatureLabelOffset = 0; int signatureLabelEnd = 0; if (idx >= 0) { signatureLabelOffset = idx; signatureLabelEnd = idx + parameterInfo.getLabel().length(); } element = Elements.createSpanElement(); element.setTextContent(signatureInfo.getLabel().substring(signatureLabelEnd, end)); parent.insertBefore(element, parent.getFirstElementChild()); element = Elements.createSpanElement(resources.css().parameter()); if (activeParameter.isPresent() && i == activeParameter.get()) { Elements.addClassName(resources.css().active(), element); } element.setTextContent( signatureInfo.getLabel().substring(signatureLabelOffset, signatureLabelEnd)); parent.insertBefore(element, parent.getFirstElementChild()); end = signatureLabelOffset; } element = Elements.createSpanElement(); element.setTextContent(signatureInfo.getLabel().substring(0, end)); parent.insertBefore(element, parent.getFirstElementChild()); }
private Element renderSignature( Element signatures, SignatureInfo signatureInfo, Optional<Integer> activeParameter) { Element signatureElement = Elements.createDivElement(); signatures.appendChild(signatureElement); Element code = Elements.createDivElement(); signatureElement.appendChild(code); boolean hasParameters = signatureInfo.getParameters().isPresent() && !signatureInfo.getParameters().get().isEmpty(); if (hasParameters) { renderParameters(code, signatureInfo, activeParameter); } else { Node label = code.appendChild(Elements.createSpanElement()); label.setTextContent(signatureInfo.getLabel()); } return signatureElement; }