cli.put: add --strip to remove comments and docstrings before copying #108
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is a feature I've implemented on my fork and I've found it to be useful.
Since micropython does not provide functionality to print docstrings using the
help()
function, nor is there a clean way to edit files that have been copied to the device, the docstrings and comments are usually useless and taking up valuable space.I like having docstrings and comments inside of the code I write for my own benefit and for the benefit of others reading my code. However, when copying the files to the device, I would like those things stripped out.
I wrote some basic functionality using the python
ast
library using functionality that was added to the standard library in Python 3.9. The premise of this implementation comes fromhttps://gist.github.com/phpdude/1ae6f19de213d66286c8183e9e3b9ec1
I implemented it in such a way that if the conversion fails for any reason, including using a version of python that does not have the
ast.unparse()
function, it will issue a warning and revert to copying the file without modification.I will continue using my fork, but I want to contribute my changes upstream if you so desire.