diff --git a/doc/fluid/api/index_en.rst b/doc/fluid/api/index_en.rst index 3d98746f0e750c0213ce293817f575a867a94312..f360715383903c2f6efae7a01e662a710fafc340 100644 --- a/doc/fluid/api/index_en.rst +++ b/doc/fluid/api/index_en.rst @@ -32,3 +32,4 @@ API Reference regularizer.rst transpiler.rst unique_name.rst + review_tmp.rst diff --git a/doc/fluid/api/review_tmp.rst b/doc/fluid/api/review_tmp.rst new file mode 100644 index 0000000000000000000000000000000000000000..e39366bcef08a15baa15c3cfbb318022a2dc47b2 --- /dev/null +++ b/doc/fluid/api/review_tmp.rst @@ -0,0 +1,9 @@ +================= +paddle.review_tmp +================= + +.. toctree:: + :maxdepth: 1 + + review_tmp/MarginRankingLoss.rst + review_tmp/margin_ranking_loss.rst diff --git a/doc/fluid/api/review_tmp/MarginRankingLoss.rst b/doc/fluid/api/review_tmp/MarginRankingLoss.rst new file mode 100644 index 0000000000000000000000000000000000000000..edc5d1cc57c85be5eb37312c6dc9b8b204b4d9b1 --- /dev/null +++ b/doc/fluid/api/review_tmp/MarginRankingLoss.rst @@ -0,0 +1,9 @@ +.. _api_nn_loss_MarginRankingLoss_tmp: + +MarginRankingLoss +----------------- + +.. autoclass:: paddle.nn.loss.MarginRankingLoss + :members: + :inherited-members: + :noindex: diff --git a/doc/fluid/api/review_tmp/margin_ranking_loss.rst b/doc/fluid/api/review_tmp/margin_ranking_loss.rst new file mode 100644 index 0000000000000000000000000000000000000000..289d1928bf05925dc81238c7ff0dad2623a4d3fc --- /dev/null +++ b/doc/fluid/api/review_tmp/margin_ranking_loss.rst @@ -0,0 +1,7 @@ +.. _api_nn_functional_margin_ranking_loss_tmp: + +margin_ranking_loss +------------------- + +.. autofunction:: paddle.nn.functional.margin_ranking_loss + :noindex: diff --git a/gen_index.py b/gen_index.py new file mode 100644 index 0000000000000000000000000000000000000000..e2817e3ab06c62700676813fd15effa086ceda40 --- /dev/null +++ b/gen_index.py @@ -0,0 +1,72 @@ +import argparse +import sys +import types +import os +import contextlib + + +def parse_arg(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--api_path', + type=str, + default='paddle.nn.functional.l1_loss', + help='the function/class path') + parser.add_argument( + '--is_class', + type=str, + default='False', + help='whether function or class, False means function') + return parser.parse_args() + + +def add_index(en_doc_review_dir, api_name): + + stream = open(en_doc_review_dir + '.rst', 'a') + stream.write(' review_tmp/' + api_name + '.rst\n') + stream.close() + print('add index to ' + en_doc_review_dir + '.rst success') + + +def add_file(en_doc_review_dir, api_path, is_class=False): + + api_path_list = api_path.split('.') + api_name = api_path_list[-1] + api_title = '_'.join(api_path_list[1:]) + + stream = open(en_doc_review_dir + '/' + api_name + '.rst', 'w') + stream.write('.. _api_' + api_title + ':\n') + stream.write('\n') + stream.write(api_name + '\n') + for i in range(max(9, len(api_name))): + stream.write('-') + stream.write('\n') + stream.write('\n') + + if is_class == 'True': + stream.write('.. autoclass:: ' + api_path + '\n') + stream.write(' :members:\n') + stream.write(' :inherited-members:\n') + else: + stream.write('.. autofunction:: ' + api_path + '\n') + + stream.write(' :noindex:\n') + stream.close() + print('add' + en_doc_review_dir + '/' + api_name + '.rst success') + + +def main(): + args = parse_arg() + api_path = args.api_path + is_class = args.is_class + api_name = api_path.split('.')[-1] + + fluid_doc_path = os.getcwd() + en_doc_review_dir = fluid_doc_path + '/doc/fluid/api/review_tmp' + + add_index(en_doc_review_dir, api_name) + add_file(en_doc_review_dir, api_path, is_class) + + +if __name__ == '__main__': + main()