New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore tested code listings #5
Comments
The comments in the markdown that show the version of a code listing that was tested under the RST-based pipeline have a marker at the start of each that tells you what kind of line it is. Those markers are as follows: Input to the REPL
Output from the REPL
Expected Errors
Tested Comments
|
For an example of the kinds of mistakes that tested code listings prevents, see #45. In that case, I had to write some code listings without tests, because the "swifttest" portion of the legacy pipeline wasn't set up to test async code. |
@amartini51, was the code that implemented the REPL checks open source? I got curious, and considered poking around a little bit. Do you think a capability to execute |
When releasing TSPL as an open-source project, only the English text was included, not any of the old build system's code. Before migrating TSPL to DocC, the book was build using a Sphinx with a number of custom directives. The code that handled the DocC has some support for testing code listings using snippets (see Kyle's notes above). It's probably possible to adopt snippets for parts of the book — I'd be inclined to start with the guided tour as a test. TSPL's needs are a little unusual compared to other documentation — the book includes many tests that are expected to not compile, testing prose that makes assertions about the language's syntax, and many tests that are expected to trap/crash at run time. |
@amartini51 thank you for linking Snippets. I did not know they were a thing — did not stumble at them when I read up on Swift DocC documentation. Perhaps I document them 👀 So, DocC already has support for snippets code blocks that are built at docc build time, but they don't support the syntax you described above. I don't have a gut feeling that adding REPL commands support to snippets is a universally good idea, but that sounds like something that could be a good addition — should I draft an RFC for it and try and spike on a proof of concept for it? I imagine that:
Something like that? UPD:
|
The shipping book uses a custom syntax for its tests; we preserved these as DocC comments in the Markdown source, but use regular Swift code blocks to render them without running and testing the code as part of the build process. We should evaluate how to bring these tests back, potentially using Swift Snippets.
The text was updated successfully, but these errors were encountered: