Skip to content

cli.put: add --strip to remove comments and docstrings before copying#108

Open
mikebentley15 wants to merge 1 commit intoscientifichackers:masterfrom
mikebentley15:put-add-stripping
Open

cli.put: add --strip to remove comments and docstrings before copying#108
mikebentley15 wants to merge 1 commit intoscientifichackers:masterfrom
mikebentley15:put-add-stripping

Conversation

@mikebentley15
Copy link
Copy Markdown

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 from

https://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.

@GuillaumeLeclerc
Copy link
Copy Markdown

Any reason this hasn't been merged ? this sounds critical for larger projects where:

  • Extensive documentation is very important
  • Flash Space becomes a scarce resource

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