Search in sources :

Example 1 with Variable

use of org.ballerinalang.docgen.model.Variable in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for enums.
 * @param enumNode ballerina enum node.
 * @return documentation for enum.
 */
public static EnumDoc createDocForNode(EnumNode enumNode) {
    String enumName = enumNode.getName().getValue();
    List<Variable> enumerators = new ArrayList<>();
    // Iterate through the enumerators
    if (enumNode.getEnumerators().size() > 0) {
        for (EnumNode.Enumerator enumerator : enumNode.getEnumerators()) {
            String desc = fieldAnnotation((BLangNode) enumNode, (BLangNode) enumerator);
            Variable variable = new Variable(enumerator.getName().getValue(), "", desc);
            enumerators.add(variable);
        }
    }
    return new EnumDoc(enumName, description((BLangNode) enumNode), new ArrayList<>(), enumerators);
}
Also used : EnumDoc(org.ballerinalang.docgen.model.EnumDoc) BLangNode(org.wso2.ballerinalang.compiler.tree.BLangNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) ArrayList(java.util.ArrayList) EnumNode(org.ballerinalang.model.tree.EnumNode)

Example 2 with Variable

use of org.ballerinalang.docgen.model.Variable in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for connectors.
 * @param connectorNode ballerina connector node.
 * @return documentation for connectors.
 */
public static ConnectorDoc createDocForNode(BLangConnector connectorNode) {
    String connectorName = connectorNode.getName().value;
    List<Variable> parameters = new ArrayList<>();
    List<Documentable> actions = new ArrayList<>();
    // Iterate through the connector parameters
    if (connectorNode.getParameters().size() > 0) {
        for (BLangVariable param : connectorNode.getParameters()) {
            String dataType = type(param);
            String desc = paramAnnotation(connectorNode, param);
            Variable variable = new Variable(param.getName().value, dataType, desc);
            parameters.add(variable);
        }
    }
    // Iterate through the actions of the connectors
    if (connectorNode.getActions().size() > 0) {
        for (BLangAction action : connectorNode.getActions()) {
            actions.add(createDocForNode(action));
        }
    }
    return new ConnectorDoc(connectorName, description(connectorNode), actions, parameters);
}
Also used : BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) Documentable(org.ballerinalang.docgen.model.Documentable) ArrayList(java.util.ArrayList) ConnectorDoc(org.ballerinalang.docgen.model.ConnectorDoc) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction)

Example 3 with Variable

use of org.ballerinalang.docgen.model.Variable in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for functions.
 * @param functionNode ballerina function node.
 * @return documentation for functions.
 */
public static FunctionDoc createDocForNode(BLangFunction functionNode) {
    String functionName = functionNode.getName().value;
    List<Variable> parameters = new ArrayList<>();
    List<Variable> returnParams = new ArrayList<>();
    // Iterate through the parameters
    if (functionNode.getParameters().size() > 0) {
        for (BLangVariable param : functionNode.getParameters()) {
            String dataType = type(param);
            String desc = paramAnnotation(functionNode, param);
            Variable variable = new Variable(param.getName().value, dataType, desc);
            parameters.add(variable);
        }
    }
    // Iterate through the return types
    if (functionNode.getReturnParameters().size() > 0) {
        for (int i = 0; i < functionNode.getReturnParameters().size(); i++) {
            BLangVariable returnParam = functionNode.getReturnParameters().get(i);
            String dataType = type(returnParam);
            String desc = returnParamAnnotation(functionNode, i);
            Variable variable = new Variable(returnParam.getName().value, dataType, desc);
            returnParams.add(variable);
        }
    }
    return new FunctionDoc(functionName, description(functionNode), new ArrayList<>(), parameters, returnParams);
}
Also used : BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) FunctionDoc(org.ballerinalang.docgen.model.FunctionDoc) ArrayList(java.util.ArrayList) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 4 with Variable

use of org.ballerinalang.docgen.model.Variable in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for annotations.
 * @param annotationNode ballerina annotation node.
 * @return documentation for annotation.
 */
public static AnnotationDoc createDocForNode(BLangAnnotation annotationNode) {
    String annotationName = annotationNode.getName().getValue();
    List<Variable> attributes = new ArrayList<>();
    // Iterate through the attributes of the annotation
    if (annotationNode.getAttributes().size() > 0) {
        for (BLangAnnotAttribute annotAttribute : annotationNode.getAttributes()) {
            String dataType = getTypeName(annotAttribute.getTypeNode());
            String desc = annotFieldAnnotation(annotationNode, annotAttribute);
            Variable variable = new Variable(annotAttribute.getName().value, dataType, desc);
            attributes.add(variable);
        }
    }
    return new AnnotationDoc(annotationName, description(annotationNode), new ArrayList<>(), attributes);
}
Also used : AnnotationDoc(org.ballerinalang.docgen.model.AnnotationDoc) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) ArrayList(java.util.ArrayList) BLangAnnotAttribute(org.wso2.ballerinalang.compiler.tree.BLangAnnotAttribute)

Example 5 with Variable

use of org.ballerinalang.docgen.model.Variable in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for actions.
 * @param actionNode ballerina action node.
 * @return documentation for actions.
 */
public static ActionDoc createDocForNode(BLangAction actionNode) {
    String actionName = actionNode.getName().value;
    List<Variable> parameters = new ArrayList<>();
    List<Variable> returnParams = new ArrayList<>();
    // Iterate through the parameters
    if (actionNode.getParameters().size() > 0) {
        for (BLangVariable param : actionNode.getParameters()) {
            String dataType = type(param);
            String desc = paramAnnotation(actionNode, param);
            Variable variable = new Variable(param.getName().value, dataType, desc);
            parameters.add(variable);
        }
    }
    // Iterate through the return types
    if (actionNode.getReturnParameters().size() > 0) {
        for (int i = 0; i < actionNode.getReturnParameters().size(); i++) {
            BLangVariable returnParam = actionNode.getReturnParameters().get(i);
            String dataType = type(returnParam);
            String desc = returnParamAnnotation(actionNode, i);
            Variable variable = new Variable(returnParam.getName().value, dataType, desc);
            returnParams.add(variable);
        }
    }
    return new ActionDoc(actionName, description(actionNode), new ArrayList<>(), parameters, returnParams);
}
Also used : ActionDoc(org.ballerinalang.docgen.model.ActionDoc) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) ArrayList(java.util.ArrayList) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Aggregations

ArrayList (java.util.ArrayList)5 Variable (org.ballerinalang.docgen.model.Variable)5 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)5 ActionDoc (org.ballerinalang.docgen.model.ActionDoc)1 AnnotationDoc (org.ballerinalang.docgen.model.AnnotationDoc)1 ConnectorDoc (org.ballerinalang.docgen.model.ConnectorDoc)1 Documentable (org.ballerinalang.docgen.model.Documentable)1 EnumDoc (org.ballerinalang.docgen.model.EnumDoc)1 FunctionDoc (org.ballerinalang.docgen.model.FunctionDoc)1 EnumNode (org.ballerinalang.model.tree.EnumNode)1 BLangAction (org.wso2.ballerinalang.compiler.tree.BLangAction)1 BLangAnnotAttribute (org.wso2.ballerinalang.compiler.tree.BLangAnnotAttribute)1 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)1