Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

tidyview - a tool for a best practice

by leriksen (Curate)
on Nov 24, 2006 at 23:32 UTC ( #585941=perlmeditation: print w/ replies, xml ) Need Help??

Coming in at #6 of Damian Conway's Ten Essential Development Pracices is "Agree upon a coherent style and automate it with perltidy."

Now perltidy is an excellent tool with a long heritage, and, importantly, is still under active development - there have been several releases this year. However, I always had problems with the many options it has. The nuber of options isn't surprising, anyone who has used a code formatting tool will know there are many ways to layout code - what to do with bracketsand braces, whitespace and tab handling, new line control, etc etc etc.

So I wrote a previewer for the effect of perltidy options, called tidyview. It is available through [CPAN] and the CVS tree is at [sourceforge].

As a side note, I had a lot of trouble deciding how best to release this to CPAN. CPAN has excellent support for modules, and poor support for applications. CPAN's idea of an application is a single in-line script, all in one file. And most people dont write applications (regardless of language) that way - at a minimum, configuration data is separated out and provided in a text file. In the end I didnt have to do anything special, but it wasn't at all obvious from CPAN's doco that I didn't have to do anything special.

One very nice side-effect of this project has been the creation of a new Tk module for displaying colored diff's - [Tk::DiffText]. This was contributed by a user of tidyview, which completely blew me away. I'd mentioned wanting this feature in the TODO file, so those things really do work!! The fact that now anyone can include colorised diff's in their perl Tk apps, as a result of spinning this feature out of tidyview and into its own module, thrills me to bits.

So if you want to automate perl code formatting with perltidy, but aren't sure exactly which options you need, give tidyview a whirl. I'd like to thank Steve Hancock who wrote perltidy, and provide a whole new API to help tidyview do its job, and Michael Carman, who contributed Tk::DiffText.

...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann

Comment on tidyview - a tool for a best practice
Re: tidyview - a tool for a best practice
by geekphilosopher (Friar) on Nov 25, 2006 at 08:55 UTC
    This looks like it could be pretty cool. I'm still developing my own perl style (as I've worked with in mostly maintenance mode, I've tried to keep the existing style in tact), and I'll likely have some input into my company's upcoming Coding Style document, so this will likely help out a lot.
Re: tidyview - a tool for a best practice
by brian_d_foy (Abbot) on Nov 25, 2006 at 18:05 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://585941]
Approved by ikegami
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-09-18 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (108 votes), past polls