tig12.net
Site personnel

Admin
Rubriques proches

Nombre de visites : 26
Mise en ligne : 05/2008
Dernière modif : 06/2008

 Data structures

To generate documentation, phpSimpleDoc first computes data structures expressing the documentable objects. This corresponds to the "model" part of the program.
It is called 'default' data structure because as phpSimpleDocs permits several documentor implementations, different implementations can rely on an different data structures. This data structure is used by the 'default' documentor implementation ; 'zendlike' and 'php' data structures are very close to the default one.

Inventory

There are several ways to organize documentable objects (noted DOs) ; here is the description used in phpSimpleDoc.
It helped to identify the code elements, their characteristics and the relations between them, but is not used as a class hierarchy in the code.

Hierarchy of documentable objects

Notes :
- Current implementation of the data structure is partial.

Storage

Documentable objects are stored as PHP arrays in Documentor's public property $data.

These arrays can be classified in three categories :
  1. Arrays that really contain data : "regular" arrays (indexed with integers)
    - classes,
    - classConstants,
    - classMethods,
    - classFields,
    - functions,
    - constants,
    - packages,
    - files,
    - dirs
  2. Arrays containing only references ; they are associative arrays ;
    keys = class names ; values = class indexes.
    - allClasses
    - normalClasses
    - abstractClasses
    - interfaces
    - nonInterfaces
    - exceptions
  3. Particular cases : $docu->data['classNames'] is just a regular array containing class names.
Each array is an entry of $docu->data : $docu->data['classes'] etc.

Complete list of fields

Here are the fields of arrays of type 1, as currently implemented :
classes
name
index
fileIndex
packageIndex
type
startLine
endLine
relativePath
absolutePath
prefix
declaringInstruction
modifiers
extends
implements
isAbstract
isInterface
isFinal
isException
methods
fields
constants
commentLine
commentObject
classMethods
name
index
classIndex
fileIndex
startLine
endLine
declaringInstruction
modifiers
visibility
isStatic
isAbstract
isFinal
overrides
overridenBy
specifies
specifiedBy
parameters
commentLine
commentObject
classFields
name
index
classIndex
fileIndex
startLine
endLine
declaringInstruction
defaultValue
modifiers
visibility
isStatic
overrides
overridenBy
commentLine
commentObject
classConstants
name
index
fileIndex
classIndex
value
startLine
endLine
declaringInstruction
commentLine
commentObject
functions
name
index
fileIndex
packageIndex
startLine
endLine
declaringInstruction
parameters
commentLine
commentObject
constants
name
index
fileIndex
packageIndex
value
startLine
declaringInstruction
commentLine
commentObject
packages
name
index
fullName
absolutePath
relativePath
commentObject
files
name
index
packageIndex
absolutePath
relativePath
classes
interfaces
functions
constants
dirs

Links

Links between the entities are expressed using the indexes of objects in arrays.
Hierarchy of documentable objects

Inheritance hierarchies

To express inheritance hierarchy, $docu->data['hierarchies'] is computed.
It contains :
- $docu->data['hierarchies']['class']
- $docu->data['hierarchies']['interface']
- $docu->data['hierarchies']['exception']
A dump of an element of these arrays look like that :
Array(
    [Class1] => Array(
            [parent] => DateTimeZone
            [children] => Array(
                    [0] => Class2
                    [1] => Class3
                    [2] => Class5
                )
        )
)

Some details

$docu->data['classes'][$i]['methods'] and ['fields']

Contains 2 sub-arrays, for static and instance methods ;
Here is an example for Class2 :
- Methods 12 and 13 are declared in Class2
- Methods 15, 18, 19 are inherited from Class1
- Methods getName(), getOffset(), getTransitions() are inherited from DateTimeZone.
The presence of the method name instead of its index means that the method is not part of documented code.
    [methods] => Array(
            [instance] => Array(
                    [Class2] => Array(
                            [0] => 12
                            [1] => 13
                        )
                    [Class1] => Array(
                            [0] => 15
                            [1] => 18
                            [2] => 19
                        )
                    [DateTimeZone] => Array(
                            [0] => getName
                            [1] => getOffset
                            [2] => getTransitions
                        )
                )
            [static] => Array(
                    [Class2] => Array(
                            [0] => 11
                            [1] => 14
                        )
                    [Class1] => Array(
                            [0] => 17
                        )
                    [DateTimeZone] => Array(
                            [0] => listAbbreviations
                            [1] => listIdentifiers
                        )
                )
        )
$docu->data['classes'][$i]['fields'] has the same structure

'Zendlike' data structure

This data structure is used to handle documentation generated with the 'zendlike' documentor implementation.
The differences with the defaut data structure comes from the fact that packages are handled differently :
- no packageIndex field in arrays $data['classes'], $data['constants'] and $data['functions'].
- $data['packages'], is replaced by 3 arrays :
  • $data['packages'] : associative array.
    keys : package names
    values : associative array with 2 entries : 'classes' and 'subpackages', which contain classes and subpackage names.
    $data['packages'] = Array(
          ['package1'] => Array(
                  ['classes'] => Array(
                          [0] => 'class1'
                      )
                  ['subpackages'] => Array(
                          [0] => 'package2'
                      )
              )
    )
    
  • $data['subpackages'] : associative array.
    keys : subpackage names
    values : associative array with 2 entries : 'classes' (contains classes names) and 'parent' (name of parent package).
    $data['subpackages'] = Array(
            ['package2'] => Array(
                    ['classes'] => Array(
                            [0] => 'class2'
                    )
                    ['parent'] => 'package1'
            )
    )
    
  • $data['c2p'] : associative array (c2p means "classes to packages").
    keys : class names
    values : associative array with 2 entries : 'package' (package name) and 'subpackage' (subpackage name).
    $data['c2p'] = Array(
          ['class2'] => Array(
                  ['package'] => 'package1'
                  ['subpackage'] => 'package2'
              )
    )
    


--Site écrit avec SPIP--Licence du contenu publié sur ce site--