简体   繁体   English

自动测试文档中的示例

[英]Automatic testing of examples in documentation

In the end of the SageMath manual they explain why they chose to implement SageMath in Python. SageMath手册的最后,他们解释了为什么选择在Python中实现SageMath。 One of the items says: "Excellent support for documentation of functions and packages in the source code, including automatic extraction of documentation and automatic testing of all examples. The examples are automatically tested regularly and guaranteed to work as indicated. " 其中一项说:“对源代码中的功能和软件包的文档提供了出色的支持,包括文档的自动提取和所有示例的自动测试。这些示例会定期进行自动测试,并保证可以按照指定的方式工作。

This sounds neat, but I haven't found the way to do it. 这听起来很整洁,但是我还没有找到解决方法。 How can I automatically test all the examples that appear in the documentation to my functions? 如何自动测试功能文档中出现的所有示例?

In principle, you can write your examples using this syntax . 原则上,您可以使用此语法编写示例。 Then, you should be able to just do 然后,您应该可以

sage -t path/to/myfile.sage

and apparently that works, given the comment thread! 鉴于评论主题,这显然可行!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM