Search in sources :

Example 1 with JSTypeTable

use of com.google.api.codegen.util.js.JSTypeTable in project toolkit by googleapis.

the class NodeJSGapicSurfaceDocTransformer method generateDoc.

private ViewModel generateDoc(ProtoFile file, GapicProductConfig productConfig) {
    ModelTypeTable typeTable = new ModelTypeTable(new JSTypeTable(productConfig.getPackageName()), new NodeJSModelTypeNameConverter(productConfig.getPackageName()));
    // Use file path for package name to get file-specific package instead of package for the API.
    SurfaceNamer namer = new NodeJSSurfaceNamer(productConfig.getPackageName(), NodeJSUtils.isGcloud(productConfig));
    JSCommentReformatter commentReformatter = new JSCommentReformatter();
    GrpcDocView.Builder doc = GrpcDocView.newBuilder();
    doc.templateFileName(DOC_TEMPLATE_FILENAME);
    doc.outputPath(getOutputPath(namer, file));
    doc.fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer));
    doc.elementDocs(grpcElementDocTransformer.generateElementDocs(typeTable, namer, file));
    return doc.build();
}
Also used : JSTypeTable(com.google.api.codegen.util.js.JSTypeTable) JSCommentReformatter(com.google.api.codegen.util.js.JSCommentReformatter) ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) GrpcDocView(com.google.api.codegen.viewmodel.GrpcDocView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 2 with JSTypeTable

use of com.google.api.codegen.util.js.JSTypeTable in project toolkit by googleapis.

the class NodeJSModelTypeNameConverterTest method testGetEnumValue.

@Test
public void testGetEnumValue() {
    String packageName = "library.v1";
    TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
    EnumValue value = type.getEnumType().getValues().get(0);
    NodeJSModelTypeNameConverter converter = new NodeJSModelTypeNameConverter(packageName);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new JSTypeTable(packageName))).isEqualTo("'GOOD'");
}
Also used : JSTypeTable(com.google.api.codegen.util.js.JSTypeTable) TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) Test(org.junit.Test)

Aggregations

JSTypeTable (com.google.api.codegen.util.js.JSTypeTable)2 ModelTypeTable (com.google.api.codegen.transformer.ModelTypeTable)1 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)1 JSCommentReformatter (com.google.api.codegen.util.js.JSCommentReformatter)1 GrpcDocView (com.google.api.codegen.viewmodel.GrpcDocView)1 EnumValue (com.google.api.tools.framework.model.EnumValue)1 TypeRef (com.google.api.tools.framework.model.TypeRef)1 Test (org.junit.Test)1