From d89ca2ffb521c7f903d2173b485146a945ffa0b7 Mon Sep 17 00:00:00 2001 From: tianshuo78520a <707759223@qq.com> Date: Tue, 5 Nov 2019 19:09:29 +0800 Subject: [PATCH] split api_spec document (#20999) * split api_spec document;test=document_fix * change tools * test=develop;test=document_fix * test=develop;test=document_fix --- paddle/scripts/paddle_build.sh | 2 ++ tools/check_api_approvals.sh | 29 ++++++++++++++++++++--------- tools/print_signatures.py | 24 ++++++++++++------------ 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 2de9d08ba5..c364381566 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -485,6 +485,8 @@ function generate_api_spec() { spec_path=${PADDLE_ROOT}/paddle/fluid/API_${spec_kind}.spec python ${PADDLE_ROOT}/tools/print_signatures.py paddle.fluid > $spec_path + awk -F '(' '{print $NF}' $spec_path >${spec_path}.doc + awk -F '(' '{$NF="";print $0}' $spec_path >${spec_path}.api if [ "$1" == "cp35-cp35m" ] || [ "$1" == "cp36-cp36m" ] || [ "$1" == "cp37-cp37m" ]; then # Use sed to make python2 and python3 sepc keeps the same sed -i 's/arg0: str/arg0: unicode/g' $spec_path diff --git a/tools/check_api_approvals.sh b/tools/check_api_approvals.sh index de61ac45b3..e953c4326d 100644 --- a/tools/check_api_approvals.sh +++ b/tools/check_api_approvals.sh @@ -41,26 +41,37 @@ if [[ $git_files -gt 19 || $git_count -gt 999 ]];then fi fi -api_spec_diff=`python ${PADDLE_ROOT}/tools/diff_api.py ${PADDLE_ROOT}/paddle/fluid/API_DEV.spec ${PADDLE_ROOT}/paddle/fluid/API_PR.spec` +api_spec_diff=`python ${PADDLE_ROOT}/tools/diff_api.py ${PADDLE_ROOT}/paddle/fluid/API_DEV.spec.api ${PADDLE_ROOT}/paddle/fluid/API_PR.spec.api` if [ "$api_spec_diff" != "" ]; then + APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 46782768 47554610 2870059` + if [ "${APPROVALS}" == "FALSE" ]; then + failed_num=`expr $failed_num + 1` + echo_line="You must have one RD (XiaoguangHu01 or lanxianghit or saxon-zh)approval for the api change for the management reason of API interface." + echo_list=(${echo_list[@]}$failed_num "." $echo_line) + fi +fi + +api_doc_spec_diff=`python ${PADDLE_ROOT}/tools/diff_api.py ${PADDLE_ROOT}/paddle/fluid/API_DEV.spec.doc ${PADDLE_ROOT}/paddle/fluid/API_PR.spec.doc` +if [ "$api_doc_spec_diff" != "" ]; then APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 2 46782768 7534971 14105589 12605721 3064195 328693 47554610 39645414 11195205 20274488 45024560` if [ "${APPROVALS}" == "FALSE" ]; then failed_num=`expr $failed_num + 1` - echo_line="You must have two RD (XiaoguangHu01 or wanghaoshuang or guoshengCS or heavengate or kuke or Superjomn or lanxianghit or cyj1986 or hutuxian or frankwhzhang or nepeplwu) approval for the api change for the management reason of API interface and API document." + echo_line="You must have two RD (XiaoguangHu01 or wanghaoshuang or guoshengCS or heavengate or kuke or Superjomn or lanxianghit or cyj1986 or hutuxian or frankwhzhang or nepeplwu) approval for the api change for the management reason of API document." echo_list=(${echo_list[@]}$failed_num "." $echo_line) fi fi + for API_FILE in ${API_FILES[*]}; do API_CHANGE=`git diff --name-only upstream/$BRANCH | grep "${API_FILE}" | grep -v "/CMakeLists.txt" || true` echo "checking ${API_FILE} change, PR: ${GIT_PR_ID}, changes: ${API_CHANGE}" if [ "${API_CHANGE}" ] && [ "${GIT_PR_ID}" != "" ]; then # NOTE: per_page=10000 should be ok for all cases, a PR review > 10000 is not human readable. - # approval_user_list: XiaoguangHu01 46782768,chengduoZH 30176695,Xreki 12538138,luotao1 6836917,sneaxiy 32832641,tensor-tang 21351065,xsrobin 50069408,qingqing01 7845005,guoshengCS 14105589,heavengate 12605721,kuke 3064195,Superjomn 328693,lanxianghit 47554610,cyj1986 39645414,hutuxian 11195205,frankwhzhang 20274488,nepeplwu 45024560,Dianhai 38231817,JiabinYang 22361972,chenwhql 22561442,seiriosPlus 5442383,gongweibao 10721757. + # approval_user_list: XiaoguangHu01 46782768,Xreki 12538138,luotao1 6836917,sneaxiy 32832641,qingqing01 7845005,guoshengCS 14105589,heavengate 12605721,kuke 3064195,Superjomn 328693,lanxianghit 47554610,cyj1986 39645414,hutuxian 11195205,frankwhzhang 20274488,nepeplwu 45024560,Dianhai 38231817,JiabinYang 22361972,chenwhql 22561442,seiriosPlus 5442383,gongweibao 10721757,saxon-zh 2870059. if [ "${API_FILE}" == "paddle/fluid/op_use_default_grad_op_maker.spec" ];then APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 32832641 6836917` elif [ "${API_FILE}" == "CMakeLists.txt" ];then - APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 6836917 46782768 30176695` + APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 6836917 46782768` elif [ "${API_FILE}" == "python/paddle/fluid/__init__.py" ];then APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 6836917 47554610` elif [ "${API_FILE}" == "python/requirements.txt" ];then @@ -68,7 +79,7 @@ for API_FILE in ${API_FILES[*]}; do elif [ "${API_FILE}" == "paddle/fluid/operators/distributed/send_recv.proto.in" ];then APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 10721757 5442383` else - APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 21351065 3048612 46782768 30176695 12538138 6836917 32832641` + APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 3048612 46782768 12538138 6836917 32832641` fi echo "current pr ${GIT_PR_ID} got approvals: ${APPROVALS}" if [ "${APPROVALS}" == "FALSE" ]; then @@ -78,7 +89,7 @@ for API_FILE in ${API_FILES[*]}; do echo_list=(${echo_list[@]}$failed_num "." $echo_line) elif [ "${API_FILE}" == "CMakeLists.txt" ];then failed_num=`expr $failed_num + 1` - echo_line="You must have one RD (luotao1 or chengduoZH or XiaoguangHu01) approval for CMakeLists.txt, which manages the compilation parameter.\n" + echo_line="You must have one RD (luotao1 or XiaoguangHu01) approval for CMakeLists.txt, which manages the compilation parameter.\n" echo_list=(${echo_list[@]}$failed_num "." $echo_line) elif [ "${API_FILE}" == "python/requirements.txt" ];then failed_num=`expr $failed_num + 1` @@ -94,7 +105,7 @@ for API_FILE in ${API_FILES[*]}; do echo_list=(${echo_list[@]}$failed_num "." $echo_line) else failed_num=`expr $failed_num + 1` - echo_line="You must have one RD (XiaoguangHu01,chengduoZH,Xreki,luotao1,sneaxiy,tensor-tang) approval for ${API_FILE}, which manages the underlying code for fluid.\n" + echo_line="You must have one RD (XiaoguangHu01,Xreki,luotao1,sneaxiy) approval for ${API_FILE}, which manages the underlying code for fluid.\n" echo_list=(${echo_list[@]}$failed_num "." $echo_line) fi fi @@ -104,11 +115,11 @@ done HAS_CONST_CAST=`git diff -U0 upstream/$BRANCH |grep -o -m 1 "const_cast" || true` if [ ${HAS_CONST_CAST} ] && [ "${GIT_PR_ID}" != "" ]; then APPROVALS=`curl -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/PaddlePaddle/Paddle/pulls/${GIT_PR_ID}/reviews?per_page=10000 | \ - python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 21351065 3048612 46782768 30176695 12538138 6836917 32832641` + python ${PADDLE_ROOT}/tools/check_pr_approval.py 1 3048612 46782768 12538138 6836917 32832641` echo "current pr ${GIT_PR_ID} got approvals: ${APPROVALS}" if [ "${APPROVALS}" == "FALSE" ]; then failed_num=`expr $failed_num + 1` - echo_line="You must have one RD (XiaoguangHu01,chengduoZH,Xreki,luotao1,sneaxiy,tensor-tang) approval for the usage (either add or delete) of const_cast.\n" + echo_line="You must have one RD (XiaoguangHu01,Xreki,luotao1,sneaxiy) approval for the usage (either add or delete) of const_cast.\n" echo_list=(${echo_list[@]}$failed_num "." $echo_line) fi fi diff --git a/tools/print_signatures.py b/tools/print_signatures.py index 7741b6aa53..05c4911828 100644 --- a/tools/print_signatures.py +++ b/tools/print_signatures.py @@ -46,19 +46,19 @@ def queue_dict(member, cur_name): if cur_name in omitted_list: return - try: - doc = ('document', md5(member.__doc__)) - if inspect.isclass(member): - args = member.__module__ + "." + member.__name__ - else: + doc = ('document', md5(member.__doc__)) + + if inspect.isclass(member): + args = member.__module__ + "." + member.__name__ + else: + try: args = inspect.getargspec(member) - all = (args, doc) - member_dict[cur_name] = all - except TypeError: # special for PyBind method - member_dict[cur_name] = " ".join([ - line.strip() for line in pydoc.render_doc(member).split('\n') - if "->" in line - ]) + except TypeError: # special for PyBind method + args = " ".join([ + line.strip() for line in pydoc.render_doc(member).split('\n') + if "->" in line + ]) + member_dict[cur_name] = (args, doc) def visit_member(parent_name, member): -- GitLab