MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / check_old_style

Function check_old_style

tools/sampcd_processor_utils.py:673–709  ·  view source on GitHub ↗
(docstrings_to_test: dict[str, str])

Source from the content-addressed store, hash-verified

671
672
673def 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
712def exec_gen_doc():

Callers 1

run_doctestFunction · 0.85

Calls 5

log_exitFunction · 0.85
itemsMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected