Python: document writer.Writer
[babeltrace.git] / bindings / python / writer.py
index fbcd68754745c5144f53c68c35fca09d8f5373e2..f1525214511127876ab4f54ca7b6d2a21c121327 100644 (file)
@@ -35,17 +35,40 @@ _MAX_UINT64 = 0xFFFFFFFFFFFFFFFF
 
 class EnumerationMapping:
     """
-    Enumeration mapping class. start and end values are inclusive.
+    Mapping from an enumeration label to a range of integers.
     """
 
     def __init__(self, name, start, end):
+        """
+        Creates an enumeration mapping, where label *name* is mapped to
+        the [*start*, *end*] range of integers (*end* is included).
+
+        Set *start* and *end* to the same value to create an enumeration
+        mapping to a single value.
+        """
+
         self.name = name
         self.start = start
         self.end = end
 
 
 class Clock:
+    """
+    A CTF clock allows the description of the system's clock topology, as
+    well as the definition of each clock's parameters.
+
+    :class:`Clock` objects must be registered to a :class:`Writer`
+    object (see :meth:`Writer.add_clock`), as well as be registered to
+    a :class:`StreamClass` object (see :attr:`StreamClass.clock`).
+    """
+
     def __init__(self, name):
+        """
+        Creates a default CTF clock named *name*.
+
+        :exc:`ValueError` is raised on error.
+        """
+
         self._c = nbt._bt_ctf_clock_create(name)
 
         if self._c is None:
@@ -57,7 +80,11 @@ class Clock:
     @property
     def name(self):
         """
-        Get the clock's name.
+        Clock name.
+
+        Set this attribute to change the clock's name.
+
+        :exc:`ValueError` is raised on error.
         """
 
         name = nbt._bt_ctf_clock_get_name(self._c)
@@ -70,18 +97,17 @@ class Clock:
     @property
     def description(self):
         """
-        Get the clock's description. None if unset.
+        Clock description (string).
+
+        Set this attribute to change the clock's description.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_clock_get_description(self._c)
 
     @description.setter
     def description(self, desc):
-        """
-        Set the clock's description. The description appears in the clock's TSDL
-        meta-data.
-        """
-
         ret = nbt._bt_ctf_clock_set_description(self._c, str(desc))
 
         if ret < 0:
@@ -90,7 +116,11 @@ class Clock:
     @property
     def frequency(self):
         """
-        Get the clock's frequency (Hz).
+        Clock frequency in Hz (integer).
+
+        Set this attribute to change the clock's frequency.
+
+        :exc:`ValueError` is raised on error.
         """
 
         freq = nbt._bt_ctf_clock_get_frequency(self._c)
@@ -102,10 +132,6 @@ class Clock:
 
     @frequency.setter
     def frequency(self, freq):
-        """
-        Set the clock's frequency (Hz).
-        """
-
         ret = nbt._bt_ctf_clock_set_frequency(self._c, freq)
 
         if ret < 0:
@@ -114,7 +140,11 @@ class Clock:
     @property
     def precision(self):
         """
-        Get the clock's precision (in clock ticks).
+        Clock precision in clock ticks (integer).
+
+        Set this attribute to change the clock's precision.
+
+        :exc:`ValueError` is raised on error.
         """
 
         precision = nbt._bt_ctf_clock_get_precision(self._c)
@@ -126,16 +156,16 @@ class Clock:
 
     @precision.setter
     def precision(self, precision):
-        """
-        Set the clock's precision (in clock ticks).
-        """
-
         ret = nbt._bt_ctf_clock_set_precision(self._c, precision)
 
     @property
     def offset_seconds(self):
         """
-        Get the clock's offset in seconds from POSIX.1 Epoch.
+        Clock offset in seconds since POSIX.1 Epoch (integer).
+
+        Set this attribute to change the clock's offset in seconds.
+
+        :exc:`ValueError` is raised on error.
         """
 
         offset_s = nbt._bt_ctf_clock_get_offset_s(self._c)
@@ -147,10 +177,6 @@ class Clock:
 
     @offset_seconds.setter
     def offset_seconds(self, offset_s):
-        """
-        Set the clock's offset in seconds from POSIX.1 Epoch.
-        """
-
         ret = nbt._bt_ctf_clock_set_offset_s(self._c, offset_s)
 
         if ret < 0:
@@ -159,7 +185,12 @@ class Clock:
     @property
     def offset(self):
         """
-        Get the clock's offset in ticks from POSIX.1 Epoch + offset in seconds.
+        Clock offset in ticks since (POSIX.1 Epoch +
+        :attr:`offset_seconds`).
+
+        Set this attribute to change the clock's offset.
+
+        :exc:`ValueError` is raised on error.
         """
 
         offset = nbt._bt_ctf_clock_get_offset(self._c)
@@ -171,10 +202,6 @@ class Clock:
 
     @offset.setter
     def offset(self, offset):
-        """
-        Set the clock's offset in ticks from POSIX.1 Epoch + offset in seconds.
-        """
-
         ret = nbt._bt_ctf_clock_set_offset(self._c, offset)
 
         if ret < 0:
@@ -183,8 +210,13 @@ class Clock:
     @property
     def absolute(self):
         """
-        Get a clock's absolute attribute. A clock is absolute if the clock
-        is a global reference across the trace's other clocks.
+        ``True`` if this clock is absolute, i.e. if the clock is a
+        global reference across the other clocks of the trace.
+
+        Set this attribute to change the clock's absolute state
+        (boolean).
+
+        :exc:`ValueError` is raised on error.
         """
 
         is_absolute = nbt._bt_ctf_clock_get_is_absolute(self._c)
@@ -196,20 +228,19 @@ class Clock:
 
     @absolute.setter
     def absolute(self, is_absolute):
-        """
-        Set a clock's absolute attribute. A clock is absolute if the clock
-        is a global reference across the trace's other clocks.
-        """
-
         ret = nbt._bt_ctf_clock_set_is_absolute(self._c, int(is_absolute))
 
         if ret < 0:
-            raise ValueError("Could not set the clock's absolute attribute.")
+            raise ValueError("Could not set the clock absolute attribute.")
 
     @property
     def uuid(self):
         """
-        Get a clock's UUID (an object of type UUID).
+        Clock UUID (an :class:`uuid.UUID` object).
+
+        Set this attribute to change the clock's UUID.
+
+        :exc:`ValueError` is raised on error.
         """
 
         uuid_list = []
@@ -226,10 +257,6 @@ class Clock:
 
     @uuid.setter
     def uuid(self, uuid):
-        """
-        Set a clock's UUID (an object of type UUID).
-        """
-
         uuid_bytes = uuid.bytes
 
         if len(uuid_bytes) != 16:
@@ -245,8 +272,12 @@ class Clock:
     @property
     def time(self):
         """
