(docstrings_to_test: dict[str, str])
| 671 | |
| 672 | |
| 673 | def check_old_style(docstrings_to_test: dict[str, str]): |
| 674 | old_style_apis = [] |
| 675 | for api_name, raw_docstring in docstrings_to_test.items(): |
| 676 | for codeblock in extract_code_blocks_from_docstr( |
| 677 | raw_docstring, google_style=False |
| 678 | ): |
| 679 | old_style = True |
| 680 | |
| 681 | for line in codeblock['codes'].splitlines(): |
| 682 | if line.strip().startswith('>>>'): |
| 683 | old_style = False |
| 684 | break |
| 685 | |
| 686 | if old_style: |
| 687 | codeblock_name = codeblock['name'] |
| 688 | codeblock_id = codeblock['id'] |
| 689 | |
| 690 | docstring_name = f'{api_name}:{codeblock_name or codeblock_id}' |
| 691 | |
| 692 | old_style_apis.append(docstring_name) |
| 693 | |
| 694 | if old_style_apis: |
| 695 | logger.warning( |
| 696 | ">>> %d apis use plain sample code style.", |
| 697 | len(old_style_apis), |
| 698 | ) |
| 699 | logger.warning('=======================') |
| 700 | logger.warning('\n'.join(old_style_apis)) |
| 701 | logger.warning('=======================') |
| 702 | logger.warning(">>> Check Failed!") |
| 703 | logger.warning( |
| 704 | ">>> DEPRECATION: Please do not use plain sample code style." |
| 705 | ) |
| 706 | logger.warning( |
| 707 | ">>> For more information: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/dev_guides/style_guide_and_references/code_example_writing_specification_cn.html " |
| 708 | ) |
| 709 | log_exit(1) |
| 710 | |
| 711 | |
| 712 | def exec_gen_doc(): |
no test coverage detected