从文档中提取源代码进行测试

发布于 2024-12-14 14:04:03 字数 288 浏览 3 评论 0原文

我为我编写的一些 Ruby gem 编写了教程。它位于 Markdown (Kramdown) 文本文档中。为了确保随着 gems 开发的继续,教程中源代码的完整性,我想从教程文档中提取源代码并运行测试以确保代码正确且有效。在重新发明轮子之前,我进行了搜索,但没有发现任何关于此类问题的信息。有没有什么软件可以帮助我解决我的问题? Ruby 软件会很酷,但我对这种语言并不挑剔。我确信我不是第一个遇到这个问题的人。

另一种选择是仅在教程文档中包含占位符,并将所有文件放在外部,然后在发布之前填充文档。这意味着更多的松散文件,但实施起来会容易得多。

I wrote tutorials for some Ruby gems I wrote. It is in markdown (Kramdown) text document. To ensure the integrity of the source code in the tutorials as the development of the gems continue I want to extract the source code from the tutorial document and run test to ensure the code is correct and working. Before reinventing the wheel I searched but found nothing on this kind of problem. Is there any software that can help me solve my problem? Ruby software would be cool but I'm not particular about the language. I'm sure I can't be the first person to encounter this problem.

The other option is to only have place holders in the tutorial documents and have all the files externally en then populate the document prior to publishing. This would mean a lot more loose files but would be significantly easier to implement.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑着哭最痛 2024-12-21 14:04:03

emacs 中的 Org 模式 可以做到这一点,但这意味着你不能用 Markdown 写。

Org mode in emacs can do that, but it means you can't write in Markdown.

呆橘 2024-12-21 14:04:03

您是否在寻找类似 Ruby DocTest 的东西?

Are you after something like Ruby DocTest?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文