Is there a good C ++ code beautifier written in python?

I have a python script that generates a lot of template code in C ++. The approach I took does if it’s hard to maintain things like the right indentation while it spits out the code. Obviously, my main problem is creating the right code that compiles and does what it should do, but it would be nice if it were also user friendly and easy on the eye.

I suggest directing the output of my generator to a code decoder. This should ultimately happen on an automated build server, so ideally I want to use a python module that I can easily use.

I know that there are many solutions other than python to solve this problem, but python is what I really need and I would rather not write it myself.

+6
c ++ python beautifier
source share
1 answer

I do not know such a tool, so if I were you, I would do one of these two ways:

  • Make the code generated by my Python script readable. In my experience (quite a lot of code generation for several languages) this is not complicated.
  • Feed the generated code through an external tool, such as astyle ("Art Style"), which is the prefix of C ++ code. This can be easily automated inside your Python script so that the user does not even know that an external tool is involved.

Artistic style is the source code indenter, formatting and decorator for C, C ++, C # and Java programming languages.

+7
source share

All Articles