#Mini-Zig: Remove comments from your zig files

1 messages · Page 1 of 1 (latest)

steep bramble
#

Hello everyone!

I wanted to share a small tool I've been working on, called Mini-Zig. It's a utility that helps in cleaning up source files by removing commented lines. This might be helpful for those who are looking to simplify their Zig codebases.

Features of Mini-Zig:

Efficient removal of single-line comments.
Handles files with leading whitespace.
Simple command-line interface.
Processes files entirely in memory.

While it's a small tool, I believe it could be useful for some. I'm open to any feedback or contributions from the community.

Thank you and I hope someone finds it useful.

The project is open-source and available on GitHub here: https://github.com/ZakariaBouguira/mini-zig.

whole crypt
#

Removing all comments? including documentation?

lone lantern
#

i think they said its a minifier

#

so it removes spaces too?

steep bramble
#

Yes it looks for lines starting with '//' after trimming the line from whitespaces. So it removes also documentation.

#

I made it because I was constantly removing the commented lines from build.zig and build.zig.zon.

#

If you like it we can easily extend its capability

uneven bone
#

Dunno if I like the idea of doing it, but cool for those who want this

steep bramble
# whole crypt Removing *all* comments? including documentation?

Hi everyone, thanks for the feedback and questions. I wanted to share a quick update based on our conversation:

Documentation Comments: I've revised the tool to include an option to keep documentation comments (///).

Minifying Behavior: By default, Mini-Zig will continue to remove all comments (including documentation), but with the new -keep-doc flag, you can preserve your documentation comments in the minified file.

Inline Comments: In addition to removing full-line comments, Mini-Zig now also removes inline comments

I appreciate the input, as it has led to this useful enhancement. If there are more features or improvements you'd like to see, feel free to let me know!

rugged pivot