Ai
2 Star 0 Fork 0

mirrors_IntelPython/numba-dppy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
set_examples_to_doc.py 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
Diptorup Deb 提交于 2024-02-10 05:10 +08:00 . Reformat using latest black
""" This script is needed to convert gdb scripts from commands to documentation
"""
import os
def convert_commands_to_docs():
commands_dir = os.getcwd() + "/numba_dpex/examples/debug/commands"
examples = os.listdir(commands_dir)
os.chdir(commands_dir + "/docs")
for file in examples:
if file != "docs":
with open(commands_dir + "/" + file, "r") as open_file:
read_lines = open_file.readlines()
if os.path.exists(file):
os.remove(file)
with open(file, "a") as write_file:
for line in read_lines:
if (
line.startswith("# Expected")
or line.startswith("echo Done")
or line.startswith("quit")
or line.startswith("set trace-commands")
or line.startswith("set pagination")
):
continue
if line.startswith("# Run: "):
line = line.replace("# Run:", "$")
words = line.split()
for i in range(len(words)):
if words[i] == "-command" or words[
i
].startswith("commands"):
words[i] = ""
line = " ".join(words)
line = " ".join(line.split()) + "\n"
elif line.startswith("# "):
line = line.replace("# ", "")
else:
line = "(gdb) " + line
write_file.write(line)
if __name__ == "__main__":
convert_commands_to_docs()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_IntelPython/numba-dppy.git
git@gitee.com:mirrors_IntelPython/numba-dppy.git
mirrors_IntelPython
numba-dppy
numba-dppy
main

搜索帮助