-        Get the current time in nanoseconds since the clock's origin (offset and
-        offset_s attributes).
+        Clock current time; nanoseconds (integer) since clock origin
+        (POSIX.1 Epoch + :attr:`offset_seconds` + :attr:`offset`).
+
+        Set this attribute to change the clock's current time.
+
+        :exc:`ValueError` is raised on error.
         """
 
         time = nbt._bt_ctf_clock_get_time(self._c)
@@ -258,32 +289,42 @@ class Clock:
 
     @time.setter
     def time(self, time):
-        """
-        Set the current time in nanoseconds since the clock's origin (offset and
-        offset_s attributes). The clock's value will be sampled as events are
-        appended to a stream.
-        """
-
         ret = nbt._bt_ctf_clock_set_time(self._c, time)
 
         if ret < 0:
             raise ValueError("Invalid time value.")
 
 
+class IntegerBase:
+    """
+    Display base of an integer.
+    """
+
+    #: Unknown
+    INTEGER_BASE_UNKNOWN = -1
+
+    #: Binary
+    INTEGER_BASE_BINARY = 2
+
+    #: Octal
+    INTEGER_BASE_OCTAL = 8
+
+    #: Decimal
+    INTEGER_BASE_DECIMAL = 10
+
+    #: Hexadecimal
+    INTEGER_BASE_HEXADECIMAL = 16
+
+
 class FieldDeclaration:
     """
-    FieldDeclaration should not be instantiated directly. Instantiate
-    one of the concrete FieldDeclaration classes.
+    Base class of all field declarations. This class is not meant to
+    be instantiated by the user; use one of the concrete field
+    declaration subclasses instead.
     """
 
-    class IntegerBase:
-        # These values are based on the bt_ctf_integer_base enum
-        # declared in event-types.h.
-        INTEGER_BASE_UNKNOWN = -1
-        INTEGER_BASE_BINARY = 2
-        INTEGER_BASE_OCTAL = 8
-        INTEGER_BASE_DECIMAL = 10
-        INTEGER_BASE_HEXADECIMAL = 16
+    class IntegerBase(IntegerBase):
+        pass
 
     def __init__(self):
         if self._ft is None:
@@ -320,19 +361,17 @@ class FieldDeclaration:
     @property
     def alignment(self):
         """
-        Get the field declaration's alignment. Returns -1 on error.
+        Field alignment in bits (integer).
+
+        Set this attribute to change this field's alignment.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_field_type_get_alignment(self._ft)
 
     @alignment.setter
     def alignment(self, alignment):
-        """
-        Set the field declaration's alignment. Defaults to 1 (bit-aligned). However,
-        some types, such as structures and string, may impose other alignment
-        constraints.
-        """
-
         ret = nbt._bt_ctf_field_type_set_alignment(self._ft, alignment)
 
         if ret < 0:
@@ -341,18 +380,18 @@ class FieldDeclaration:
     @property
     def byte_order(self):
         """
-        Get the field declaration's byte order. One of the ByteOrder's constant.
+        Field byte order (one of :class:`babeltrace.common.ByteOrder`
+        constants).
+
+        Set this attribute to change this field's byte order.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_field_type_get_byte_order(self._ft)
 
     @byte_order.setter
     def byte_order(self, byte_order):
-        """
-        Set the field declaration's byte order. Use constants defined in the ByteOrder
-        class.
-        """
-
         ret = nbt._bt_ctf_field_type_set_byte_order(self._ft, byte_order)
 
         if ret < 0:
@@ -360,36 +399,52 @@ class FieldDeclaration:
 
 
 class IntegerFieldDeclaration(FieldDeclaration):
+    """
+    Integer field declaration.
+    """
+
     def __init__(self, size):
         """
-        Create a new integer field declaration of the given size.
+        Creates an integer field declaration of size *size* bits.
+
+        :exc:`ValueError` is raised on error.
         """
+
         self._ft = nbt._bt_ctf_field_type_integer_create(size)
         super().__init__()
 
     @property
     def size(self):
         """
-        Get an integer's size.
+        Integer size in bits (integer).
+
+        Set this attribute to change this integer's size.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_integer_get_size(self._ft)
 
         if ret < 0:
-            raise ValueError("Could not get Integer's size attribute.")
+            raise ValueError("Could not get Integer size attribute.")
         else:
             return ret
 
     @property
     def signed(self):
         """
-        Get an integer's signedness attribute.
+        ``True`` if this integer is signed.
+
+        Set this attribute to change this integer's signedness
+        (boolean).
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_integer_get_signed(self._ft)
 
         if ret < 0:
-            raise ValueError("Could not get Integer's signed attribute.")
+            raise ValueError("Could not get Integer signed attribute.")
         elif ret > 0:
             return True
         else:
@@ -397,64 +452,66 @@ class IntegerFieldDeclaration(FieldDeclaration):
 
     @signed.setter
     def signed(self, signed):
-        """
-        Set an integer's signedness attribute.
-        """
-
         ret = nbt._bt_ctf_field_type_integer_set_signed(self._ft, signed)
 
         if ret < 0:
-            raise ValueError("Could not set Integer's signed attribute.")
+            raise ValueError("Could not set Integer signed attribute.")
 
     @property
     def base(self):
         """
-        Get the integer's base used to pretty-print the resulting trace.
-        Returns a constant from the FieldDeclaration.IntegerBase class.
+        Integer display base (one of :class:`IntegerBase` constants).
+
+        Set this attribute to change this integer's display base.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_field_type_integer_get_base(self._ft)
 
     @base.setter
     def base(self, base):
-        """
-        Set the integer's base used to pretty-print the resulting trace.
-        The base must be a constant of the FieldDeclarationIntegerBase class.
-        """
-
         ret = nbt._bt_ctf_field_type_integer_set_base(self._ft, base)
 
         if ret < 0:
-            raise ValueError("Could not set Integer's base.")
+            raise ValueError("Could not set Integer base.")
 
     @property
     def encoding(self):
         """
-        Get the integer's encoding (one of the constants of the
-        CTFStringEncoding class).
-        Returns a constant from the CTFStringEncoding class.
+        Integer encoding (one of
+        :class:`babeltrace.common.CTFStringEncoding` constants).
+
+        Set this attribute to change this integer's encoding.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_field_type_integer_get_encoding(self._ft)
 
     @encoding.setter
     def encoding(self, encoding):
-        """
-        An integer encoding may be set to signal that the integer must be printed
-        as a text character. Must be a constant from the CTFStringEncoding class.
-        """
-
         ret = nbt._bt_ctf_field_type_integer_set_encoding(self._ft, encoding)
 
         if ret < 0:
-            raise ValueError("Could not set Integer's encoding.")
+            raise ValueError("Could not set Integer encoding.")
 
 
 class EnumerationFieldDeclaration(FieldDeclaration):
+    """
+    Enumeration field declaration. A CTF enumeration maps labels to
+    ranges of integers.
+    """
+
     def __init__(self, integer_type):
         """
