Code Beautifier
Code Beautifier
Does anyone know a good code beautifier? Because we are obviously are going to need a code standarizer...
Code::Blocks comes with a plugin called "Source code formatter" (AStyle). This just changes the way it looks by auto-indenting, brace alignment etc.
It may not be to everyones liking however.
For example the following code
gets tranformed into
It may not be to everyones liking however.
For example the following code
Code: Select all
class Something {
int r(void) { return 10; }
void c(int p) {}
};
Code: Select all
class Something
{
int r(void)
{
return 10;
}
void c(int p)
{}
}
;
Upon further research AStyle is actually a program which can convert to any style possible, be it hard tabs, fixed spaces, ANSI, gnu, unix, Kernighan and Ritchie, Java style or any custom variant.
I suggest checking out their web site http://astyle.sourceforge.net/. (Note this is actually an external program and plug-in to Code::Blocks)
Lets say people have different ideas of what looks good...
1. Someone loads the project from CVS
2. Applies their own AStyle to the code
3. Writes more code
4. Applies the universal AStyle (that the community decides upon) styling
5. Upload to CVS
This may solve any conflicts with, "lets do it my way" and will standardise the code format.
I suggest checking out their web site http://astyle.sourceforge.net/. (Note this is actually an external program and plug-in to Code::Blocks)
Lets say people have different ideas of what looks good...
1. Someone loads the project from CVS
2. Applies their own AStyle to the code
3. Writes more code
4. Applies the universal AStyle (that the community decides upon) styling
5. Upload to CVS
This may solve any conflicts with, "lets do it my way" and will standardise the code format.
-
- Transport Empire Developer
- Posts: 699
- Joined: 03 Feb 2003 09:30
- Location: Back at the office
These two steps will only work well when applying steps 2 and 4 to a file will yield the same file again. But other than that, I don't see any objections.aarona wrote:4. Applies the universal AStyle (that the community decides upon) styling
5. Upload to CVS
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)
[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
Code: Select all
+------------Oo.------+
| Transport Empire -> |
+---------------------+
Under construction...
Yes, it could be done. But should it? It could cause merge conflicts in the working copy of the individual commiting the differently styled code. It could cause white space-only commits. If the tool doing the styling fails or outputs incorrect code, it could break the continuity of the repository.Steve wrote:I do however predict many times where someone forgets to reapply the universal style. Is there anyway this can be done automatically when it's submitted to CVS?
It could be less dangerous to have a cron script check out the code, style it and check it back in - but still probably overkill.
I'm unsure of what problem you're trying to solve. Minor style errors are a fact of life.
Let's just apply before each release :-)
Let's just apply the style standardizer before each release. 
OK, optimistic saying that there'll be a release, I know....

OK, optimistic saying that there'll be a release, I know....
Who is online
Users browsing this forum: No registered users and 2 guests