Copyright Notice: You can reprint anything, please sure to indicate the original source and author information and this statement by hyperlink. Http://www.chedong.com/tech/undent_tools.html
Keywords: pretty print indent Perlty Pydent AStyle Htmltidy Source Code Beautifier
Summary: The purpose of writing this article is nothing more than 2:
If the predecessor's indentation is very unlined, it affects the code reading speed of the current maintainer. New project code (writing in what editing environment) can adapt to the company's indentation specification, which can facilitate communication between developers.
If you can find it now, you need to see you need to see the last: The document in the corresponding kit will have more detailed instructions.
C, C C # ==> indent AStylejava ==> AStyle Jalopy Jacobe Importscrbberphp ==> phpcodebeautifierperl ==> PerltiDython ==> Pydent
ASP ==> VBSBEAUT
The programmer should be good at communicating, the meaning of code beautification is to reflect the respect of the developer's respect for others, using good coding conventions to make source code, easy to read, accurate, more intuitive and more intuitive and other language agreement, thus Better communication between programmers.
There is a statistical indicate that the indentation code can improve the efficiency of code reading more than 40%, and the other statistics are more than 70% of software development work is the code for maintenance, so the format of past code is often the system reconstruction ( The first step in Refactoring. The use of the PRETTY Print Program allows the basic code indent specification to become a system that is easier to perform.
In addition, if the servant as a sector code specification should also understand the programmaker is not a machine, it is almost impossible when writing code. Tool-based volume formatting and organizing tools for easy configuration Import / export mechanisms Develop a unified indentation specification is a truly operability.
Introduction to the code beautifying tools for open source code
Tool Name Applicable Language Introduction Installation / Using Indent Cindent is a standard tool for code beautifying tools Indent is a standard tool included with GCC, Indenter, Indenter, Indenter, Indenter, Indenter, Indenter, Indenter, Indenter File] Perltidy Perl Perltidy itself is also downloaded by Perl: Perl makefile.pl; make; make install perltix [options] file1 file2 file3 ... (Output Goes to file1.tdy, file2.tdy, file3.tdy,. ..) Perltix [options] file1 -o outfile perltix [Options] file1 -st> Outfile Perlty [options]
Option Description:
-RAW: Does not modify Chinese characters (Output Values Above 127 without conversion to entities)
-i indend default HTML Press 2 space indentation
-m covers the original file
-u Force all HTML marker uppercase (this can not add)
-WRAP page code width is greater than 132 lines forced wrap
-f% f.err outputs an error to the "corresponding file name .ERR" file
HTMLTIDY supports XML format beautification:
Tidy-xml -imq web.xml
Tidy-xml -imq build.xml
Other tool introductions:
PHP Code Beautif Tool phpcb: PHP Code Beautifier has a command line version, and there is a code viewer with a graphics interface. Http://www.phnedit.net/products/phpcodebeautifier/java's code beautification tool If it is specifically for Java code, Jacobe is also a good choice, it is default, which contains a format that completely followed by Sun's code specification. Chemical configuration file. And even Jindent This commercial code finishing tool for better results.
Importscrbber: Java Import declarations to make the reference java.util. * Such references into a single reference, and help delete a reference that no longer needs. http://importscrubber.sourceforge.net/
Introduce these tools can be found here: Jacobe Jindent JxBeautifier ... http://directory.google.com/top/computers/programming/languages/java/development_tools/code_beautifierrs/
Use the command line tool to implement the batch modification of the code
Under Windows 2000: Directory traversal and file filtering and command execution are implemented with the for command, for example: for / R% f in (* .java) do school --style = java% f for / R% f in (* .htm * ) Do Tidy -raw -imq -wrap 132 -F% F.ERR% f for / R% f in (* .asp) do vbsbeaut.exe -i -s4% F Linux: Execute with Find -exec, for example: Find ./ -Name * .java -exec ASTYLE --Style = ANSI {} /;
So don't be confused by many commercial software, when faced with thousands of source files, it is also a very important feature based on whether ordered batch operations.
Tool plugin for Ide development environments such as Eclipse
More and more IDE development environments contain code beautification, but some are still unlikely to be strong, and if there is eclipse in developers, some of the loyal users of JBuilder, how to make them easily abide by code Standardize? The answer is to use all JALOPY to develop the environment for these mainstream IDE development environments. JALOPY: Java code beautification tool: http://jalopy.sourceforge.net/ Eclipse Plug-in: http://jalopy.sourceforge.net/plugin-eclipse.html Checkstyle: Java code code specification (indent, naming) check Tool http://checkstyle.sourceforge.net Eclipse Plug-in: Eclipse Checkstyle Plug-in
Installation: Plug-in installation as Eclipse is very convenient, unpackage to the Eclipse / PLUG-IN / directory to restart Eclipse:
Configuration: Jalopy: Windows ==> Jalopy Preference Configure Import / Export in General Mengers, Checkstyle: Windows ==> Perference ==> Checkstyle Configuration Import / Export is the import / export function of the configuration interface right It greatly reduces the study time for developers for the above tools. For most developers, there is no need to understand all the option configurations, just know that the standard configuration is imported. I often use: Jalopy: In addition to the original format option, in addition to the original format option, the Source => Orgenize Imports that Eclipse itself can be reached in addition to the original Format option. Imports srubber The same effect. Checkstyle is a very complex code style check: including indentation, naming, etc., so the default is disable, startup checkstyle needed for a project, the project's Properties ==> CheckStyle ==> Enable.
Moreover, these tools include extensions for Ant, which can be easily added to the ANT script for automatic code finishing / statistics.
Reference:
GNU Coding Standards http://www.gnu.org/prep/standards_toc.html
Code Conventions for the Java (TM) programming language http://java.sun.com/docs/codeconv/html/codeconvtoc.doc.html
PHP Coding Standard http://alltasks.net/code/php_coding_standard.html
Perl style http://www.Perldoc.com/perl5.6.1/pod/perlstyle.html PB: Perl / JavaScript Beautifier
http://www.arachnoid.com/lutusp/ftp/cgi/pb.txt
HTML XML XHTML CSS ... http://www.w3c.org C-C Beautifier How-to:
http://www.tldp.org/howto/c-c beautifier-howto/
VBScript code specification http://msdn.microsoft.com/library/en-us/script56/html/vbscodingconventions.asp
VBSBeaut code finishing tool http://www.daansystems.com/vbsbeaut/
Dependency analysis between Java components http://www.clarkware.com/software/jdepend.html
Code check http://www.thecortex.net/clover/index.html
More XP Tools http://directory.google.com/top/computers/programming/languages/java/coding_standards/ http://www.xprogramming.com/software.htm http://www.qsm.com/codecounters .html
Attachment: Why HTMLTIDY is not suitable for reformatting the JSP PHP ASP and other HTML embedded scripting languages
Some errors that cannot be parsed are actually caused by the code irregular.
"<" In JavaScript, for example, for (i = 1; i > But like this code: <% = infoForm.getphoto ()%> width = 120> due to The beginning of the property is not <%, so IMG has no end error htmltidy default is completely complemented by the code, and many HTML code is in the included file. Moreover, HTMLTIDY has a problem with Chinese code recognition (currently only supporting BIG5):
Why is embedded code difficult to maintain? After all, it is more complicated to the unregistered HTML syntax inspector than a language parser. For example, such as this code: Php echo "