Search in sources :

Example 6 with ParamDocView

use of com.google.api.codegen.viewmodel.ParamDocView in project toolkit by googleapis.

the class PhpApiMethodParamTransformer method getOptionalArrayParamDoc.

private ParamDocView getOptionalArrayParamDoc(GapicMethodContext context, Iterable<FieldModel> fields) {
    MapParamDocView.Builder paramDoc = MapParamDocView.newBuilder();
    Name optionalArgsName = Name.from("optional", "args");
    paramDoc.paramName(context.getNamer().localVarName(optionalArgsName));
    paramDoc.typeName(context.getNamer().getOptionalArrayTypeName());
    paramDoc.firstLine("Optional.");
    paramDoc.remainingLines(ImmutableList.<String>of());
    paramDoc.arrayKeyDocs(ImmutableList.<ParamDocView>builder().addAll(getMethodParamDocs(context, fields)).addAll(getCallSettingsParamDocList(context)).build());
    return paramDoc.build();
}
Also used : MapParamDocView(com.google.api.codegen.viewmodel.MapParamDocView) MapParamDocView(com.google.api.codegen.viewmodel.MapParamDocView) SimpleParamDocView(com.google.api.codegen.viewmodel.SimpleParamDocView) ParamDocView(com.google.api.codegen.viewmodel.ParamDocView) Name(com.google.api.codegen.util.Name)

Example 7 with ParamDocView

use of com.google.api.codegen.viewmodel.ParamDocView in project toolkit by googleapis.

the class RubyApiMethodParamTransformer method generateMethodParamDocs.

private List<ParamDocView> generateMethodParamDocs(GapicMethodContext context, Iterable<FieldModel> fields) {
    SurfaceNamer namer = context.getNamer();
    MethodConfig methodConfig = context.getMethodConfig();
    ImmutableList.Builder<ParamDocView> docs = ImmutableList.builder();
    for (FieldModel field : fields) {
        if (isRequestTokenParam(methodConfig, field)) {
            continue;
        }
        SimpleParamDocView.Builder paramDoc = SimpleParamDocView.newBuilder();
        paramDoc.paramName(namer.getVariableName(field));
        paramDoc.typeName(namer.getParamTypeName(context.getTypeTable(), field.getType()));
        ImmutableList.Builder<String> docLines = ImmutableList.builder();
        if (isPageSizeParam(methodConfig, field)) {
            docLines.add("The maximum number of resources contained in the underlying API", "response. If page streaming is performed per-resource, this", "parameter does not affect the return value. If page streaming is", "performed per-page, this determines the maximum number of", "resources in a page.");
        } else {
            docLines.addAll(namer.getDocLines(field));
            boolean isMessageField = field.isMessage() && !field.isMap();
            boolean isMapContainingMessage = field.isMap() && field.getMapValueField().isMessage();
            if (isMessageField || isMapContainingMessage) {
                String messageType;
                if (isMapContainingMessage) {
                    messageType = context.getTypeTable().getFullNameForElementType(field.getMapValueField());
                } else {
                    messageType = context.getTypeTable().getFullNameForElementType(field);
                }
                docLines.add(String.format("A hash of the same form as `%s`", messageType));
                docLines.add("can also be provided.");
            }
        }
        paramDoc.lines(docLines.build());
        docs.add(paramDoc.build());
    }
    return docs.build();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) SimpleParamDocView(com.google.api.codegen.viewmodel.SimpleParamDocView) ImmutableList(com.google.common.collect.ImmutableList) SimpleParamDocView(com.google.api.codegen.viewmodel.SimpleParamDocView) ParamDocView(com.google.api.codegen.viewmodel.ParamDocView) FieldModel(com.google.api.codegen.config.FieldModel) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 8 with ParamDocView

use of com.google.api.codegen.viewmodel.ParamDocView in project toolkit by googleapis.

the class NodeJSApiMethodParamTransformer method generateMethodParamDocs.