-        Create a new enumeration field declaration with the given underlying container type.
+        Creates an enumeration field declaration, with *integer_type*
+        being the underlying :class:`IntegerFieldDeclaration` for storing
+        the integer.
+
+        :exc:`ValueError` is raised on error.
         """
+
         isinst = isinstance(integer_type, IntegerFieldDeclaration)
 
         if integer_type is None or not isinst:
@@ -466,7 +523,9 @@ class EnumerationFieldDeclaration(FieldDeclaration):
     @property
     def container(self):
         """
-        Get the enumeration's underlying container type.
+        Underlying container (:class:`IntegerFieldDeclaration`).
+
+        :exc:`TypeError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_enumeration_get_container_type(self._ft)
@@ -478,7 +537,12 @@ class EnumerationFieldDeclaration(FieldDeclaration):
 
     def add_mapping(self, name, range_start, range_end):
         """
-        Add a mapping to the enumeration. The range's values are inclusive.
+        Adds a mapping to the enumeration field declaration, from the
+        label named *name* to range [*range_start*, *range_end*], where
+        *range_start* and *range_end* are integers included in the
+        range.
+
+        :exc:`ValueError` is raised on error.
         """
 
         if range_start < 0 or range_end < 0:
@@ -498,7 +562,10 @@ class EnumerationFieldDeclaration(FieldDeclaration):
     @property
     def mappings(self):
         """
-        Generator returning instances of EnumerationMapping.
+        Generates the mappings of this enumeration field declaration
+        (:class:`EnumerationMapping` objects).
+
+        :exc:`TypeError` is raised on error.
         """
 
         signed = self.container.signed
@@ -520,7 +587,10 @@ class EnumerationFieldDeclaration(FieldDeclaration):
 
     def get_mapping_by_name(self, name):
         """
-        Get a mapping by name (EnumerationMapping).
+        Returns the :class:`EnumerationMapping` object for the label
+        named *name*.
+
+        :exc:`TypeError` is raised on error.
         """
 
         index = nbt._bt_ctf_field_type_enumeration_get_mapping_index_by_name(self._ft, name)
@@ -543,7 +613,10 @@ class EnumerationFieldDeclaration(FieldDeclaration):
 
     def get_mapping_by_value(self, value):
         """
-        Get a mapping by value (EnumerationMapping).
+        Returns the :class:`EnumerationMapping` object for the value
+        *value* (integer).
+
+        :exc:`TypeError` is raised on error.
         """
 
         if value < 0:
@@ -568,15 +641,44 @@ class EnumerationFieldDeclaration(FieldDeclaration):
         return EnumerationMapping(name, range_start, range_end)
 
 
-class FloatFieldDeclaration(FieldDeclaration):
+class FloatingPointFieldDeclaration(FieldDeclaration):
+    """
+    Floating point number field declaration.
+
+    A CTF floating point number is a made of three sections: the sign
+    bit, the exponent bits, and the mantissa bits. The most significant
+    bit of the resulting binary word is the sign bit, and is included
+    in the number of mantissa bits.
+
+    For example, the
+    `IEEE 754 <http://en.wikipedia.org/wiki/IEEE_floating_point>`_
+    single precision floating point number is represented on a 32-bit
+    word using an 8-bit exponent (``e``) and a 24-bit mantissa (``m``),
+    the latter count including the sign bit (``s``)::
+
+        s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm
+
+    The IEEE 754 double precision floating point number uses an
+    11-bit exponent and a 53-bit mantissa.
+    """
+
+    #: IEEE 754 single precision floating point number exponent size
     FLT_EXP_DIG = 8
+
+    #: IEEE 754 double precision floating point number exponent size
     DBL_EXP_DIG = 11
+
+    #: IEEE 754 single precision floating point number mantissa size
     FLT_MANT_DIG = 24
+
+    #: IEEE 754 double precision floating point number mantissa size
     DBL_MANT_DIG = 53
 
     def __init__(self):
         """
-        Create a new floating point field declaration.
+        Creates a floating point number field declaration.
+
+        :exc:`ValueError` is raised on error.
         """
 
         self._ft = nbt._bt_ctf_field_type_floating_point_create()
@@ -585,7 +687,13 @@ class FloatFieldDeclaration(FieldDeclaration):
     @property
     def exponent_digits(self):
         """
-        Get the number of exponent digits used to store the floating point field.
+        Floating point number exponent section size in bits (integer).
+
+        Set this attribute to change the floating point number's
+        exponent section's size. You may use :attr:`FLT_EXP_DIG` or
+        :attr:`DBL_EXP_DIG` for IEEE 754 floating point numbers.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_floating_point_get_exponent_digits(self._ft)
@@ -598,12 +706,6 @@ class FloatFieldDeclaration(FieldDeclaration):
 
     @exponent_digits.setter
     def exponent_digits(self, exponent_digits):
-        """
-        Set the number of exponent digits to use to store the floating point field.
-        The only values currently supported are FLT_EXP_DIG and DBL_EXP_DIG which
-        are defined as constants of this class.
-        """
-
         ret = nbt._bt_ctf_field_type_floating_point_set_exponent_digits(self._ft,
                                                                         exponent_digits)
 
@@ -613,7 +715,13 @@ class FloatFieldDeclaration(FieldDeclaration):
     @property
     def mantissa_digits(self):
         """
-        Get the number of mantissa digits used to store the floating point field.
+        Floating point number mantissa section size in bits (integer).
+
+        Set this attribute to change the floating point number's
+        mantissa section's size. You may use :attr:`FLT_MANT_DIG` or
+        :attr:`DBL_MANT_DIG` for IEEE 754 floating point numbers.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_floating_point_get_mantissa_digits(self._ft)
@@ -625,12 +733,6 @@ class FloatFieldDeclaration(FieldDeclaration):
 
     @mantissa_digits.setter
     def mantissa_digits(self, mantissa_digits):
-        """
-        Set the number of mantissa digits to use to store the floating point field.
-        The only values currently supported are FLT_MANT_DIG and DBL_MANT_DIG which
-        are defined as constants of this class.
-        """
-
         ret = nbt._bt_ctf_field_type_floating_point_set_mantissa_digits(self._ft,
                                                                         mantissa_digits)
 
@@ -638,14 +740,21 @@ class FloatFieldDeclaration(FieldDeclaration):
             raise ValueError("Could not set mantissa digit count.")
 
 
-class FloatingPointFieldDeclaration(FloatFieldDeclaration):
+class FloatFieldDeclaration(FloatingPointFieldDeclaration):
     pass
 
 
 class StructureFieldDeclaration(FieldDeclaration):
+    """
+    Structure field declaration, i.e. an ordered mapping from field
+    names to field declarations.
+    """
+
     def __init__(self):
         """
-        Create a new structure field declaration.
+        Creates an empty structure field declaration.
+
+        :exc:`ValueError` is raised on error.
         """
 
         self._ft = nbt._bt_ctf_field_type_structure_create()
@@ -653,7 +762,10 @@ class StructureFieldDeclaration(FieldDeclaration):
 
     def add_field(self, field_type, field_name):
         """
-        Add a field of type "field_type" to the structure.
+        Appends one :class:`FieldDeclaration` *field_type* named
+        *field_name* to the structure's ordered map.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_structure_add_field(self._ft,
@@ -666,7 +778,10 @@ class StructureFieldDeclaration(FieldDeclaration):
     @property
     def fields(self):
         """
-        Generator returning the structure's field as tuples of (field name, field declaration).
+        Generates the (field name, :class:`FieldDeclaration`) pairs
+        of this structure.
+
+        :exc:`TypeError` is raised on error.
         """
 
         count = nbt._bt_ctf_field_type_structure_get_field_count(self._ft)
@@ -692,7 +807,10 @@ class StructureFieldDeclaration(FieldDeclaration):
 
     def get_field_by_name(self, name):
         """
-        Get a field declaration by name (FieldDeclaration).
+        Returns the :class:`FieldDeclaration` mapped to the field name
+        *name* in this structure.
+
+        :exc:`TypeError` is raised on error.
         """
 
         field_type_native = nbt._bt_ctf_field_type_structure_get_field_type_by_name(self._ft, name)
@@ -705,9 +823,23 @@ class StructureFieldDeclaration(FieldDeclaration):
 
 
 class VariantFieldDeclaration(FieldDeclaration):
+    """
+    Variant field declaration.
+
+    A CTF variant is a dynamic selection between different fields.
+    The value of a *tag* (a CTF enumeration) determines what is the
+    current selected field. All the possible fields must be added to
+    its field declaration before using an actual variant field.
+    """
+
     def __init__(self, enum_tag, tag_name):
         """
-        Create a new variant field declaration.
+        Creates an empty variant field declaration with tag field
+        declaration *enum_tag* (instance of
+        :class:`EnumerationFieldDeclaration`) named *tag_name*
+        (string).
+
+        :exc:`ValueError` is raised on error.
         """
 
         isinst = isinstance(enum_tag, EnumerationFieldDeclaration)
@@ -721,7 +853,9 @@ class VariantFieldDeclaration(FieldDeclaration):
     @property
     def tag_name(self):
         """
-        Get the variant's tag name.
+        Variant field declaration tag name.
+
+        :exc:`TypeError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_variant_get_tag_name(self._ft)
@@ -734,7 +868,10 @@ class VariantFieldDeclaration(FieldDeclaration):
     @property
     def tag_type(self):
         """
-        Get the variant's tag type.
+        Variant field declaration tag field declaration
+        (:class:`EnumerationFieldDeclaration` object).
+
+        :exc:`TypeError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_variant_get_tag_type(self._ft)
@@ -746,7 +883,11 @@ class VariantFieldDeclaration(FieldDeclaration):
 
     def add_field(self, field_type, field_name):
         """
-        Add a field of type "field_type" to the variant.
+        Registers the :class:`FieldDeclaration` object *field_type*
+        as the variant's selected type when the variant's tag's current
+        label is *field_name*.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_variant_add_field(self._ft,
@@ -759,7 +900,10 @@ class VariantFieldDeclaration(FieldDeclaration):
     @property
     def fields(self):
         """
-        Generator returning the variant's field as tuples of (field name, field declaration).
+        Generates the (field name, :class:`FieldDeclaration`) pairs
+        of this variant field declaration.
+
+        :exc:`TypeError` is raised on error.
         """
 
         count = nbt._bt_ctf_field_type_variant_get_field_count(self._ft)
@@ -785,7 +929,10 @@ class VariantFieldDeclaration(FieldDeclaration):
 
     def get_field_by_name(self, name):
         """
-        Get a field declaration by name (FieldDeclaration).
+        Returns the :class:`FieldDeclaration` selected when the
+        variant's tag's current label is *name*.
+
+        :exc:`TypeError` is raised on error.
         """
 
         field_type_native = nbt._bt_ctf_field_type_variant_get_field_type_by_name(self._ft,
@@ -799,7 +946,10 @@ class VariantFieldDeclaration(FieldDeclaration):
 
     def get_field_from_tag(self, tag):
         """
-        Get a field declaration from tag (EnumerationField).
+        Returns the :class:`FieldDeclaration` selected by the current
+        label of the :class:`EnumerationField` *tag*.
+
+        :exc:`TypeError` is raised on error.
         """
 
         field_type_native = nbt._bt_ctf_field_type_variant_get_field_type_from_tag(self._ft, tag._f)
@@ -812,9 +962,16 @@ class VariantFieldDeclaration(FieldDeclaration):
 
 
 class ArrayFieldDeclaration(FieldDeclaration):
+    """
+    Static array field declaration.
+    """
+
     def __init__(self, element_type, length):
         """
-        Create a new array field declaration.
+        Creates a static array field declaration of *length*
+        elements of type *element_type* (:class:`FieldDeclaration`).
+
+        :exc:`ValueError` is raised on error.
         """
 
         self._ft = nbt._bt_ctf_field_type_array_create(element_type._ft,
@@ -824,7 +981,10 @@ class ArrayFieldDeclaration(FieldDeclaration):
     @property
     def element_type(self):
         """
-        Get the array's element type.
+        Type of the elements of this this static array (subclass of
+        :class:`FieldDeclaration`).
+
+        :exc:`TypeError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_array_get_element_type(self._ft)
@@ -837,7 +997,9 @@ class ArrayFieldDeclaration(FieldDeclaration):
     @property
     def length(self):
         """
-        Get the array's length.
+        Length of this static array (integer).
+
+        :exc:`TypeError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_array_get_length(self._ft)
@@ -849,9 +1011,19 @@ class ArrayFieldDeclaration(FieldDeclaration):
 
 
 class SequenceFieldDeclaration(FieldDeclaration):
+    """
+    Sequence (dynamic array) field declaration.
+    """
+
     def __init__(self, element_type, length_field_name):
         """
-        Create a new sequence field declaration.
+        Creates a sequence field declaration of
+        elements of type *element_type* (:class:`FieldDeclaration`).
+        The length of a sequence field based on this sequence field
+        declaration is obtained by retrieving the dynamic integer
+        value of the field named *length_field_name*.
+
+        :exc:`ValueError` is raised on error.
         """
 
         self._ft = nbt._bt_ctf_field_type_sequence_create(element_type._ft,
@@ -861,7 +1033,10 @@ class SequenceFieldDeclaration(FieldDeclaration):
     @property
     def element_type(self):
         """
-        Get the sequence's element type.
+        Type of the elements of this sequence (subclass of
+        :class:`FieldDeclaration`).
+
+        :exc:`TypeError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_sequence_get_element_type(self._ft)
@@ -874,7 +1049,10 @@ class SequenceFieldDeclaration(FieldDeclaration):
     @property
     def length_field_name(self):
         """
-        Get the sequence's length field name.
+        Name of the integer field defining the dynamic length of
+        sequence fields based on this sequence field declaration.
+
+        :exc:`TypeError` is raised on error.
         """
 
         ret = nbt._bt_ctf_field_type_sequence_get_length_field_name(self._ft)
@@ -886,9 +1064,15 @@ class SequenceFieldDeclaration(FieldDeclaration):
 
 
 class StringFieldDeclaration(FieldDeclaration):
+    """
+    String (NULL-terminated array of bytes) field declaration.
+    """
+
     def __init__(self):
         """
-        Create a new string field declaration.
+        Creates a string field declaration.
+
+        :exc:`ValueError` is raised on error.
         """
 
         self._ft = nbt._bt_ctf_field_type_string_create()
@@ -897,17 +1081,18 @@ class StringFieldDeclaration(FieldDeclaration):
     @property
     def encoding(self):
         """
-        Get a string declaration's encoding (a constant from the CTFStringEncoding class).
+        String encoding (one of
+        :class:`babeltrace.common.CTFStringEncoding` constants).
+
+        Set this attribute to change this string's encoding.
+
+        :exc:`ValueError` is raised on error.
         """
 
         return nbt._bt_ctf_field_type_string_get_encoding(self._ft)
 
     @encoding.setter
     def encoding(self, encoding):
-        """
-        Set a string declaration's encoding. Must be a constant from the CTFStringEncoding class.
-        """
-
         ret = nbt._bt_ctf_field_type_string_set_encoding(self._ft, encoding)
         if ret < 0:
             raise ValueError("Could not set string encoding.")
@@ -943,7 +1128,10 @@ def create_field(field_type):
 
 class Field:
     """
-    Base class, do not instantiate.
+    Base class of all fields. This class is not meant to be
+    instantiated by the user, and neither are its subclasses. Use
+    :meth:`Event.payload` to access specific, concrete fields of
+    an event.
     """
 
     def __init__(self, field_type):
@@ -984,6 +1172,12 @@ class Field:
 
     @property
     def declaration(self):
+        """
+        Field declaration (subclass of :class:`FieldDeclaration`).
+
+        :exc:`TypeError` is raised on error.
+        """
+
         native_field_type = nbt._bt_ctf_field_get_type(self._f)
 
         if native_field_type is None:
@@ -993,10 +1187,18 @@ class Field:
 
 
 class IntegerField(Field):
+    """
+    Integer field, based on an :class:`IntegerFieldDeclaration` object.
+    """
+
     @property
     def value(self):
         """
-        Get an integer field's value.
+        Integer value (:class:`int`).
+
+        Set this attribute to change the integer field's value.
+
+        :exc:`ValueError` or :exc:`TypeError` are raised on error.
         """
 
         signedness = nbt._bt_python_field_integer_get_signedness(self._f)
@@ -1016,10 +1218,6 @@ class IntegerField(Field):
 
     @value.setter
     def value(self, value):
-        """
-        Set an integer field's value.
-        """
-
         if not isinstance(value, int):
             raise TypeError("IntegerField's value must be an int")
 
@@ -1037,10 +1235,17 @@ class IntegerField(Field):
 
 
 class EnumerationField(Field):
+    """
+    Enumeration field, based on an
+    :class:`EnumerationFieldDeclaration` object.
+    """
+
     @property
     def container(self):
         """
-        Return the enumeration's underlying container field (an integer field).
+        Underlying container (:class:`IntegerField`).
+
+        :exc:`TypeError` is raised on error.
         """
 
         container = IntegerField.__new__(IntegerField)
@@ -1054,23 +1259,23 @@ class EnumerationField(Field):
     @property
     def value(self):
         """
-        Get the enumeration field's mapping name.
+        Current label of this enumeration field (:class:`str`).
+
+        Set this attribute to an integer (:class:`int`) to change the
+        enumeration field's value.
+
+        :exc:`ValueError` is raised on error.
         """
 
         value = nbt._bt_ctf_field_enumeration_get_mapping_name(self._f)
 
         if value is None:
-            raise ValueError("Could not get enumeration's mapping name.")
+            raise ValueError("Could not get enumeration mapping name.")
 
         return value
 
     @value.setter
     def value(self, value):
-        """
-        Set the enumeration field's value. Must be an integer as mapping names
-        may be ambiguous.
-        """
-
         if not isinstance(value, int):
             raise TypeError("EnumerationField value must be an int")
 
@@ -1078,10 +1283,20 @@ class EnumerationField(Field):
 
 
 class FloatingPointField(Field):
+    """
+    Floating point number field, based on a
+    :class:`FloatingPointFieldDeclaration` object.
+    """
+
     @property
     def value(self):
         """
-        Get a floating point field's value.
+        Floating point number value (:class:`float`).
+
+        Set this attribute to change the floating point number field's
+        value.
+
+        :exc:`ValueError` or :exc:`TypeError` are raised on error.
         """
 
         ret, value = nbt._bt_ctf_field_floating_point_get_value(self._f)
@@ -1093,10 +1308,6 @@ class FloatingPointField(Field):
 
     @value.setter
     def value(self, value):
-        """
-        Set a floating point field's value.
-        """
-
         if not isinstance(value, int) and not isinstance(value, float):
             raise TypeError("Value must be either a float or an int")
 
@@ -1113,9 +1324,16 @@ class FloatFieldingPoint(FloatingPointField):
 
 
 class StructureField(Field):
+    """
+    Structure field, based on a
+    :class:`StructureFieldDeclaration` object.
+    """
+
     def field(self, field_name):
         """
-        Get the structure's field corresponding to the provided field name.
+        Returns the structure :class:`Field` named *field_name*.
+
+        :exc:`ValueError` is raised on error.
         """
 
         native_instance = nbt._bt_ctf_field_structure_get_field(self._f,
@@ -1128,9 +1346,17 @@ class StructureField(Field):
 
 
 class VariantField(Field):
+    """
+    Variant field, based on a
+    :class:`VariantFieldDeclaration` object.
+    """
+
     def field(self, tag):
         """
-        Return the variant's selected field. The "tag" field is the selector enum field.
+        Returns the :class:`Field` selected by the current label of
+        *tag* (:class:`EnumerationField`).
+
+        :exc:`ValueError` is raised on error.
         """
 
         native_instance = nbt._bt_ctf_field_variant_get_field(self._f, tag._f)
@@ -1142,9 +1368,17 @@ class VariantField(Field):
 
 
 class ArrayField(Field):
+    """
+    Static array field, based on an
+    :class:`ArrayFieldDeclaration` object.
+    """
+
     def field(self, index):
         """
-        Return the array's field at position "index".
+        Returns the :class:`Field` at index *index* in this static
+        array.
+
+        :exc:`IndexError` is raised on error.
         """
 
         native_instance = nbt._bt_ctf_field_array_get_field(self._f, index)
@@ -1156,10 +1390,20 @@ class ArrayField(Field):
 
 
 class SequenceField(Field):
+    """
+    Sequence (dynamic array) field, based on a
+    :class:`SequenceFieldDeclaration` object.
+    """
+
     @property
     def length(self):
         """
-        Get the sequence's length field (IntegerField).
+        Sequence length (:class:`IntegerField`).
+
+        Set this attribute to change the sequence length's integer
+        field (integer must be unsigned).
+
+        :exc:`ValueError` or :exc:`TypeError` are raised on error.
         """
 
         native_instance = nbt._bt_ctf_field_sequence_get_length(self._f)
@@ -1171,10 +1415,6 @@ class SequenceField(Field):
 
     @length.setter
     def length(self, length_field):
-        """
-        Set the sequence's length field (IntegerField).
-        """
-
         if not isinstance(length_field, IntegerField):
             raise TypeError("Invalid length field.")
 
@@ -1188,7 +1428,9 @@ class SequenceField(Field):
 
     def field(self, index):
         """
-        Return the sequence's field at position "index".
+        Returns the :class:`Field` at index *index* in this sequence.
+
+        :exc:`ValueError` is raised on error.
         """
 
         native_instance = nbt._bt_ctf_field_sequence_get_field(self._f, index)
@@ -1200,20 +1442,24 @@ class SequenceField(Field):
 
 
 class StringField(Field):
+    """
+    String (NULL-terminated array of bytes) field.
+    """
+
     @property
     def value(self):
         """
-        Get a string field's value.
+        String value (:class:`str`).
+
+        Set this attribute to change the string's value.
+
+        :exc:`ValueError` or :exc:`TypeError` are raised on error.
         """
 
         return nbt._bt_ctf_field_string_get_value(self._f)
 
     @value.setter
     def value(self, value):
-        """
-        Set a string field's value.
-        """
-
         ret = nbt._bt_ctf_field_string_set_value(self._f, str(value))
 
         if ret < 0:
@@ -1221,9 +1467,22 @@ class StringField(Field):
 
 
 class EventClass:
+    """
+    An event class contains the properties of specific
+    events (:class:`Event`). Any concrete event must be linked with an
+    :class:`EventClass`.
+
+    Some attributes are automatically set when creating an event class.
+    For example, if no numeric ID is explicitly set using the
+    :attr:`id` attribute, a default, unique ID within the stream class
+    containing this event class will be created when needed.
+    """
+
     def __init__(self, name):
         """
-        Create a new event class of the given name.
+        Creates an event class named *name*.
+
+        :exc:`ValueError` is raised on error.
         """
 
         self._ec = nbt._bt_ctf_event_class_create(name)
@@ -1236,7 +1495,21 @@ class EventClass:
 
     def add_field(self, field_type, field_name):
         """
-        Add a field of type "field_type" to the event class.
+        Adds a field declaration *field_type* named *field_name* to
+        this event class.
+
+        *field_type* must be one of:
+
+        * :class:`IntegerFieldDeclaration`
+        * :class:`FloatingPointFieldDeclaration`
+        * :class:`EnumerationFieldDeclaration`
+        * :class:`StringFieldDeclaration`
+        * :class:`ArrayFieldDeclaration`
+        * :class:`SequenceFieldDeclaration`
+        * :class:`StructureFieldDeclaration`
+        * :class:`VariantFieldDeclaration`
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_event_class_add_field(self._ec, field_type._ft,
@@ -1248,7 +1521,7 @@ class EventClass:
     @property
     def name(self):
         """
-        Get the event class' name.
+        Event class' name.
         """
 
         name = nbt._bt_ctf_event_class_get_name(self._ec)
@@ -1261,7 +1534,13 @@ class EventClass:
     @property
     def id(self):
         """
-        Get the event class' id. Returns a negative value if unset.
+        Event class' numeric ID.
+
+        Set this attribute to assign a numeric ID to this event class.
+        This ID must be unique amongst all the event class IDs of a
+        given stream class.
+
+        :exc:`TypeError` is raised on error.
         """
 
         id = nbt._bt_ctf_event_class_get_id(self._ec)
@@ -1273,21 +1552,18 @@ class EventClass:
 
     @id.setter
     def id(self, id):
-        """
-        Set the event class' id. Throws a TypeError if the event class
-        is already registered to a stream class.
-        """
-
         ret = nbt._bt_ctf_event_class_set_id(self._ec, id)
 
         if ret < 0:
-            raise TypeError("Can't change an Event Class's id after it has been assigned to a stream class")
+            raise TypeError("Can't change an Event Class id after it has been assigned to a stream class")
 
     @property
     def stream_class(self):
         """
-        Get the event class' stream class. Returns None if unset.
+        :class:`StreamClass` object containing this event class,
+        or ``None`` if not set.
         """
+
         stream_class_native = nbt._bt_ctf_event_class_get_stream_class(self._ec)
 
         if stream_class_native is None:
@@ -1301,7 +1577,10 @@ class EventClass:
     @property
     def fields(self):
         """
-        Generator returning the event class' fields as tuples of (field name, field declaration).
+        Generates the (field name, :class:`FieldDeclaration`) pairs of
+        this event class.
+
+        :exc:`TypeError` is raised on error.
         """
 
         count = nbt._bt_ctf_event_class_get_field_count(self._ec)
@@ -1327,7 +1606,10 @@ class EventClass:
 
     def get_field_by_name(self, name):
         """
-        Get a field declaration by name (FieldDeclaration).
+        Returns the :class:`FieldDeclaration` object named *name* in
+        this event class.
+
+        :exc:`TypeError` is raised on error.
         """
 
         field_type_native = nbt._bt_ctf_event_class_get_field_by_name(self._ec, name)
@@ -1340,9 +1622,18 @@ class EventClass:
 
 
 class Event:
+    """
+    Events are specific instances of event classes
+    (:class:`EventClass`), which means they may contain actual,
+    concrete field values.
+    """
+
     def __init__(self, event_class):
         """
-        Create a new event of the given event class.
+        Creates an event linked with the :class:`EventClass`
+        *event_class*.
+
+        :exc:`ValueError` is raised on error.
         """
 
         if not isinstance(event_class, EventClass):
@@ -1359,7 +1650,7 @@ class Event:
     @property
     def event_class(self):
         """
-        Get the event's class.
+        :class:`EventClass` object to which this event is linked.
         """
 
         event_class_native = nbt._bt_ctf_event_get_class(self._e)
@@ -1374,8 +1665,8 @@ class Event:
 
     def clock(self):
         """
-        Get a clock from event. Returns None if the event's class
-        is not registered to a stream class.
+        :class:`Clock` object used by this object, or ``None`` if
+        the event class is not registered to a stream class.
         """
 
         clock_instance = nbt._bt_ctf_event_get_clock(self._e)
@@ -1390,7 +1681,24 @@ class Event:
 
     def payload(self, field_name):
         """
-        Get a field from event.
+        Returns the :class:`Field` object named *field_name* in this
+        event.
+
+        The returned field object is created using the event class'
+        field declaration named *field_name*.
+
+        The return type is one of:
+
+        * :class:`IntegerField`
+        * :class:`FloatingPointField`
+        * :class:`EnumerationField`
+        * :class:`StringField`
+        * :class:`ArrayField`
+        * :class:`SequenceField`
+        * :class:`StructureField`
+        * :class:`VariantField`
+
+        :exc:`TypeError` is raised on error.
         """
 
         native_instance = nbt._bt_ctf_event_get_payload(self._e,
@@ -1403,7 +1711,21 @@ class Event:
 
     def set_payload(self, field_name, value_field):
         """
-        Set a manually created field as an event's payload.
+        Set the event's field named *field_name* to the manually
+        created :class:`Field` object *value_field*.
+
+        *value_field*'s type must be one of:
+
+        * :class:`IntegerField`
+        * :class:`FloatingPointField`
+        * :class:`EnumerationField`
+        * :class:`StringField`
+        * :class:`ArrayField`
+        * :class:`SequenceField`
+        * :class:`StructureField`
+        * :class:`VariantField`
+
+        :exc:`ValueError` is raised on error.
         """
 
         if not isinstance(value, Field):
@@ -1417,9 +1739,23 @@ class Event:
 
 
 class StreamClass:
+    """
+    A stream class contains the properties of specific
+    streams (:class:`Stream`). Any concrete stream must be linked with
+    a :class:`StreamClass`, usually by calling
+    :meth:`Writer.create_stream`.
+
+    Some attributes are automatically set when creating a stream class.
+    For example, if no clock is explicitly set using the
+    :attr:`clock` attribute, a default clock will be created
+    when needed.
+    """
+
     def __init__(self, name):
         """
-        Create a new stream class of the given name.
+        Creates a stream class named *name*.
+
+        :exc:`ValueError` is raised on error.
         """
 
         self._sc = nbt._bt_ctf_stream_class_create(name)
@@ -1433,7 +1769,9 @@ class StreamClass:
     @property
     def name(self):
         """
-        Get a stream class' name.
+        Stream class' name.
+
+        :exc:`TypeError` is raised on error.
         """
 
         name = nbt._bt_ctf_stream_class_get_name(self._sc)
@@ -1446,7 +1784,11 @@ class StreamClass:
     @property
     def clock(self):
         """
-        Get a stream class' clock.
+        Stream class' clock (:class:`Clock` object).
+
+        Set this attribute to change the clock of this stream class.
+
+        :exc:`ValueError` is raised on error.
         """
 
         clock_instance = nbt._bt_ctf_stream_class_get_clock(self._sc)
@@ -1461,10 +1803,6 @@ class StreamClass:
 
     @clock.setter
     def clock(self, clock):
-        """
-        Assign a clock to a stream class.
-        """
-
         if not isinstance(clock, Clock):
             raise TypeError("Invalid clock type.")
 
@@ -1476,7 +1814,11 @@ class StreamClass:
     @property
     def id(self):
         """
-        Get a stream class' id.
+        Stream class' numeric ID.
+
+        Set this attribute to change the ID of this stream class.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_stream_class_get_id(self._sc)
@@ -1488,10 +1830,6 @@ class StreamClass:
 
     @id.setter
     def id(self, id):
-        """
-        Assign an id to a stream class.
-        """
-
         ret = nbt._bt_ctf_stream_class_set_id(self._sc, id)
 
         if ret < 0:
@@ -1500,7 +1838,10 @@ class StreamClass:
     @property
     def event_classes(self):
         """
-        Generator returning the stream class' event classes.
+        Generates the event classes (:class:`EventClass` objects) of
+        this stream class.
+
+        :exc:`TypeError` is raised on error.
         """
 
         count = nbt._bt_ctf_stream_class_get_event_class_count(self._sc)
@@ -1521,10 +1862,13 @@ class StreamClass:
 
     def add_event_class(self, event_class):
         """
-        Add an event class to a stream class. New events can be added even after a
-        stream has been instantiated and events have been appended. However, a stream
-        will not accept events of a class that has not been added to the stream
-        class beforehand.
+        Registers the :class:`EventClass` *event_class* to this stream
+        class.
+
+        Once the event class is registered, it will be generated as one
+        of the event classes generated by :attr:`event_classes`.
+
+        :exc:`ValueError` is raised on error.
         """
 
         if not isinstance(event_class, EventClass):
@@ -1539,7 +1883,14 @@ class StreamClass:
     @property
     def packet_context_type(self):
         """
-        Get the StreamClass' packet context type (StructureFieldDeclaration)
+        Stream packet context declaration.
+
+        Set this attribute to change the stream packet context
+        declaration (must be an instance of
+        :class:`StructureFieldDeclaration`).
+
+        :exc:`ValueError` is raised on error.
+
         """
 
         field_type_native = nbt._bt_ctf_stream_class_get_packet_context_type(self._sc)
@@ -1553,11 +1904,6 @@ class StreamClass:
 
     @packet_context_type.setter
     def packet_context_type(self, field_type):
-        """
-        Set a StreamClass' packet context type. Must be of type
-        StructureFieldDeclaration.
-        """
-
         if not isinstance(field_type, StructureFieldDeclaration):
             raise TypeError("field_type argument must be of type StructureFieldDeclaration.")
 
@@ -1569,6 +1915,24 @@ class StreamClass:
 
 
 class Stream:
+    """
+    Streams are specific instances of stream classes, which means they
+    may contain actual, concrete events.
+
+    :class:`Stream` objects are returned by
+    :meth:`Writer.create_stream`; they are not meant to be
+    instantiated by the user.
+
+    Concrete :class:`Event` objects are appended to
+    :class:`Stream` objects using :meth:`append_event`.
+
+    When :meth:`flush` is called, a CTF packet is created, containing
+    all the appended events since the last flush. Although the stream
+    is flushed on object destruction, it is **strongly recommended**
+    that the user call :meth:`flush` manually before exiting the
+    script, as :meth:`__del__` is not always reliable.
+    """
+
     def __init__(self):
         raise NotImplementedError("Stream cannot be instantiated; use Writer.create_stream()")
 
@@ -1578,28 +1942,34 @@ class Stream:
     @property
     def discarded_events(self):
         """
-        Get a stream's discarded event count.
+        Number of discarded (lost) events in this stream so far.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret, count = nbt._bt_ctf_stream_get_discarded_events_count(self._s)
 
         if ret < 0:
-            raise ValueError("Could not get the stream's discarded events count")
+            raise ValueError("Could not get the stream discarded events count")
 
         return count
 
     def append_discarded_events(self, event_count):
         """
-        Increase the current packet's discarded event count.
+        Appends *event_count* discarded events to this stream.
         """
 
         nbt._bt_ctf_stream_append_discarded_events(self._s, event_count)
 
     def append_event(self, event):
         """
-        Append "event" to the stream's current packet. The stream's associated clock
-        will be sampled during this call. The event shall not be modified after
-        being appended to a stream.
+        Appends event *event* (:class:`Event` object) to this stream.
+
+        The stream's associated clock will be sampled during this call.
+        *event* **shall not** be modified after being appended to this
+        stream.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_stream_append_event(self._s, event._e)
@@ -1610,7 +1980,13 @@ class Stream:
     @property
     def packet_context(self):
         """
-        Get a Stream's packet context field (a StructureField).
+        Stream packet context field (instance of
+        :class:`StructureField`).
+
+        Set this attribute to assign a stream packet context field
+        to this stream.
+
+        :exc:`ValueError` is raised on error.
         """
 
         native_field = nbt._bt_ctf_stream_get_packet_context(self._s)
@@ -1622,10 +1998,6 @@ class Stream:
 
     @packet_context.setter
     def packet_context(self, field):
-        """
-        Set a Stream's packet context field (must be a StructureField).
-        """
-
         if not isinstance(field, StructureField):
             raise TypeError("Argument field must be of type StructureField")
 
@@ -1636,8 +2008,11 @@ class Stream:
 
     def flush(self):
         """
-        The stream's current packet's events will be flushed to disk. Events
-        subsequently appended to the stream will be added to a new packet.
+        Flushes the current packet of this stream to disk. Events
+        subsequently appended to the stream will be added to a new
+        packet.
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_stream_flush(self._s)
@@ -1647,9 +2022,20 @@ class Stream:
 
 
 class Writer:
+    """
+    This object is the CTF writer API context. It oversees its streams
+    and clocks, and is responsible for writing one CTF trace.
+    """
+
     def __init__(self, path):
         """
-        Create a new writer that will produce a trace in the given path.
+        Creates a CTF writer, initializing a new CTF trace at path
+        *path*.
+
+        *path* must be an existing directory, since a CTF trace is
+        made of multiple files.
+
+        :exc:`ValueError` is raised if the creation fails.
         """
 
         self._w = nbt._bt_ctf_writer_create(path)
@@ -1662,7 +2048,13 @@ class Writer:
 
     def create_stream(self, stream_class):
         """
-        Create a new stream instance and register it to the writer.
+        Creates and registers a new stream based on stream class
+        *stream_class*.
+
+        This is the standard way of creating a :class:`Stream` object:
+        the user is not allowed to instantiate this class.
+
+        Returns a new :class:`Stream` object.
         """
 
         if not isinstance(stream_class, StreamClass):
@@ -1675,7 +2067,10 @@ class Writer:
 
     def add_environment_field(self, name, value):
         """
-        Add an environment field to the trace.
+        Sets the CTF environment variable named *name* to value *value*
+        (converted to a string).
+
+        :exc:`ValueError` is raised on error.
         """
 
         ret = nbt._bt_ctf_writer_add_environment_field(self._w, str(name),
@@ -1686,8 +2081,12 @@ class Writer:
 
     def add_clock(self, clock):
         """
-        Add a clock to the trace. Clocks assigned to stream classes must be
-        registered to the writer.
+        Registers :class:`Clock` object *clock* to the writer.
+
+        You *must* register CTF clocks assigned to stream classes
+        to the writer.
+
+        :exc:`ValueError` is raised if the creation fails.
         """
 
         ret = nbt._bt_ctf_writer_add_clock(self._w, clock._c)
@@ -1698,14 +2097,14 @@ class Writer:
     @property
     def metadata(self):
         """
-        Get the trace's TSDL meta-data.
+        Current metadata of this trace (:class:`str`).
         """
 
         return nbt._bt_ctf_writer_get_metadata_string(self._w)
 
     def flush_metadata(self):
         """
-        Flush the trace's metadata to the metadata file.
+        Flushes the trace's metadata to the metadata file.
         """
 
         nbt._bt_ctf_writer_flush_metadata(self._w)
@@ -1713,20 +2112,26 @@ class Writer:
     @property
     def byte_order(self):
         """
-        Get the trace's byte order. Must be a constant from the ByteOrder
-        class.
+        Native byte order of this trace (one of
+        :class:`babeltrace.common.ByteOrder` constants).
+
+        This is the actual byte order that is used when a field
+        declaration has the
+        :attr:`babeltrace.common.ByteOrder.BYTE_ORDER_NATIVE`
+        value.
+
+        Set this attribute to change the trace's native byte order.
+
+        Defaults to the host machine's endianness.
+
+        :exc:`ValueError` is raised on error.
         """
 
         raise NotImplementedError("Getter not implemented.")
 
     @byte_order.setter
     def byte_order(self, byte_order):
-        """
-        Set the trace's byte order. Must be a constant from the ByteOrder
-        class. Defaults to the host machine's endianness
-        """
-
         ret = nbt._bt_ctf_writer_set_byte_order(self._w, byte_order)
 
         if ret < 0:
-            raise ValueError("Could not set trace's byte order.")
+            raise ValueError("Could not set trace byte order.")
This page took 0.043364 seconds and 4 git commands to generate.