supperthomas / bluetoothlover_doc

this is about the learning station about friends.
https://supperthomas-wiki.readthedocs.io/
Apache License 2.0
46 stars 25 forks source link

代码注释器 #419

Open supperthomas opened 1 year ago

supperthomas commented 1 year ago

http://www.network-science.de/ascii/

http://www.network-science.de/ascii/

supperthomas commented 1 month ago

https://mp.weixin.qq.com/s?search_click_id=8715882495914789207-1727640867688-6139467338&__biz=MzI4MTEyNDU1MA==&mid=2651243818&idx=1&sn=a5ebb4f6895b733582faea1d69a616e9&chksm=f05c6e83c72be7957899234b9cfc2643bf52cf62be2a8970702abd432584ce0d46fc386cad6d&scene=7&subscene=10000&clicktime=1727640867&enterid=1727640867&sessionid=0&ascene=65&fasttmpl_type=0&fasttmpl_fullversion=7404777-zh_CN-zip&fasttmpl_flag=0&realreporttime=1727640867717&devicetype=android-34&version=28003337&nettype=WIFI&abtest_cookie=AAACAA%3D%3D&lang=zh_CN&countrycode=AL&exportkey=n_ChQIAhIQuCJXaLaLcIeUkPr2tcWHYRLYAQIE97dBBAEAAAAAAOltF5IL4NsAAAAOpnltbLcz9gKNyK89dVj0a7hzPcwo5FzhdxzTEcuk5Xwd1mim7HJJLxNPp20KKzgq7hP21YDXCqUuPBol1xGaFsWFliV3fROjHgejtDVeawGmvWgVuCyaVy%2BUoN%2BhOMuZHmF6cCd%2B7LexTSAAMjqOMAZCBSDFXdSeR5MnURsrPXBQvjCqud3LWaD53vsR0XO%2BRpF0n84yC2zqmd46OsgR1ZqbX1ntZNUqvRUynjfhbpzcWnvJa0bqhboqDfHHhGfi0A%3D%3D&pass_ticket=pRjKjzIBPPsmN2vjIvmtusSb0x%2Fj3Znx6iIgVKhgifZhJUe6o%2BGXFhRP8j6h%2BExP&wx_header=3

supperthomas commented 1 month ago

图片转字符

http://www.glassgiant.com/ascii/

图片转字符

http://www.robertecker.com/hp/research/image2asciiart.php

文字转字符

http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something%20

文字转字符

http://www.network-science.de/ascii/

Ascii World(字符图应有尽有)

http://www.asciiworld.com/

supperthomas commented 1 month ago
import openai
import re

# 设置OpenAI的API密钥
openai.api_key = 'YOUR_API_KEY_HERE'

# 定义函数来调用chatgpt的API
def summarize_function_content(function_name, function_code):
    # 调用chatgpt API以获取函数内容概括
    response = openai.Completion.create(
      engine="davinci-codex",
      prompt=f"Summarize the function content of the C code snippet:\n\n{function_code}\n\nFunction Name: {function_name}\n\nSummary:",
      max_tokens=100
    )

    # 解析API返回的概括
    summary = response.choices[0].text.strip()

    return summary

# 定义函数来对C语言代码进行Doxygen注释和函数内容概括
def generate_doxygen_comments(c_code):
    # 使用正则表达式提取函数名和代码
    functions = re.findall(r'(?:\w+\s)+(\w+)\s*\([^{}]*\)\s*{[^}]*}', c_code)

    for function in functions:
        # 调用summarize_function_content函数获取函数内容概括
        function_code = re.search(f'{function}\\s*\\([^{}]*\\)\\s*{{([^}}]*)}}', c_code, re.MULTILINE | re.DOTALL).group(1).strip()
        summary = summarize_function_content(function, function_code)

        # 生成Doxygen注释
        doxygen_comment = f"/**\n * @brief {summary}\n */"

        # 在函数之前添加Doxygen注释
        c_code = re.sub(f'{function}\\s*\\([^{}]*\\)\\s*{{', f'{doxygen_comment}\n\\g<0>', c_code)

    return c_code

# 示例C语言代码
c_code = """
int add(int a, int b) {
    return a + b;
}

int main() {
    int result = add(5, 3);
    return 0;
}
"""

# 生成Doxygen注释和函数内容概括
c_code_with_comments = generate_doxygen_comments(c_code)
print(c_code_with_comments)
supperthomas commented 1 month ago

如何写doxygen注释 https://docs.espressif.com/projects/esp-idf/zh_CN/v5.2/esp32c6/contribute/documenting-code.html