openSUSE / python-rpm-macros

Multi-Python, Single-Spec macros generator
Other
22 stars 20 forks source link

Support comments outside of lua function definitions #171

Closed Thaodan closed 6 months ago

mcepl commented 8 months ago

Could you, please, add some documentation to README.md? Or at least make detailed commit message? Without deep analysis of your commit, I really don’t know what was the original intent of this PR.

Thaodan commented 7 months ago

I explained the change inside the comment message more detailed. I hope it's clear now.

mcepl commented 7 months ago

I explained the change inside the comment message more detailed. I hope it's clear now.

I am sorry, it isn’t. I am probably too stupid, but what kind of comments (^# or ^-- ones)? Could we have an example? Please, write a bit of README.md.

Thaodan commented 7 months ago

I explained the change inside the comment message more detailed. I hope it's clear now.

I am sorry, it isn’t. I am probably too stupid, but what kind of comments (^# or ^-- ones)? Could we have an example? Please, write a bit of README.md.

Just regular lua comments outside of functions. The ^ is in there to only match on the beginning of line.

You can see the change in action in the tree-sitter package: https://build.opensuse.org/package/show/editors/tree-sitter

bnavigator commented 7 months ago

You can see the change in action in the tree-sitter package:

No, we don't. Please explain.

Thaodan commented 7 months ago

Ben Greiner @.***> writes:

You can see the change in action in the tree-sitter package:

No, we don't. Please explain.

The script doesn't escape macros outside of Lua functions in Lua files correctly.

E.g. if you have comments such as:

-- foo single line coment
--[[
    multi line comment
--]]

will be inserted literally as they are into the rpm macro file.

With the change lua comments will be converted into rpm comments e.g.

-- single line comment -> # single line comment

# --[[
#   multi line comment
# --]]
mcepl commented 7 months ago

Some abbreviated version of this would be lovely to have in README.md.

mcepl commented 6 months ago

I will be the bad guy here. Let’s just say no to this PR request. We really do not want to make python-rpm-macros into an independent Turing-complete programming language. If you really want to use some comments in your code, the best I can suggest for you is some kind of pre-processor (even if it is a one-liner with sed), but please any PR sent here should be clear of any comments.