Open notJoon opened 1 week ago
Attention: Patch coverage is 78.60465%
with 46 lines
in your changes missing coverage. Please review.
Project coverage is 54.84%. Comparing base (
28c3b1a
) to head (5a8a2d8
). Report is 5 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Description
The
doctest
(tentative name) is a tool that allows code blocks in Markdown, especially those marked as "go" and "gno", to be executed using the gno VM.It works as follows: First, it parses the code blocks (fenced code blocks) from the Markdown file. After that, the extracted code is written to a temporary file, and the code is executed at the VM level.
Also supports static analysis to automatically include imports or packages without explicitly specifying them before execution. However, in this case, it assumes the code always executes the main function, fixes the package as 'main', and only searches for missing library paths in the standard library. Additionally, to prevent unnecessary executions, a feature to cache execution results has been added.
Moving forward, there is potential to further enhance this tool to support code documentation by allowing the execution of code embedded within comments, similar to Rust.
related #2245
CLI
The CLI command is used as follows:
path
literally means the path of the markdown to be executed. Andindex
specifies which code block in the file to execute, based on its position. However, I plan to replaceindex
with a feature that allows specifying tags. That will execute when there's a partial or complete match with the given tag, likego test -run <name>
.Current issues:
p
,r
.