Skip to content

[util] added doc test utility#177

Merged
FrankLeeeee merged 3 commits intomainfrom
feature/doc-test
Feb 27, 2023
Merged

[util] added doc test utility#177
FrankLeeeee merged 3 commits intomainfrom
feature/doc-test

Conversation

@FrankLeeeee
Copy link
Copy Markdown
Contributor

@FrankLeeeee FrankLeeeee commented Feb 27, 2023

This PR added a utility command to test the markdown file.

docer test -p <path/to/markdown>

If you want to test the Python code in your markdown file, you need to provide a command to trigger the test. Do add the following line to the top of your file and replace $command with the actual command. Do note that the markdown will be converted into a Python file. Assuming you have a demo.md file, the test file generated will be demo.py. Therefore, you should use demo.py in your command, e.g. python demo.py.

<!-- doc-test-command: $command  -->

Meanwhile, only code labelled as a Python code block will be considered for testing.

    ```python
    print("hello world")
    ```

Lastly, if you want to skip some code, you just need to add the following annotations to tell docer to discard the wrapped code for testing.

    <!--- doc-test-ignore-start -->
    ```python
    print("hello world")
    ```
    <!--- doc-test-ignore-end -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants