1 /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #include "tensorflow/c/experimental/ops/gen/cpp/renderers/op_comment_renderer.h"
16
17 #include "tensorflow/c/experimental/ops/gen/cpp/views/op_view.h"
18
19 namespace tensorflow {
20 namespace generator {
21 namespace cpp {
22
OpCommentRenderer(RendererContext context,OpView op)23 OpCommentRenderer::OpCommentRenderer(RendererContext context, OpView op)
24 : Renderer(context), op_(op) {}
25
Render()26 void OpCommentRenderer::Render() {
27 if (context_.mode == RendererContext::kHeader) {
28 // Add a short 1-line comment to the header files.
29 CommentLine(op_.Summary());
30 return;
31 }
32
33 CommentLine("Op: $0()", op_.FunctionName());
34 CommentLine("Summary: $0", op_.Summary());
35 CommentLine("");
36 CommentLine("Description:");
37 for (const auto& line : op_.Description()) {
38 CommentLine(" $0", line);
39 }
40 }
41
42 } // namespace cpp
43 } // namespace generator
44 } // namespace tensorflow
45