cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Created: Tips for committers
Date Tue, 01 Aug 2006 15:20:00 GMT
A new document has been created.

Document ID: 1196
Branch: main
Language: default
Name: Tips for committers
Document Type: Cocoon Document
Created: 8/1/06 3:19:45 PM
Creator (owner): Helma van der Linden
State: publish


Mime type: text/xml
Size: 3687 bytes


<p>These are some tips to help committers to keep our Subversion (SVN)
repository clean. See also
<a href="">Committers FAQ</a> and
<a href="">PMC FAQ</a>.</p>

<h1>Coding Style Guidelines</h1>

<p>We do not want to get too concerned about style, other than a few obvious
things such as whitespace. Basically just follow the style that is already used
by the files that you are working on. We loosely follow the
<a href="">Sun Java Style Guide</a>.</p>

<h1>Consistent whitespace</h1>

<p>Whitespace can cause big problems with SVN. If it is inconsistent, then diffs
are very hard to follow - actual changes become lost in the noise of whitespace
changes. Some developers use editors that attempt to automatically format the
whitespace. The trouble is that if SVN files are inconsistent, some of those
editors just make it worse.</p>

<p>The solution comes in two parts:</p>

<p>When a committer adds a new file, they need to ensure that the file has the
correct line endings for their own operating system, and that either their SVN
client automatically sets the EOL settings for the file based upon the file
extension, or they must do:</p>

<pre>svn add myfile.txt
svn propset svn:eol-style native myfile.txt

<p>is that some committers who have a proper editor should occasionally correct
the whitespace across all SVN files, applying the following rules.</p>

<p>For all text files:</p>

<li>Replace all tabs with spaces.</li>
<li>No trailing whitespace.</li>
<li>No MS-DOS line endings.</li>
<li>Newline at end-of-file.</li>
<li>Single whitespace between words.</li>

<p>For all Java source files, as for text files plus:</p>

<li>Use 4-space indentation.</li>

<p>For all XML source files, as for text files plus:</p>

<li>Use 2-space indentation.</li>
<li>No whitespace at start-of-file.</li>
<li>No whitespace at end-of-file (except of course a newline).</li>

<h1>dos2unix and other control-characters</h1>

<p>If you are on a UNIX system, when you receive a patch from a contributor on
Windows then do a 'dos2unix'. If you are on a Windows system, then ensure that
you have a proper SVN client (it is supposed to convert to UNIX line-endings
when you commit).</p>

<p>Here is one UNIX way to find all plain-text files that have DOS line-endings
(and maybe mixed line-endings). There seem to be many images and jar archives
that contain carriage-returns, so to list only the plain-text files:</p>

<pre>find . -type f | xargs grep -l '^M' | xargs file | \
grep -i -w text | cut -f1 -d:

To add the ^M use "Ctrl-v Ctrl-m" at the command-line.
Note that copy-and-paste will not work.
The -w can be omitted, but might then match some extra filenames.

<p>To instead find <em>all</em> files (including images and foreign jar
archives) that have DOS line-endings: <tt>find . -type f | xargs grep -l

<p>Here is one way to find files that have <em>any</em> hidden control
characters: <tt>find . -type f | xargs grep -l '[[:cntrl:]]'</tt></p>

<h1>Valid XML instances</h1>

<p>Many of us have wasted time with a broken build due to xml validation errors.
Would all committers please either use a proper xml editor or validate their
xdocs with one of the following commands:</p>

<pre>onsgmls -c $COCOON_HOME/src/webapp/WEB-INF/entities/catalog \
-wall -wxml -s mydoc.xml

<pre>export SGML_CATALOG_FILES=$COCOON_HOME/src/webapp/WEB-INF/entities/catalog
xmllint --valid --catalogs --noout mydoc.xml

<pre>forrest validate-xdocs


The document belongs to the following collections: generaldocs

View raw message