buildframework/helium/doc/src/development/coding_conventions.rst
author wbernard
Tue, 27 Apr 2010 08:33:08 +0300
changeset 587 85df38eb4012
child 588 c7c26511138f
permissions -rw-r--r--
helium_9.0-a7879c935424
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
..  ============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
    Name        : coding_conventions.rst
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
    Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
    Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
    All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
    This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
    under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
    which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
    at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
    Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
    Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
    Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
    Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
    ============================================================================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
##############################
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
Coding Conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
##############################
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
  module: Coding Conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
.. contents::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
Introduction
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
============
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
This describes how you should write code for Helium. It covers Ant XML, Java and Python.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
  single: General Conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
General conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
===================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
* Changing the working directory should be avoided in any language.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
  single: Ant Conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
Documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
=============
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
Standalone documents like this design document and the user guide are documented in reStructuredText__ format.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
__ http://docutils.sourceforge.net/rst.html
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
Run the ``hlm docs`` command to generate documentation under ``/helium/build/doc``.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
  single: Index References-creating
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
ReStructuredText documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
------------------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
Linking to the API reference
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
````````````````````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
It is possible to link to targets, properties and macros in the API documentation using a custom reStructuredText__ role, e.g::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
    :hlm-t:`target-name`
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
.. csv-table:: Custom API roles
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
   :header: "Name", "Links to"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
   "``hlm-t``", "Targets"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
   "``hlm-p``", "Properties"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
   "``hlm-m``", "Macros"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
