use of com.google.api.codegen.util.ruby.RubyTypeTable in project toolkit by googleapis.
the class RubyGapicSurfaceDocTransformer method generateDoc.
private ViewModel generateDoc(ProtoFile file, GapicProductConfig productConfig) {
ModelTypeTable typeTable = new ModelTypeTable(new RubyTypeTable(productConfig.getPackageName()), new RubyModelTypeNameConverter(productConfig.getPackageName()));
// Use file path for package name to get file-specific package instead of package for the API.
SurfaceNamer namer = new RubySurfaceNamer(typeTable.getFullNameFor(file));
String subPath = pathMapper.getOutputPath(file.getFullName(), productConfig);
String baseFilename = namer.getProtoFileName(file.getSimpleName());
GrpcDocView.Builder doc = GrpcDocView.newBuilder();
doc.templateFileName(DOC_TEMPLATE_FILENAME);
doc.outputPath(subPath + "/doc/" + baseFilename);
doc.fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer));
doc.elementDocs(elementDocTransformer.generateElementDocs(typeTable, namer, file));
doc.modules(generateModuleViews(new ProtoApiModel(file.getModel()), productConfig, namer, isSourceApiInterfaceFile(file) ? file : null, false));
return doc.build();
}
use of com.google.api.codegen.util.ruby.RubyTypeTable in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateApiClasses.
private List<ViewModel> generateApiClasses(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
FeatureConfig featureConfig = new RubyFeatureConfig();
ImmutableList.Builder<ViewModel> serviceSurfaces = ImmutableList.builder();
for (InterfaceModel apiInterface : model.getInterfaces()) {
String packageName = productConfig.getPackageName();
ModelTypeTable modelTypeTable = new ModelTypeTable(new RubyTypeTable(productConfig.getPackageName()), new RubyModelTypeNameConverter(packageName));
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, modelTypeTable, namer, featureConfig);
serviceSurfaces.add(generateApiClass(context, packageName));
}
return serviceSurfaces.build();
}
use of com.google.api.codegen.util.ruby.RubyTypeTable in project toolkit by googleapis.
the class RubyModelTypeNameConverterTest method testGetEnumValue.
@Test
public void testGetEnumValue() {
String packageName = "Library::V1";
TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
EnumValue value = type.getEnumType().getValues().get(0);
RubyModelTypeNameConverter converter = new RubyModelTypeNameConverter(packageName);
Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new RubyTypeTable(packageName))).isEqualTo(":GOOD");
}
Aggregations