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();
}
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();
}
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();
}
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();
}
Aggregations