private List<ParamDocView> generateMethodParamDocs(GapicMethodContext context, Iterable<FieldModel> fields, boolean isOptional) {
    SurfaceNamer namer = context.getNamer();
    MethodConfig methodConfig = context.getMethodConfig();
    ImmutableList.Builder<ParamDocView> docs = ImmutableList.builder();
    for (FieldModel field : fields) {
        if (isRequestTokenParam(methodConfig, field)) {
            continue;
        }
        SimpleParamDocView.Builder paramDoc = SimpleParamDocView.newBuilder();
        String paramName = "request." + namer.getVariableName(field);
        if (isOptional) {
            paramName = String.format("[%s]", paramName);
        }
        paramDoc.paramName(paramName);
        String typeName = namer.getParamTypeName(context.getTypeTable(), field.getType());
        paramDoc.typeName(typeName);
        List<String> fieldDocLines = namer.getDocLines(field);
        ImmutableList.Builder<String> docLines = ImmutableList.builder();
        if (isPageSizeParam(methodConfig, field)) {
            docLines.add("The maximum number of resources contained in the underlying API", "response. If page streaming is performed per-resource, this", "parameter does not affect the return value. If page streaming is", "performed per-page, this determines the maximum number of", "resources in a page.");
        } else {
            docLines.addAll(fieldDocLines);
        }
        paramDoc.lines(docLines.build());
        docs.add(paramDoc.build());
    }
    return docs.build();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) SimpleParamDocView(com.google.api.codegen.viewmodel.SimpleParamDocView) ImmutableList(com.google.common.collect.ImmutableList) SimpleParamDocView(com.google.api.codegen.viewmodel.SimpleParamDocView) ParamDocView(com.google.api.codegen.viewmodel.ParamDocView) FieldModel(com.google.api.codegen.config.FieldModel) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 9 with ParamDocView

use of com.google.api.codegen.viewmodel.ParamDocView in project toolkit by googleapis.

the class PythonApiMethodParamTransformer method generateMethodParamDocs.

private List<ParamDocView> generateMethodParamDocs(GapicMethodContext context, Iterable<FieldModel> fields) {
    SurfaceNamer namer = context.getNamer();
    MethodConfig methodConfig = context.getMethodConfig();
    ImmutableList.Builder<ParamDocView> docs = ImmutableList.builder();
    for (FieldModel field : fields) {
        if (isRequestTokenParam(methodConfig, field)) {
            continue;
        }
        SimpleParamDocView.Builder paramDoc = SimpleParamDocView.newBuilder();
        paramDoc.paramName(namer.getVariableName(field));
        paramDoc.typeName(namer.getParamTypeName(context.getTypeTable(), field.getType()));
        ImmutableList.Builder<String> docLines = ImmutableList.builder();
        if (isPageSizeParam(methodConfig, field)) {
            docLines.add("The maximum number of resources contained in the", "underlying API response. If page streaming is performed per-", "resource, this parameter does not affect the return value. If page", "streaming is performed per-page, this determines the maximum number", "of resources in a page.");
        } else {
            docLines.addAll(namer.getDocLines(field));
            boolean isMessageField = field.isMessage() && !field.isMap();
            boolean isMapContainingMessage = field.isMap() && field.getMapValueField().isMessage();
            if (isMessageField || isMapContainingMessage) {
                String messageType;
                if (isMapContainingMessage) {
                    messageType = context.getTypeTable().getFullNameForElementType(field.getMapValueField());
                } else {
                    messageType = context.getTypeTable().getFullNameForElementType(field);
                }
                docLines.add("If a dict is provided, it must be of the same form as the protobuf", String.format("message :class:`%s`", PythonDocstringUtil.napoleonType(messageType, namer.getVersionedDirectoryNamespace())));
            }
        }
        paramDoc.lines(docLines.build());
        docs.add(paramDoc.build());
    }
    return docs.build();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) SimpleParamDocView(com.google.api.codegen.viewmodel.SimpleParamDocView) ImmutableList(com.google.common.collect.ImmutableList) SimpleParamDocView(com.google.api.codegen.viewmodel.SimpleParamDocView) ParamDocView(com.google.api.codegen.viewmodel.ParamDocView) FieldModel(com.google.api.codegen.config.FieldModel) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Aggregations

ParamDocView (com.google.api.codegen.viewmodel.ParamDocView)9 SimpleParamDocView (com.google.api.codegen.viewmodel.SimpleParamDocView)9 FieldModel (com.google.api.codegen.config.FieldModel)6 ImmutableList (com.google.common.collect.ImmutableList)6 MethodConfig (com.google.api.codegen.config.MethodConfig)5 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)3 MapParamDocView (com.google.api.codegen.viewmodel.MapParamDocView)3 MethodModel (com.google.api.codegen.config.MethodModel)2 Name (com.google.api.codegen.util.Name)2 ArrayList (java.util.ArrayList)2 FieldConfig (com.google.api.codegen.config.FieldConfig)1 InitCodeView (com.google.api.codegen.viewmodel.InitCodeView)1 PathTemplateCheckView (com.google.api.codegen.viewmodel.PathTemplateCheckView)1 RequestObjectMethodDetailView (com.google.api.codegen.viewmodel.RequestObjectMethodDetailView)1 RequestObjectParamView (com.google.api.codegen.viewmodel.RequestObjectParamView)1