From 439a265760e7421cec2c7ca3ea1b9e6a3c24b673 Mon Sep 17 00:00:00 2001 From: yuyang18 Date: Fri, 8 Jun 2018 16:01:35 +0800 Subject: [PATCH] Better trim dot --- python/paddle/fluid/layers/control_flow.py | 2 +- .../fluid/layers/layer_function_generator.py | 14 ++++++++++---- python/paddle/fluid/layers/tensor.py | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/python/paddle/fluid/layers/control_flow.py b/python/paddle/fluid/layers/control_flow.py index b32248ad3da..51fad6e68c9 100644 --- a/python/paddle/fluid/layers/control_flow.py +++ b/python/paddle/fluid/layers/control_flow.py @@ -736,7 +736,7 @@ def max_sequence_len(rank_table): rank_table(${rank_table_type}): ${rank_table_comment}. Returns: - (${out_type}): ${out_comment} + (${out_type}): ${out_comment}. """ helper = LayerHelper("max_seqence_len", **locals()) res = helper.create_tmp_variable(dtype="int64") diff --git a/python/paddle/fluid/layers/layer_function_generator.py b/python/paddle/fluid/layers/layer_function_generator.py index e6a7e7c3aaa..7dc4c214be3 100644 --- a/python/paddle/fluid/layers/layer_function_generator.py +++ b/python/paddle/fluid/layers/layer_function_generator.py @@ -238,6 +238,9 @@ def templatedoc(): Decorated function. """ + def trim_ending_dot(msg): + return msg.rstrip('.') + def __impl__(func): op_proto = OpProtoHolder.instance().get_op_proto(func.__name__) tmpl = string.Template(func.__doc__) @@ -249,19 +252,22 @@ def templatedoc(): comment += line comment += "\n" - args = {"comment": comment} + args = {"comment": trim_ending_dot(comment)} for each_input in op_proto.inputs: input_name = _convert_(each_input.name) - args["{0}_comment".format(input_name)] = each_input.comment + args["{0}_comment".format(input_name)] = trim_ending_dot( + each_input.comment) args["{0}_type".format(input_name)] = "Variable" for each_attr in op_proto.attrs: input_name = _convert_(each_attr.name) - args["{0}_comment".format(input_name)] = each_attr.comment + args["{0}_comment".format(input_name)] = trim_ending_dot( + each_attr.comment) args["{0}_type".format(input_name)] = _type_to_str_(each_attr.type) for each_opt in op_proto.outputs: output_name = _convert_(each_opt.name) - args["{0}_comment".format(output_name)] = each_opt.comment + args["{0}_comment".format(output_name)] = trim_ending_dot( + each_opt.comment) args["{0}_type".format(output_name)] = "Variable" func.__doc__ = tmpl.substitute(args) return func diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index 601b06cdd8d..66db6fe13fb 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -296,7 +296,7 @@ def fill_constant_batch_size_like(input, output_dim_idx(${output_dim_idx_type}): ${output_dim_idx_comment}. Returns: - ${out_comment} + ${out_comment}. """ helper = LayerHelper("fill_constant_batch_size_like", **locals()) out = helper.create_tmp_variable(dtype=dtype) -- GitLab