Creating Index References
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
`````````````````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
In order to get things in the index you have to manually add the following code to the ``.rst`` files: ::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
  .. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
     module: file heading (the text in the 1st heading at the top of the page) gets added to index as module
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
put this text at the top of the file::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
  .. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
    single: heading text
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
put this just above a heading. This gets added to the index as a normal indexed link.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
If you replace 'single' with 'pair' it puts 2 enteries in the index:::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
  .. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
     pair: iname1; ename2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
In the index it becomes iname1 with ename2 below it and indented (in the 'i' section) and also ename2 with iname1 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
below it and indented (in the 'e' section)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
The index directive needs blank lines either side of it.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
Ant conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
======================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
These conventions are applicable to all Ant XML script files.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
API documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
-----------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
The Helium API documentation is generated directly from the Ant source files. Additional documentation for Ant objects (properties, targets, macros, etc) and special markup is defined in a similar style to JavaDoc, following these conventions:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
* Additional documentation is written as XML comments.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
* Typically the preceeding comment for an Ant object is assumed to relate to that object. A comment can be definitively noted as a Ant documentation comment by adding a ``*`` character at the start.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
* The text format of the documentation can be formatted in MediaWiki_ format.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
* The first sentence of the comment is taken as the summary for short text fields. The rest of the text is the full documentation.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
* Specific metadata tags are defined using ``@``. Each tag should be on a newline and all tags should be after the general documentation paragraphs::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
    <!--* comment text
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
    @scope private
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
    -->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
.. _MediaWiki: http://www.mediawiki.org/wiki/Help:Formatting
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
* A number of tags are supported:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
.. csv-table:: Ant comment tags
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
   :header: "Tag", "Applies to", "Description"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
   "scope", "All elements", "The scope or visibility of the element. Valid values are ``public`` (default), ``protected`` and ``private``."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
   "editable", "All types", "Whether this element should be overridden or defined by the user. Valid values are ``required`` and ``optional``"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   132
   "type", "Properties", "The type of the property value. Valid values are ``string`` (default), ``integer``, ``boolean``."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
   "deprecated", "All elements", "Documents that the element is deprecated and may be removed in a future release. The text should describe what to use instead."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   135
* Some properties (and other types) are only defined by the user, so there is no default declaration inside Helium. These can be documented completely within a comment::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
    <!--* @property name.of.property
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
    This property must be defined by the user.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
    @scope public
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
    @editable required
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
    @type integer
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
    -->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
Projects
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
* Project comments must have the ``*`` character in order to avoid assuming that the copyright comment block is project documentation::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
    <!--* comment text -->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
* A project can be defined as a member of a package in this way::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
    <!-- @package framework -->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
  single: XML Indentations
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
XML indentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
---------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
* Indents are 4 spaces. Tabs should not be used.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
* The XML element structure should be consistently indented.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
  single: File Names
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
File names
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
----------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
* Ant files intended to be called by a ``bld.bat`` should be named ``build.xml`` (the default name Ant looks for).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
* All other Ant files should end with "``.ant.xml``".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
  single: File Organisation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
File organisation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
-----------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
* ``helium.ant.xml`` is the root Ant file under ``/helium`` that includes all the other Ant files.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
* ``helium.ant.xml`` should only include top-level build stage Ant files, e.g. ``preparation.ant.xml``. Within each build stage directory, further Ant files should be included by that build stage file. This reduces frequent edits to ``helium.ant.xml``.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   183
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
  single: Targets
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
Targets
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
-----------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
* Target names are a mix of lowercase letters and numbers and the '-' character.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
* Configuration files needed as input to external scripts/tools are not defined as arguments using any kind of hardcoded path (absolute or relative). Rather an Ant property should define the path to the file and that property value is used as the argument in the call to the tool.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
* Ant properties are used in preference (where the option exists) to external environment variables (that start with ``env.``).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   193
* Targets can be marked as deprecated by adding one optional tag ``<deprecated> value </deprecated>`` in the comment tag top of the target area.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   194
* Targets can be marked as private by adding ``Private:`` in the comment tag top of the target area.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   195
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
  single: Properties
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
.. _properties_label:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
Properties
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   202
----------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   203
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   204
* Properties are named using lowercase words separated by the '.' character.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   205
* Values should not have any dependencies on the location of the ``helium`` project. Based on the ``HELIUM_HOME`` setting, the project could be anywhere, so paths should not assume it to be relative to any other location.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   206
* Properties can be marked as deprecated in the data model by adding one optional tag ``<deprecated>``.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   207
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   208
.. csv-table:: Property naming conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   209
   :header: "Rule", "Description"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   210
   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   211
   "File paths", "Property name should end with ``.file``"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   212
   "Directory paths", "Property name should end with ``.dir``. The ``location`` attribute is recommended over ``value``. No trailing slashes are required. Paths should use other properties such as ``build.drive`` to be flexible. Forward slashes should be used, unless backslashes are specifically needed."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   213
   "Value list", "Property name should end with ``.list``."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   214
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   215
Ant tasks
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   216
---------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   217
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   218
There are two preferred ways to implement an Ant task:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   219
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   220
* A pure Java Task subclass.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   221
* A ``<scriptdef>`` task using Jython.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   222
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   223
In general these guidelines should be noted:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   224
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   225
* Use short, descriptive task names that fit with the Ant naming style. All custom tasks should be under the ``hlm:`` namespace.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   226
* Avoid referencing property values directly inside the task implementation. Data values should typically be passed as attributes.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   227
* Do not put large chuck Jython code inside Ant side, make sure the functional part of the code is unit-tested.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   228
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   229
Implement using tasks when the functionality may be used in more than one place or it will help the design and maintenance to provide a well-defined interface for that function.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   230
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   231
Scripts
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   232
-------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   233
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   234
A script allows more flexible code than is provided by the standard tasks while not being as formalized as a new custom task. There are two preferred ways to implement embedded scripts:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   235
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   236
* A ``<script>`` task using Jython.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   237
* A ``<hlm:python>`` task using embedded Python code. This typically does not allow much interaction with the Ant process.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   238
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   239
Here properties can be accessed directly but it is good practice to only reference them in the embedded code. If the functionality is significant create separate Python libraries as needed and call them from the embedded script, e.g::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   240
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   241
    <hlm:python>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   242
    import mycode
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   243
    mycode.dostuff(r'${prop.1}')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   244
    </hlm:python>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   245
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   246
    <script language="jython">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   247
    import mycode
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   248
    value = mycode.dostuff(project.getProperty('prop.1'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   249
    project.setProperty('xyz', value)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   250
    </script>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   251
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   252
Use a script when prototyping or a more specialized operation is needed in only one place. Embedded scripts should generally be kept as short as possible.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   253
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   254
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   255
  single: Java conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   256
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   257
Java conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   258
================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   259
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   260
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   261
  single: Ant Task Documentions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   262
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   263
Ant task documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   264
----------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   265
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   266
* Javadoc comment of a Ant task class should include the Ant-specific tag ``@ant.task``. It accepts three "attributes": ``name``, ``category`` and ``ignored``. When ``ignored=true``, the class will not be included in the documentation. For example::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   267
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   268
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   269
     * Code Sample for Ant Task class Comments
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   270
     * @ant.task name="copy" category="filesystem"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   271
     * @ant.task ignored="true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   272
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   273
    public class Copy
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   274
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   275
* The task properties documentation is extracted from the property getter/setter methods. The tags are ``@ant.required`` and ``@ant.not-required`` which indicate if the property is required or not required. For example::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   276
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   277
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   278
     * Code Sample for Ant Task property Comments
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   279
     * @ant.required 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   280
     * Default is false.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   281
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   282
    public void setOverwrite(boolean overwrite){ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   283
        this.forceOverwrite = overwrite;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   284
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   285
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   286
All custom tasks should be commented in this way.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   287
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   288
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   289
  single: File Execution
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   290
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   291
File execution
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   292
==============
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   293
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   294
File execution should not depend on the extension of the file. The appropriate executable should be used to run the script, e.g::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   295
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   296
    python foo.py
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   297
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   298
not::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   299
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   300
    foo.py
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   301
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   302
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   303
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   304
  single: Documentation conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   305
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   306
Documentation conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   307
=========================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   308
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   309
Standalone documents are written in reStructuredText_ format.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   310
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   311
.. _reStructuredText : http://docutils.sourceforge.net/rst.html
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   312
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   313
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   314
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   315
  single: Python conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   316
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   317
Python conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   318
=========================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   319
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   320
Specific conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   321
--------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   322
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   323
Python Code Indentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   324
```````````````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   325
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   326
* Indents are 4 spaces. Tabs should not be used.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   327
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   328
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   329
Documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   330
`````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   331
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   332
* Docstrings are written in reStructuredText_ format, according to `PEP 257 - Docstring Conventions`_. Documentation is extracted using Epydoc_, so the reStructuredText tags that Epydoc recognises are used.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   333
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   334
.. _`PEP 257 - Docstring Conventions` : http://www.python.org/dev/peps/pep-0257/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   335
.. _Epydoc : http://epydoc.sourceforge.net/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   336
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   337
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   338
Unit testing
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   339
````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   340
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   341
* Unit tests are written for each Python module.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   342
* They should follow the Nose_ testing framework conventions.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   343
* The test suite is run by calling ``hlm py-unittest``.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   344
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   345
.. _Nose : http://somethingaboutorange.com/mrl/projects/nose/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   346
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   347
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   348
Lint 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   349
````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   350
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   351
* Always check your code with pylint_ before checking it in.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   352
* Aim for pylint_ score >= 8.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   353
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   354
.. _pylint: http://www.logilab.org/857
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   355
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   356
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   357
Reference coding standards
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   358
--------------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   359
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   360
These reference standards are used for all conventions not covered above.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   361
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   362
* `PEP 8 - Style Guide for Python Code`_.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   363
* `Twisted Coding Standard`_ (but with a grain of salt):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   364
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   365
.. _`PEP 8 - Style Guide for Python Code` : http://www.python.org/dev/peps/pep-0008/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   366
.. _`Twisted Coding Standard` : http://twistedmatrix.com/trac/browser/trunk/doc/development/policy/coding-standard.xhtml?format=raw
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   367
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   368
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   369
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   370
  single: Quality Checklist
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   371
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   372
Quality checklist
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   373
=================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   374
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   375
'''Python'''
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   376
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   377
* All modules have a single description line in the module comment.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   378
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   379
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   380
  single: Bad Word Scanner configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   381
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   382
Bad Word Scanner configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   383
==============================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   384
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   385
This section will probably only ever be used by a helium contributor:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   386
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   387
Bad word scanner scans the helium code for the words that should not be in the helium source code. You need to include the bad words
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   388
in a .cvs file and scan the directory of the source code. Bad words include Nokia product names, competitors product names etc.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   389
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   390
Run the following command ::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   391
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   392
    hlm check-bad-words