use of com.google.api.codegen.viewmodel.ServiceDocView in project toolkit by googleapis.
the class CSharpGapicClientTransformer method generateCsProjView.
private PackageInfoView generateCsProjView(GapicInterfaceContext context) {
Model model = context.getModel();
GapicProductConfig productConfig = context.getProductConfig();
PackageInfoView.Builder view = PackageInfoView.newBuilder();
view.templateFileName(CSPROJ_TEMPLATE_FILENAME);
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), productConfig);
view.outputPath(outputPath + File.separator + productConfig.getPackageName() + ".csproj");
view.fileHeader(fileHeaderTransformer.generateFileHeader(context));
view.serviceTitle(model.getServiceConfig().getTitle());
view.serviceDescription(model.getServiceConfig().getDocumentation().getSummary().trim());
view.domainLayerLocation(productConfig.getDomainLayerLocation());
// Unused in C#
view.authScopes(new ArrayList<String>());
view.releaseLevel(productConfig.getReleaseLevel());
String versionSuffix;
switch(productConfig.getReleaseLevel()) {
case ALPHA:
versionSuffix = "-alpha01";
break;
case BETA:
versionSuffix = "-beta01";
break;
default:
versionSuffix = "";
break;
}
view.version("1.0.0" + versionSuffix);
String tags = "";
for (String tag : Splitter.on('.').split(productConfig.getPackageName())) {
if (tag.matches("[vV][\\d.]+")) {
break;
}
tags += ";" + tag;
}
view.tags(tags.isEmpty() ? "" : tags.substring(1));
view.packageMetadata(generatePackageMetadataView(context));
view.serviceDocs(new ArrayList<ServiceDocView>());
return view.build();
}
use of com.google.api.codegen.viewmodel.ServiceDocView in project toolkit by googleapis.
the class JavaSurfaceTransformer method transform.
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = surfaceTransformer.createSurfaceNamer(productConfig);
List<ServiceDocView> serviceDocs = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces()) {
boolean enableStringFormatFunctions = productConfig.getResourceNameMessageConfigs().isEmpty();
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
StaticLangFileView<StaticLangApiView> apiFile = generateApiFile(context, productConfig);
surfaceDocs.add(apiFile);
serviceDocs.add(apiFile.classView().doc());
StaticLangApiMethodView exampleApiMethod = getExampleApiMethod(apiFile.classView().apiMethods());
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangStubSettingsView> stubSettingsFile = generateStubSettingsFile(context, productConfig, exampleApiMethod);
context = context.withNewTypeTable(namer.getRootPackageName());
StaticLangFileView<StaticLangSettingsView> settingsFile = generateSettingsFile(context, productConfig, exampleApiMethod, stubSettingsFile.classView());
surfaceDocs.add(settingsFile);
surfaceDocs.add(stubSettingsFile);
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangStubInterfaceView> stubInterfaceFile = generateStubInterfaceFile(context, productConfig);
surfaceDocs.add(stubInterfaceFile);
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangRpcStubView> grpcStubFile = generateRpcStubClassFile(context, productConfig);
surfaceDocs.add(grpcStubFile);
surfaceDocs.add(generateCallableFactoryClassFile(context, productConfig));
}
PackageInfoView packageInfo = generatePackageInfo(model, productConfig, namer, serviceDocs);
surfaceDocs.add(packageInfo);
return surfaceDocs;
}
use of com.google.api.codegen.viewmodel.ServiceDocView in project toolkit by googleapis.
the class ServiceTransformer method generateServiceDoc.
public ServiceDocView generateServiceDoc(InterfaceContext context, ApiMethodView exampleApiMethod, GapicProductConfig productConfig) {
SurfaceNamer namer = context.getNamer();
ServiceDocView.Builder serviceDoc = ServiceDocView.newBuilder();
ImmutableList.Builder<String> docLines = ImmutableList.builder();
docLines.addAll(namer.getDocLines(context.getInterfaceDescription()));
InterfaceConfig conf = context.getInterfaceConfig();
if (!conf.getManualDoc().isEmpty()) {
docLines.add("");
docLines.addAll(namer.getDocLines(conf.getManualDoc()));
}
List<String> lines = docLines.build();
serviceDoc.lines(lines);
if (lines.isEmpty()) {
serviceDoc.firstLine("");
serviceDoc.remainingLines(ImmutableList.<String>of());
} else {
serviceDoc.firstLine(lines.get(0));
serviceDoc.remainingLines(lines.subList(1, lines.size()));
}
serviceDoc.exampleApiMethod(exampleApiMethod);
serviceDoc.apiVarName(namer.getApiWrapperVariableName(context.getInterfaceConfig()));
serviceDoc.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
serviceDoc.settingsVarName(namer.getApiSettingsVariableName(context.getInterfaceConfig()));
serviceDoc.settingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
serviceDoc.hasDefaultInstance(context.getInterfaceConfig().hasDefaultInstance());
serviceDoc.serviceTitle(context.serviceTitle());
serviceDoc.defaultTransportProviderBuilder(namer.getDefaultTransportProviderBuilder(productConfig.getTransportProtocol()));
serviceDoc.defaultChannelProviderBuilder(namer.getDefaultChannelProviderBuilder(productConfig.getTransportProtocol()));
return serviceDoc.build();
}
Aggregations