Skip to content

Commit 797171f

Browse files
authored
[Docs] Use pycon as syntax highlight marker (#7650)
1 parent 311562e commit 797171f

File tree

9 files changed

+16
-14
lines changed

9 files changed

+16
-14
lines changed

ci_scripts/check_api_cn.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function filter_cn_api_files() {
1515
local __resultvar=$2
1616
local need_check_files=""
1717
for file in `echo $git_files`;do
18-
grep 'code-block:: python' ../docs/$file > /dev/null
18+
grep -E 'code-block:: (python|pycon)' ../docs/$file > /dev/null
1919
if [ $? -eq 0 ] ;then
2020
api_file=`echo $file | sed 's#api/##g'`
2121
grep -w "${api_file}" ${DIR_PATH}/api_white_list.txt > /dev/null

docs/api/copy_codes_from_en_doc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def extract_code_blocks_from_docstr(docstr, google_style=True):
105105

106106
lastlineindex = len(docstr_list) - 1
107107

108-
cb_start_pat = re.compile(r"code-block::\s*python")
108+
cb_start_pat = re.compile(r"code-block::\s*(python|python-console|pycon)")
109109
cb_param_pat = re.compile(r"^\s*:(\w+):\s*(\S*)\s*$")
110110

111111
cb_info = {}
@@ -261,7 +261,7 @@ def insert_codes_into_cn_rst_if_need(cnrstfilename):
261261
cb_new = []
262262
indent = cf_info["indent"]
263263
cb_new.append("") # insert a empty line in the frontend
264-
cb_new.append(" " * indent + ".. code-block:: python")
264+
cb_new.append(" " * indent + ".. code-block:: pycon")
265265
if cf_info["cb_name"]:
266266
cb_new.append(" " * (indent + 3) + ":name: " + cf_info["cb_name"])
267267
cb_new.append("")

docs/api/extract_api_from_docs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def extract_code_blocks_from_rst(docstr):
5555
ds_list = docstr.expandtabs(tabsize=4).split("\n")
5656
lastlineindex = len(ds_list) - 1
5757
cb_started = False
58-
cb_start_pat = re.compile(r"((code)|(code-block))::\s*i?python[23]?")
58+
cb_start_pat = re.compile(
59+
r"((code)|(code-block))::\s*i?(python|python-console|pycon)"
60+
)
5961
cb_cur = []
6062
cb_cur_indent = -1
6163
for lineno, linecont in enumerate(ds_list):

docs/api/paddle/device/memory_allocated_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ memory_allocated
2222

2323
代码示例
2424
::::::::::::
25-
.. code-block:: python
25+
.. code-block:: pycon
2626
2727
>>> import paddle
2828
>>> paddle.device.memory_allocated('npu:0')

docs/api/paddle/device/memory_reserved_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ memory_reserved
1919

2020
代码示例
2121
::::::::::::
22-
.. code-block:: python
22+
.. code-block:: pycon
2323
2424
>>> import paddle
2525
>>> paddle.device.memory_reserved('npu:0')

docs/api/paddle/device/reset_max_memory_allocated_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ reset_max_memory_allocated
1919

2020
代码示例
2121
::::::::::::
22-
.. code-block:: python
22+
.. code-block:: pycon
2323
2424
>>> import paddle
2525
>>> paddle.device.reset_max_memory_allocated('npu:0')

docs/api/paddle/device/reset_max_memory_reserved_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ reset_max_memory_reserved
1919

2020
代码示例
2121
::::::::::::
22-
.. code-block:: python
22+
.. code-block:: pycon
2323
2424
>>> import paddle
2525
>>> paddle.device.reset_max_memory_reserved('npu:0')

docs/dev_guides/api_contributing_guides/api_docs_guidelines_cn.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
N-D Tensor. A location into which the result is stored. It’s dimension equals with :attr:`x`.
5353

5454
Examples:
55-
.. code-block:: python
55+
.. code-block:: pycon
5656

5757
>>> import paddle
5858

@@ -305,7 +305,7 @@ API 抛出异常部分,由于历史原因写在文档中,建议在源码的
305305
def api():
306306
"""
307307
Examples:
308-
.. code-block:: python
308+
.. code-block:: pycon
309309
310310
示例代码位置
311311
@@ -318,12 +318,12 @@ def api():
318318
def api():
319319
"""
320320
Examples:
321-
.. code-block:: python
321+
.. code-block:: pycon
322322
:name: example-1
323323
324324
示例代码位置
325325
326-
.. code-block:: python
326+
.. code-block:: pycon
327327
:name: example-2
328328
329329
示例代码位置 (存在多个示例代码)
@@ -336,7 +336,7 @@ def api():
336336
def multiply(x, y, axis=-1, name=None):
337337
"""
338338
Examples:
339-
.. code-block:: python
339+
.. code-block:: pycon
340340
341341
>>> import paddle
342342

docs/dev_guides/api_contributing_guides/new_cpp_op_cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ def trace(
818818
Tensor: the output data type is the same as input data type.
819819

820820
Examples:
821-
.. code-block:: python
821+
.. code-block:: pycon
822822

823823
>>> import paddle
824824

0 commit comments

Comments
 (0)