Search in sources :

Example 1 with RubyTypeTable

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();
}
Also used : RubyTypeTable(com.google.api.codegen.util.ruby.RubyTypeTable) ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) ProtoApiModel(com.google.api.codegen.config.ProtoApiModel) GrpcDocView(com.google.api.codegen.viewmodel.GrpcDocView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 2 with RubyTypeTable

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();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) FeatureConfig(com.google.api.codegen.transformer.FeatureConfig) ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) GapicInterfaceContext(com.google.api.codegen.transformer.GapicInterfaceContext) ViewModel(com.google.api.codegen.viewmodel.ViewModel) InterfaceModel(com.google.api.codegen.config.InterfaceModel) RubyTypeTable(com.google.api.codegen.util.ruby.RubyTypeTable) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 3 with RubyTypeTable

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");
}
Also used : RubyTypeTable(com.google.api.codegen.util.ruby.RubyTypeTable) TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) Test(org.junit.Test)

Aggregations

RubyTypeTable (com.google.api.codegen.util.ruby.RubyTypeTable)3 ModelTypeTable (com.google.api.codegen.transformer.ModelTypeTable)2 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)2 InterfaceModel (com.google.api.codegen.config.InterfaceModel)1 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)1 FeatureConfig (com.google.api.codegen.transformer.FeatureConfig)1 GapicInterfaceContext (com.google.api.codegen.transformer.GapicInterfaceContext)1 GrpcDocView (com.google.api.codegen.viewmodel.GrpcDocView)1 ViewModel (com.google.api.codegen.viewmodel.ViewModel)1 EnumValue (com.google.api.tools.framework.model.EnumValue)1 TypeRef (com.google.api.tools.framework.model.TypeRef)1 ImmutableList (com.google.common.collect.ImmutableList)1 Test (org.junit.Test)1