Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Fri Nov 17, 2017 11:05 pm

All times are UTC




Post new topic  Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Code Beautifier
PostPosted: Sat Oct 22, 2005 11:06 pm 
Offline
Transport Empire Moderator
Transport Empire Moderator
User avatar

Joined: Fri Jan 10, 2003 12:21 pm
Posts: 2125
Location: Wroclaw, Poland / Katowice, Poland
Does anyone know a good code beautifier? Because we are obviously are going to need a code standarizer...

_________________
All art and vehicle stats I authored for TT and derivatives are as of now PUBLIC DOMAIN! Use as you see fit
Just say NO to the TT fan-art sprite licensing madness. Public domain your art as well.


Top
   
 Post subject:
PostPosted: Tue May 30, 2006 1:40 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri May 26, 2006 3:54 pm
Posts: 221
Location: Perth, Australia
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
Code:
class Something {
    int r(void) { return 10; }
    void c(int p) {}
};


gets tranformed into

Code:
class Something
{
    int r(void)
    {
        return 10;
    }
    void c(int p)
    {}
}
;


Top
   
 Post subject:
PostPosted: Wed May 31, 2006 3:32 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Jan 10, 2004 8:19 pm
Posts: 2085
Location: London
Well, the most obvious thing would be to make sure people to use Hard Tabs, not spaces. That way each person can view the code in whatever space indentation they prefer.


Top
   
 Post subject:
PostPosted: Sun Jun 04, 2006 8:00 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri May 26, 2006 3:54 pm
Posts: 221
Location: Perth, Australia
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.


Top
   
 Post subject:
PostPosted: Thu Jun 15, 2006 6:22 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
aarona wrote:
4. Applies the universal AStyle (that the community decides upon) styling
5. Upload to CVS

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.

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)
Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+

[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...


Top
   
 Post subject:
PostPosted: Fri Jun 16, 2006 1:37 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Jan 10, 2004 8:19 pm
Posts: 2085
Location: London
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?


Top
   
 Post subject:
PostPosted: Fri Jun 16, 2006 6:15 pm 
Offline
Engineer
Engineer

Joined: Tue Jan 27, 2004 2:19 pm
Posts: 3
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?


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.

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.


Top
   
 Post subject:
PostPosted: Fri Jun 16, 2006 9:17 pm 
Offline
Transport Empire Moderator
Transport Empire Moderator
User avatar

Joined: Fri Jan 10, 2003 12:21 pm
Posts: 2125
Location: Wroclaw, Poland / Katowice, Poland
Geeeeez :)

A code is a code.

Code beautifier will parse a valid c++ code, whichever style, and outputs the desired style.

And yes - CVS should automagically to that.

_________________
All art and vehicle stats I authored for TT and derivatives are as of now PUBLIC DOMAIN! Use as you see fit
Just say NO to the TT fan-art sprite licensing madness. Public domain your art as well.


Top
   
PostPosted: Fri Jun 15, 2007 1:16 am 
Offline
Engineer
Engineer

Joined: Sun May 29, 2005 10:30 am
Posts: 13
Let's just apply the style standardizer before each release. :-)

OK, optimistic saying that there'll be a release, I know....


Top
   
 Post subject: Re: Code Beautifier
PostPosted: Sat Nov 11, 2017 8:27 am 
Offline
Engineer
Engineer

Joined: Sat Nov 11, 2017 3:06 am
Posts: 1
I have been using http://www.codeblocks.org/ for a long time. I had to use a plugin code beautification. But recently I found out an IDE https://www.jcppedit.com/ which has an inbuilt code beautifier.


Top
   
 Post subject: Re: Code Beautifier
PostPosted: Sun Nov 12, 2017 3:10 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 09, 2008 4:20 pm
Posts: 2083
Skype: yes
Location: Slovakia
Well it's definitely more common now to include this in an IDE than it was 10 years ago.

_________________
Image

Only dumb people quote themselves, and only the truest retards put such quotes in their forum signatures
-Drury


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.