Repository: incubator-streams Updated Branches: refs/heads/master 8de626e94 -> 571d4066e
STREAMS-438: Create coding guidelines document for website, this closes apache/incubator-streams#355 Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/571d4066 Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/571d4066 Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/571d4066 Branch: refs/heads/master Commit: 571d4066ee32e9a0f14cbe27a736422808a95099 Parents: 8de626e Author: smarthi <[email protected]> Authored: Sat Feb 4 21:15:02 2017 -0500 Committer: smarthi <[email protected]> Committed: Sat Feb 4 21:15:02 2017 -0500 ---------------------------------------------------------------------- src/site/markdown/code-conventions.md | 72 ++++++++++++++++++++++++++++++ src/site/site.xml | 1 + 2 files changed, 73 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/571d4066/src/site/markdown/code-conventions.md ---------------------------------------------------------------------- diff --git a/src/site/markdown/code-conventions.md b/src/site/markdown/code-conventions.md new file mode 100644 index 0000000..94a737c --- /dev/null +++ b/src/site/markdown/code-conventions.md @@ -0,0 +1,72 @@ +Title: Apache Streams Code Conventions + +The Apache Streams code should follow our code conventions. All code which +is contributed to the project should adhere to these guidelines. + +* Use 2 spaces for indentation. No tabs! +* Place open braces on the same line as the declaration, for example: + <pre><code> +public class Foo extends Bar { + public static void main(String args[]) { + try { + for (int i = 0; i < args.length; i++) { + System.out.println(Integer.parseInt(args[i])); + } + } + catch(NumberFormatException e) { + e.printStackTrace(); + } + } +} + </code></pre> +* Wrap lines longer than 140 characters. For wrapped lines use an indent of 4 characters. +* Within a class or interface, definitions should be ordered as follows: + * Class (static) variables + * Instance variables + * Constructors + * Methods + * Inner classes (or interfaces) + +* Do not use '*' package imports (for example import org.apache.streams.*) +* For other cases, we try to follow + [Java code conventions](http://www.oracle.com/technetwork/java/codeconventions-150003.pdf) as much as possible. + +# Formatter and Style files +* A code formatter file for IntelliJ can be found below. +```xml + <code_scheme name="Streams"> + <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" /> + <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" /> + <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND"> + <value /> + </option> + <option name="IMPORT_LAYOUT_TABLE"> + <value> + <package name="org.apache.streams" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="java" withSubpackages="true" static="false" /> + <package name="javax" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="" withSubpackages="true" static="true" /> + </value> + </option> + <MarkdownNavigatorCodeStyleSettings> + <option name="RIGHT_MARGIN" value="72" /> + </MarkdownNavigatorCodeStyleSettings> + <codeStyleSettings language="JAVA"> + <option name="RIGHT_MARGIN" value="140" /> + <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" /> + <option name="SPACE_BEFORE_ANNOTATION_ARRAY_INITIALIZER_LBRACE" value="true" /> + <option name="IF_BRACE_FORCE" value="3" /> + <option name="DOWHILE_BRACE_FORCE" value="3" /> + <option name="WHILE_BRACE_FORCE" value="3" /> + <option name="FOR_BRACE_FORCE" value="3" /> + <indentOptions> + <option name="INDENT_SIZE" value="2" /> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> + </code_scheme> + ``` \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/571d4066/src/site/site.xml ---------------------------------------------------------------------- diff --git a/src/site/site.xml b/src/site/site.xml index 42ec40c..3bc28de 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -102,6 +102,7 @@ <item name="Release Setup" href="release-setup.html" /> <item name="Release Process" href="release.html" /> <item name="Website Management" href="website.html" /> + <item name="Coding Conventions" href="code-conventions.html"/> </menu> <!--<menu name="Details">--> <!--<item name="Mailing Lists" href="mail-lists.html" />-->
