TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Code-Narrator: Automating Documentation with GPT-4

8 点作者 ingigauti大约 2 年前
As a solo developer on a sizeable project, I found myself facing the challenge of creating documentation, a task I admittedly do not enjoy. Fortunately, ChatGPT arrived just in time. After experimenting with it, I discovered that it generates high-quality documentation for code files, even better than what I could produce manually. This realization led me to develop Code-Narrator, a client that simplifies the documentation process.<p>Code-Narrator (<a href="https:&#x2F;&#x2F;github.com&#x2F;ingig&#x2F;code-narrator">https:&#x2F;&#x2F;github.com&#x2F;ingig&#x2F;code-narrator</a>) utilizes GPT-4 to analyze your code files and automatically generate documentation. The tool is language-agnostic and has been tested with TypeScript, GraphQL, Solidity, C#, Kotlin, and more. As long as the files are in plain text, Code-Narrator should work seamlessly.<p>The primary goal of Code-Narrator is to ease the documentation process for developers, transforming them from writers to editors. While developers are still responsible for verifying the accuracy of the generated documentation, the initial writing is handled by the AI.<p>If GPT-4 produces incorrect documentation, it typically indicates that the code needs clarification, or a brief comment should be added to guide the AI. A general rule of thumb is that if GPT-4 cannot comprehend the code, it may be too complex for the next developer.<p>However, Code-Narrator is constrained by GPT-4&#x27;s 8192-token limit, which can be problematic for extensive code files. Those with access to the gpt-4-32k variant should expect better results.<p>Upon its first run, Code-Narrator creates a configuration file by analyzing your project, and then prompts you to review it for accuracy. The key configuration aspects include the &quot;include,&quot; &quot;config_files,&quot; and &quot;source_path&quot; settings.<p>In its second run, Code-Narrator generates documentation for your entire project. The process is time-consuming, taking approximately 45 minutes to complete from scratch. However, the tool is:<p>- Flexible, allowing for the creation of custom pages such as How-To guides, tutorials, FAQs, READMEs, and other bespoke content. - Multilingual, supporting 25+ languages (as many as GPT-4 supports). - Versatile, capable of generating documentation in various formats (LaTeX, HTML, with the default being Markdown).<p>For a demonstration on transforming a few lines into a How-To guide, watch this video: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=uJtVCUOTkvw">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=uJtVCUOTkvw</a>. Remember that brevity is key, as the more concise the input, the more GPT-4 can contribute.<p>Code-Narrator also supports custom plugins, with tutorials available at <a href="https:&#x2F;&#x2F;github.com&#x2F;ingig&#x2F;code-narrator&#x2F;tree&#x2F;master&#x2F;docs&#x2F;tutorial">https:&#x2F;&#x2F;github.com&#x2F;ingig&#x2F;code-narrator&#x2F;tree&#x2F;master&#x2F;docs&#x2F;tuto...</a>.<p>In terms of size and cost, Code-Narrator consists of 45 files and 1712 lines of code. The total cost of generating documentation for the entire project is approximately $2.5, a significant savings compared to manual documentation.<p>During the development of Code-Narrator, I noticed several benefits:<p>- Improved function naming: Reading the generated documentation led me to revise vague or overly general function names, resulting in better code and documentation. - Concise input: Focusing on reducing the size of the input file (liquid) became a fun challenge, helping to optimize the process. - Enjoyable interaction: Working with ChatGPT proved more enjoyable than manually writing documentation, and the more I experimented, the better the results. - Minimal input for tutorials: I was pleasantly surprised by how little input was required to create How-To guides and tutorials using GPT-4. - Encouragement to refactor: The 8K token limitation may be restrictive, but it also encourages developers to refactor their code for improved readability and structure.<p>As a prototype and proof of concept, Code-Narrator has some limitations. I&#x27;m excited to see where Code-Narrator goes from here, and your feedback is invaluable.<p>Thank you for taking the time to explore this project!

4 条评论

overview大约 2 年前
I’ve been thinking about this for a while. Super excited to see you’ve actually done it! Will definitely be trying it out. Thanks for making this!
syntaxing大约 2 年前
Is it possible to embed the code then query to “get around” the token limit?
taf2大约 2 年前
This is super cool will be trying it out today
manikagg101大约 2 年前
This looks cool, saw the demo video.