buildframework/helium/doc/src/development/coding_conventions.rst
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
child 645 b8d81fa19e7d
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
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
   
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    76
   It is **not** possible to link to the task or anything in the Java documentation. 
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
Creating Index References
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
`````````````````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
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
    82
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
  .. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
     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
    85
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
put this text at the top of the file::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
  .. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
    single: heading text
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
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
    92
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
If you replace 'single' with 'pair' it puts 2 enteries in the index:::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
  .. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
     pair: iname1; ename2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
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
    99
below it and indented (in the 'e' section)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
The index directive needs blank lines either side of it.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
Ant conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
======================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
These conventions are applicable to all Ant XML script files.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
API documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
-----------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
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
   112
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
* Additional documentation is written as XML comments.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
* 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
   115
* The text format of the documentation can be formatted in MediaWiki_ format.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
* 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
   117
* 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
   118
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
    <!--* comment text
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
    @scope private
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
    -->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
.. _MediaWiki: http://www.mediawiki.org/wiki/Help:Formatting
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
* A number of tags are supported:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
.. csv-table:: Ant comment tags
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
   :header: "Tag", "Applies to", "Description"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
   "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
   132
   "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
   133
   "type", "Properties", "The type of the property value. Valid values are ``string`` (default), ``integer``, ``boolean``."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
   "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
   135
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
* 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
   137
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
    <!--* @property name.of.property
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
    This property must be defined by the user.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
    @scope public
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
    @editable required
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
    @type integer
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
    -->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
Projects
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
* 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
   150
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
    <!--* comment text -->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
* A project can be defined as a member of a package in this way::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
    <!-- @package framework -->
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
  single: XML Indentations
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
XML indentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
---------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
* Indents are 4 spaces. Tabs should not be used.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
* The XML element structure should be consistently indented.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
  single: File Names
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
File names
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
----------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
* 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
   174
* All other Ant files should end with "``.ant.xml``".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
  single: File Organisation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
File organisation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
-----------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
* ``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
   183
* ``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
   184
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
  single: Targets
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
Targets
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
-----------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
* Target names are a mix of lowercase letters and numbers and the '-' character.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
* 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
   193
* 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
   194
* 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
   195
* 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
   196
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
  single: Properties
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
.. _properties_label:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   202
Properties
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   203
----------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   204
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   205
* Properties are named using lowercase words separated by the '.' character.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   206
* 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
   207
* 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
   208
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   209
.. csv-table:: Property naming conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   210
   :header: "Rule", "Description"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   211
   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   212
   "File paths", "Property name should end with ``.file``"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   213
   "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
   214
   "Value list", "Property name should end with ``.list``."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   215
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   216
Ant tasks
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   217
---------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   218
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   219
There are two preferred ways to implement an Ant task:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   220
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   221
* A pure Java Task subclass.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   222
* A ``<scriptdef>`` task using Jython.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   223
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   224
In general these guidelines should be noted:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   225
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   226
* 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
   227
* 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
   228
* 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
   229
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   230
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
   231
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   232
Scripts
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   233
-------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   234
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   235
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
   236
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   237
* A ``<script>`` task using Jython.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   238
* 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
   239
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   240
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
   241
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   242
    <hlm:python>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   243
    import mycode
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   244
    mycode.dostuff(r'${prop.1}')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   245
    </hlm:python>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   246
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   247
    <script language="jython">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   248
    import mycode
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   249
    value = mycode.dostuff(project.getProperty('prop.1'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   250
    project.setProperty('xyz', value)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   251
    </script>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   252
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   253
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
   254
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   255
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   256
  single: Java conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   257
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   258
Java conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   259
================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   260
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   261
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   262
  single: Ant Task Documentions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   263
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   264
Ant task documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   265
----------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   266
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   267
* 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
   268
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   269
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   270
     * Code Sample for Ant Task class Comments
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   271
     * @ant.task name="copy" category="filesystem"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   272
     * @ant.task ignored="true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   273
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   274
    public class Copy
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   275
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   276
* 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
   277
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   278
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   279
     * Code Sample for Ant Task property Comments
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   280
     * @ant.required 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   281
     * Default is false.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   282
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   283
    public void setOverwrite(boolean overwrite){ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   284
        this.forceOverwrite = overwrite;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   285
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   286
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   287
All custom tasks should be commented in this way.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   288
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   289
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   290
  single: File Execution
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   291
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   292
File execution
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   293
==============
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   294
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   295
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
   296
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   297
    python foo.py
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   298
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   299
not::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   300
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   301
    foo.py
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   302
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   303
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   304
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   305
  single: Documentation conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   306
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   307
Documentation conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   308
=========================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   309
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   310
Standalone documents are written in reStructuredText_ format.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   311
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   312
.. _reStructuredText : http://docutils.sourceforge.net/rst.html
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   313
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   314
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   315
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   316
  single: Python conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   317
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   318
Python conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   319
=========================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   320
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   321
Specific conventions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   322
--------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   323
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   324
Python Code Indentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   325
```````````````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   326
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   327
* Indents are 4 spaces. Tabs should not be used.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   328
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   329
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   330
Documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   331
`````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   332
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   333
* 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
   334
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   335
.. _`PEP 257 - Docstring Conventions` : http://www.python.org/dev/peps/pep-0257/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   336
.. _Epydoc : http://epydoc.sourceforge.net/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   337
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   338
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   339
Unit testing
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   340
````````````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   341
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   342
* Unit tests are written for each Python module.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   343
* They should follow the Nose_ testing framework conventions.
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   344
* The test suite is run by calling :hlm-t:`py-unittest`.
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   345
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   346
.. _Nose : http://somethingaboutorange.com/mrl/projects/nose/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   347
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   348
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   349
Lint 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   350
````
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   351
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   352
* Always check your code with pylint_ before checking it in.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   353
* Aim for pylint_ score >= 8.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   354
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   355
.. _pylint: http://www.logilab.org/857
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   356
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   357
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   358
Reference coding standards
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   359
--------------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   360
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   361
These reference standards are used for all conventions not covered above.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   362
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   363
* `PEP 8 - Style Guide for Python Code`_.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   364
* `Twisted Coding Standard`_ (but with a grain of salt):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   365
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   366
.. _`PEP 8 - Style Guide for Python Code` : http://www.python.org/dev/peps/pep-0008/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   367
.. _`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
   368
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   369
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   370
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   371
  single: Quality Checklist
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   372
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   373
Quality checklist
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   374
=================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   375
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   376
'''Python'''
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   377
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   378
* All modules have a single description line in the module comment.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   379
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   380
.. index::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   381
  single: Bad Word Scanner configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   382
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   383
Bad Word Scanner configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   384
==============================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   385
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   386
This section will probably only ever be used by a helium contributor:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   387
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   388
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
   389
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
   390
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   391
Run the following command ::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   392
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   393
    hlm check-bad-words