From ddf16b0f2096c4ac39bf6f3f9aa7440690a9420b Mon Sep 17 00:00:00 2001 From: PommesPeter <54879512+PommesPeter@users.noreply.github.com> Date: Tue, 19 Sep 2023 17:15:58 +0800 Subject: [PATCH] [xdoctest] reformat example code with google style No.354 (#57440) * updated setup.py xdoctest * updated setup.py.in xdoctest * updated skip test * Apply suggestions from code review --------- Co-authored-by: Nyakku Shigure --- python/setup.py.in | 86 ++++++++++++++++++++++++++-------------------- setup.py | 85 +++++++++++++++++++++++++-------------------- 2 files changed, 95 insertions(+), 76 deletions(-) diff --git a/python/setup.py.in b/python/setup.py.in index 39dffbb240556d..a90efeabbdccc9 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -154,29 +154,34 @@ def show(): Examples: .. code-block:: python - import paddle - - # Case 1: paddle is tagged with 2.2.0 - paddle.version.show() - # full_version: 2.2.0 - # major: 2 - # minor: 2 - # patch: 0 - # rc: 0 - # cuda: '10.2' - # cudnn: '7.6.5' - # xpu: '20230114' - # xpu_xccl: '1.0.7' - # cinn: False - - # Case 2: paddle is not tagged - paddle.version.show() - # commit: cfa357e984bfd2ffa16820e354020529df434f7d - # cuda: '10.2' - # cudnn: '7.6.5' - # xpu: '20230114' - # xpu_xccl: '1.0.7' - # cinn: False + >>> import paddle + + >>> # Case 1: paddle is tagged with 2.2.0 + >>> paddle.version.show() + >>> # doctest: +SKIP('Different environments yield different output.') + full_version: 2.2.0 + major: 2 + minor: 2 + patch: 0 + rc: 0 + cuda: '10.2' + cudnn: '7.6.5' + xpu: '20230114' + xpu_xccl: '1.0.7' + cinn: False + >>> # doctest: -SKIP + + >>> # Case 2: paddle is not tagged + >>> paddle.version.show() + >>> # doctest: +SKIP('Different environments yield different output.') + commit: cfa357e984bfd2ffa16820e354020529df434f7d + cuda: '10.2' + cudnn: '7.6.5' + xpu: '20230114' + xpu_xccl: '1.0.7' + cinn: False + >>> # doctest: -SKIP + """ if istaged: print('full_version:', full_version) @@ -204,10 +209,11 @@ def cuda(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.cuda() - # '10.2' + >>> paddle.version.cuda() + >>> # doctest: +SKIP('Different environments yield different output.') + '10.2' """ return cuda_version @@ -221,10 +227,11 @@ def cudnn(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.cudnn() - # '7.6.5' + >>> paddle.version.cudnn() + >>> # doctest: +SKIP('Different environments yield different output.') + '7.6.5' """ return cudnn_version @@ -238,10 +245,11 @@ def xpu(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.xpu() - # '20230114' + >>> paddle.version.xpu() + >>> # doctest: +SKIP('Different environments yield different output.') + '20230114' """ return xpu_version @@ -255,10 +263,11 @@ def xpu_xccl(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.xpu_xccl() - # '1.0.7' + >>> paddle.version.xpu_xccl() + >>> # doctest: +SKIP('Different environments yield different output.') + '1.0.7' """ return xpu_xccl_version @@ -272,10 +281,11 @@ def cinn(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.cinn() - # False + >>> paddle.version.cinn() + >>> # doctest: +SKIP('Different environments yield different output.') + False """ return cinn_version diff --git a/setup.py b/setup.py index fd3de7ac616c06..12cd54428d2e48 100644 --- a/setup.py +++ b/setup.py @@ -479,29 +479,33 @@ def show(): Examples: .. code-block:: python - import paddle - - # Case 1: paddle is tagged with 2.2.0 - paddle.version.show() - # full_version: 2.2.0 - # major: 2 - # minor: 2 - # patch: 0 - # rc: 0 - # cuda: '10.2' - # cudnn: '7.6.5' - # xpu: '20230114' - # xpu_xccl: '1.0.7' - # cinn: False - - # Case 2: paddle is not tagged - paddle.version.show() - # commit: cfa357e984bfd2ffa16820e354020529df434f7d - # cuda: '10.2' - # cudnn: '7.6.5' - # xpu: '20230114' - # xpu_xccl: '1.0.7' - # cinn: False + >>> import paddle + + >>> # Case 1: paddle is tagged with 2.2.0 + >>> paddle.version.show() + >>> # doctest: +SKIP('Different environments yield different output.') + full_version: 2.2.0 + major: 2 + minor: 2 + patch: 0 + rc: 0 + cuda: '10.2' + cudnn: '7.6.5' + xpu: '20230114' + xpu_xccl: '1.0.7' + cinn: False + >>> # doctest: -SKIP + + >>> # Case 2: paddle is not tagged + >>> paddle.version.show() + >>> # doctest: +SKIP('Different environments yield different output.') + commit: cfa357e984bfd2ffa16820e354020529df434f7d + cuda: '10.2' + cudnn: '7.6.5' + xpu: '20230114' + xpu_xccl: '1.0.7' + cinn: False + >>> # doctest: -SKIP """ if istaged: print('full_version:', full_version) @@ -529,10 +533,11 @@ def cuda(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.cuda() - # '10.2' + >>> paddle.version.cuda() + >>> # doctest: +SKIP('Different environments yield different output.') + '10.2' """ return cuda_version @@ -546,10 +551,11 @@ def cudnn(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.cudnn() - # '7.6.5' + >>> paddle.version.cudnn() + >>> # doctest: +SKIP('Different environments yield different output.') + '7.6.5' """ return cudnn_version @@ -563,10 +569,11 @@ def xpu(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.xpu() - # '20230114' + >>> paddle.version.xpu() + >>> # doctest: +SKIP('Different environments yield different output.') + '20230114' """ return xpu_version @@ -580,10 +587,11 @@ def xpu_xccl(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.xpu_xccl() - # '1.0.7' + >>> paddle.version.xpu_xccl() + >>> # doctest: +SKIP('Different environments yield different output.') + '1.0.7' """ return xpu_xccl_version @@ -597,10 +605,11 @@ def cinn(): Examples: .. code-block:: python - import paddle + >>> import paddle - paddle.version.cinn() - # False + >>> paddle.version.cinn() + >>> # doctest: +SKIP('Different environments yield different output.') + False """ return cinn_version