Search in sources :

Example 1 with JSCommentReformatter

use of com.google.api.codegen.util.js.JSCommentReformatter 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 JSCommentReformatter

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

the class ProtoDocumentLinkTest method testJSCommentReformatter.

@Test
public void testJSCommentReformatter() {
    JSCommentReformatter commentReformatter = new JSCommentReformatter();
    Truth.assertThat(commentReformatter.reformat("[Shelf][google.example.library.v1.Shelf]")).isEqualTo("Shelf");
    Truth.assertThat(commentReformatter.reformat("[$Shelf][google.example.library.v1.Shelf]")).isEqualTo("$Shelf");
    // Cloud link may contain special character '$'
    Truth.assertThat(commentReformatter.reformat("[cloud docs!](/library/example/link)")).isEqualTo("[cloud docs!](https://cloud.google.com/library/example/link)");
    Truth.assertThat(commentReformatter.reformat("[cloud docs!](/library/example/link$)")).isEqualTo("[cloud docs!](https://cloud.google.com/library/example/link$)");
    // Absolute link may contain special character '$'
    Truth.assertThat(commentReformatter.reformat("[not a cloud link](http://www.google.com)")).isEqualTo("[not a cloud link](http://www.google.com)");
    Truth.assertThat(commentReformatter.reformat("[not a cloud link](http://www.google.com$)")).isEqualTo("[not a cloud link](http://www.google.com$)");
}
Also used : JSCommentReformatter(com.google.api.codegen.util.js.JSCommentReformatter) Test(org.junit.Test)

Aggregations

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