-
Notifications
You must be signed in to change notification settings - Fork 49
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
Tests to verify the sample code in the readme functions #152
Comments
@m8ttyB I was wondering the same thing. updating the readme and examples is something that I often forget when making changes... |
@davehunt Do you know of any tools that can lint or test example code in docs? |
There's doctest but that's based on Python's docstrings. I'm not aware of anything that would be able to test example code from a README though. Another option might be to build the README from a snippet that's tested independently. |
That sounds promising. After doing a quick search, there may be tools that exist already to test code in readme files. Will follow up on this. |
@kimberlythegeek @m8ttyB I second what @davehunt said about testing a code snippet independently. It is possible to write a script that reads the README, extracts the python code from it and then runs it through a linter like flake8 or pycodestyle. I'd be happy to give this a shot. |
thanks @terrameijar I always welcome contributions :) |
+1 Thanks @terrameijar. Sure, let us know what you come up with. |
Before the code in the file can be checked for errors, we first need to extract or find it in the document. There are two options I can think of to solve this:
I prefer option 2. I am working on figuring out how to write the regex pattern that'll work in this case. |
@m8ttyB @kimberlythegeek I am not entirely sure what the best way to invoke tests from the script is, but this proves at least that linting code in READMEs can be done. |
This might be worth a look at, it is a tool for linting Python code blocks in markdown files: |
I'm not sure if this is possible but wanted to capture the intention after seeing issue #149 filed by @mudgil. Can a process, like those run in TravisCI, verify when a pull request is made that sample code embedded in the Readme continues to function?
I recognize this might not be possible, or that the effort involved may be too great. Let's do a brief investigation into the viability of this.
The text was updated successfully, but these errors were encountered: