Skip to content

Commit

Permalink
docs: Update to use module diretive
Browse files Browse the repository at this point in the history
Update the documentation to indicated which module each class is located
without affecting the naming conventions.
This allows the documentation to be referenced from other modules as
well as enabling links to the source code directly from the
documentation.
  • Loading branch information
marcbonnici committed Nov 18, 2019
1 parent 2650a53 commit 42f7b91
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 58 deletions.
22 changes: 17 additions & 5 deletions doc/connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ Connection

A :class:`Connection` abstracts an actual physical connection to a device. The
first connection is created when :func:`Target.connect` method is called. If a
:class:`Target` is used in a multi-threaded environment, it will maintain a
:class:`Target <devlib.Target>` is used in a multi-threaded environment, it will maintain a
connection for each thread in which it is invoked. This allows the same target
object to be used in parallel in multiple threads.

:class:`Connection`\ s will be automatically created and managed by
:class:`Target`\ s, so there is usually no reason to create one manually.
:class:`Target <devlib.Target>`\ s, so there is usually no reason to create one manually.
Instead, configuration for a :class:`Connection` is passed as
`connection_settings` parameter when creating a :class:`Target`. The connection
`connection_settings` parameter when creating a :class:`Target <devlib.Target>`. The connection
to be used target is also specified on instantiation by `conn_cls` parameter,
though all concrete :class:`Target` implementations will set an appropriate
though all concrete :class:`Target <devlib.Target>` implementations will set an appropriate
default, so there is typically no need to specify this explicitly.

:class:`Connection` classes are not a part of an inheritance hierarchy, i.e.
Expand Down Expand Up @@ -76,7 +76,7 @@ class that implements the following methods.

.. note:: This **will block the connection** until the command completes.

.. note:: The above methods are directly wrapped by :class:`Target` methods,
.. note:: The above methods are directly wrapped by :class:`Target <devlib.Target>` methods,
however note that some of the defaults are different.

.. method:: cancel_running_command(self)
Expand All @@ -95,11 +95,18 @@ class that implements the following methods.
opened on instantiation.



.. _connection-types:

Connection Types
----------------


.. module:: devlib.utils.android

.. module:: devlib
:noindex:

.. class:: AdbConnection(device=None, timeout=None, adb_server=None, adb_as_root=False)

A connection to an android device via ``adb`` (Android Debug Bridge).
Expand All @@ -116,6 +123,7 @@ Connection Types
:param adb_server: Allows specifying the address of the adb server to use.
:param adb_as_root: Specify whether the adb server should be restarted in root mode.

.. module:: devlib.utils.ssh

.. class:: SshConnection(host, username, password=None, keyfile=None, port=None,\
timeout=None, password_prompt=None, \
Expand Down Expand Up @@ -178,6 +186,7 @@ Connection Types
connection to reduce the possibility of clashes).
This parameter is ignored for SSH connections.

.. module:: devlib.host

.. class:: LocalConnection(keep_password=True, unrooted=False, password=None)

Expand All @@ -193,6 +202,9 @@ Connection Types
prompting for it.


.. module:: devlib.utils.ssh
:noindex:

.. class:: Gem5Connection(platform, host=None, username=None, password=None,\
timeout=None, password_prompt=None,\
original_prompt=None)
Expand Down
15 changes: 15 additions & 0 deletions doc/derived_measurements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ API
Derived Measurements
~~~~~~~~~~~~~~~~~~~~

.. module:: devlib.derived

.. module:: devlib
:noindex:

.. class:: DerivedMeasurements

The ``DerivedMeasurements`` class provides an API for post-processing
Expand Down Expand Up @@ -102,6 +107,11 @@ Available Derived Measurements
Energy
~~~~~~

.. module:: devlib.derived.energy

.. module:: devlib
:noindex:

.. class:: DerivedEnergyMeasurements

The ``DerivedEnergyMeasurements`` class is used to calculate average power and
Expand All @@ -128,6 +138,11 @@ Energy
FPS / Rendering
~~~~~~~~~~~~~~~

.. module:: devlib.derived.fps

.. module:: devlib
:noindex:

.. class:: DerivedGfxInfoStats(drop_threshold=5, suffix='-fps', filename=None, outdir=None)

Produces FPS (frames-per-second) and other derived statistics from
Expand Down
26 changes: 19 additions & 7 deletions doc/instrumentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Instrumentation

The ``Instrument`` API provide a consistent way of collecting measurements from
a target. Measurements are collected via an instance of a class derived from
:class:`Instrument`. An ``Instrument`` allows collection of measurement from one
:class:`Instrument <devlib.Instrument>`. An ``Instrument`` allows collection of measurement from one
or more channels. An ``Instrument`` may support ``INSTANTANEOUS`` or
``CONTINUOUS`` collection, or both.

Expand Down Expand Up @@ -48,6 +48,12 @@ Android target.
API
---

.. module:: devlib.target.instrument

.. module:: devlib
:noindex:


Instrument
~~~~~~~~~~

Expand Down Expand Up @@ -120,22 +126,22 @@ Instrument
Take a single measurement from ``active_channels``. Returns a list of
:class:`Measurement` objects (one for each active channel).

.. note:: This method is only implemented by :class:`Instrument`\ s that
.. note:: This method is only implemented by :class:`Instrument <devlib.Instrument>`\ s that
support ``INSTANTANEOUS`` measurement.

.. method:: Instrument.start()

Starts collecting measurements from ``active_channels``.

.. note:: This method is only implemented by :class:`Instrument`\ s that
.. note:: This method is only implemented by :class:`Instrument <devlib.Instrument>`\ s that
support ``CONTINUOUS`` measurement.

.. method:: Instrument.stop()

Stops collecting measurements from ``active_channels``. Must be called after
:func:`start()`.

.. note:: This method is only implemented by :class:`Instrument`\ s that
.. note:: This method is only implemented by :class:`Instrument <devlib.Instrument>`\ s that
support ``CONTINUOUS`` measurement.

.. method:: Instrument.get_data(outfile)
Expand All @@ -158,7 +164,7 @@ Instrument
that can be used to stream :class:`Measurement`\ s lists (similar to what is
returned by ``take_measurement()``.

.. note:: This method is only implemented by :class:`Instrument`\ s that
.. note:: This method is only implemented by :class:`Instrument <devlib.Instrument>`\ s that
support ``CONTINUOUS`` measurement.

.. method:: Instrument.get_raw()
Expand All @@ -183,7 +189,7 @@ Instrument

Sample rate of the instrument in Hz. Assumed to be the same for all channels.

.. note:: This attribute is only provided by :class:`Instrument`\ s that
.. note:: This attribute is only provided by :class:`Instrument <devlib.Instrument>`\ s that
support ``CONTINUOUS`` measurement.

Instrument Channel
Expand All @@ -192,7 +198,7 @@ Instrument Channel
.. class:: InstrumentChannel(name, site, measurement_type, \*\*attrs)

An :class:`InstrumentChannel` describes a single type of measurement that may
be collected by an :class:`Instrument`. A channel is primarily defined by a
be collected by an :class:`Instrument <devlib.Instrument>`. A channel is primarily defined by a
``site`` and a ``measurement_type``.

A ``site`` indicates where on the target a measurement is collected from
Expand Down Expand Up @@ -622,6 +628,12 @@ given by `libiio (the Linux IIO interface)`_ however only the network-based one
has been tested. For the other classes, please refer to the official IIO
documentation for the meaning of their constructor parameters.

.. module:: devlib.target.baylibre_acme

.. module:: devlib
:noindex:


.. class:: BaylibreAcmeInstrument(target=None, iio_context=None, use_base_iio_context=False, probe_names=None)

Base class wrapper for the ACME instrument which itself is a wrapper for the
Expand Down
26 changes: 19 additions & 7 deletions doc/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
Modules
=======

Modules add additional functionality to the core :class:`Target` interface.
.. module:: devlib.module
.. module:: devlib.module.hotplug

Modules add additional functionality to the core :class:`Target <devlib.Target>` interface.
Usually, it is support for specific subsystems on the target. Modules are
instantiated as attributes of the :class:`Target` instance.
instantiated as attributes of the :class:`Target <devlib.Target>` instance.

hotplug
-------
Expand All @@ -28,6 +31,8 @@ interface to this subsystem
# Make sure all cpus are online
target.hotplug.online_all()
.. module:: devlib.module.cpufreq

cpufreq
-------

Expand Down Expand Up @@ -132,6 +137,9 @@ policies (governors). The ``devlib`` module exposes the following interface
``1`` or ``"cpu1"``).
:param frequency: Frequency to set.


.. module:: devlib.module.cpuidle

cpuidle
-------

Expand Down Expand Up @@ -167,11 +175,15 @@ cpuidle
You can also call ``enable()`` or ``disable()`` on :class:`CpuidleState` objects
returned by get_state(s).

.. module:: devlib.module.cgroups

cgroups
-------

TODO

.. module:: devlib.module.hwmon

hwmon
-----

Expand Down Expand Up @@ -204,12 +216,12 @@ define the following class attributes:
which case the module's ``name`` will be treated as its
``kind`` as well.

:stage: This defines when the module will be installed into a :class:`Target`.
:stage: This defines when the module will be installed into a :class:`Target <devlib.Target>`.
Currently, the following values are allowed:

:connected: The module is installed after a connection to the target has
been established. This is the default.
:early: The module will be installed when a :class:`Target` is first
:early: The module will be installed when a :class:`Target <devlib.Target>` is first
created. This should be used for modules that do not rely on a
live connection to the target.
:setup: The module will be installed after initial setup of the device
Expand All @@ -220,7 +232,7 @@ Additionally, a module must implement a static (or class) method :func:`probe`:

.. method:: Module.probe(target)

This method takes a :class:`Target` instance and returns ``True`` if this
This method takes a :class:`Target <devlib.Target>` instance and returns ``True`` if this
module is supported by that target, or ``False`` otherwise.

.. note:: If the module ``stage`` is ``"early"``, this method cannot assume
Expand All @@ -231,7 +243,7 @@ Installation and invocation
***************************

The default installation method will create an instance of a module (the
:class:`Target` instance being the sole argument) and assign it to the target
:class:`Target <devlib.Target>` instance being the sole argument) and assign it to the target
instance attribute named after the module's ``kind`` (or ``name`` if ``kind`` is
``None``).

Expand Down Expand Up @@ -343,7 +355,7 @@ FlashModule
Module Registration
~~~~~~~~~~~~~~~~~~~

Modules are specified on :class:`Target` or :class:`Platform` creation by name.
Modules are specified on :class:`Target <devlib.Target>` or :class:`Platform` creation by name.
In order to find the class associated with the name, the module needs to be
registered with ``devlib``. This is accomplished by passing the module class
into :func:`register_module` method once it is defined.
Expand Down

0 comments on commit 42f7b91

Please sign in to comment.