Skip to content

Commit

Permalink
lisa: Include some private functions in documentation
Browse files Browse the repository at this point in the history
Use :meta public: info field to include some private functions in the
documentation.

https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html

Command used:
    perl -0pi -e 's/(def _[^_].*:\n *"""\n( *))/\1:meta public:\n\n\2/g' lisa/**.py
  • Loading branch information
DouglasRaillard committed Feb 24, 2021
1 parent 39e7be3 commit d1a9f60
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 12 deletions.
2 changes: 0 additions & 2 deletions doc/energy_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,9 @@ Energy model

.. automodule:: lisa.energy_model
:members:
:private-members: _CpuTree

Energy meters
+++++++++++++

.. automodule:: lisa.energy_meter
:members:
:private-members: _DevlibContinuousEnergyMeter
2 changes: 0 additions & 2 deletions doc/kernel_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ Base classes

.. automodule:: lisa.tests.base
:members:
:private-members: _from_target

.. TODO:: Make those imports more generic

Expand Down Expand Up @@ -224,7 +223,6 @@ Load tracking tests
.. automodule:: lisa.tests.scheduler.load_tracking
:members:
:private-members: _from_target

|
Expand Down
6 changes: 5 additions & 1 deletion lisa/energy_meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ def report(self, out_dir, out_file='energy.json'):


class _DevlibContinuousEnergyMeter(EnergyMeter):
"""Common functionality for devlib Instruments in CONTINUOUS mode"""
"""
:meta public:
Common functionality for devlib Instruments in CONTINUOUS mode
"""

def reset(self):
self._instrument.start()
Expand Down
5 changes: 4 additions & 1 deletion lisa/energy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def __new__(cls, capacity=None, power=None):


class _CpuTree(Loggable):
"""Internal class. Abstract representation of a CPU topology.
"""
:meta public:
Internal class. Abstract representation of a CPU topology.
Each node contains either a single CPU or a set of child nodes.
Expand Down
4 changes: 4 additions & 0 deletions lisa/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def __init__(self, res_dir, plat_info, shell_output):
@classmethod
def _from_target(cls, target: Target, *, res_dir: ArtifactPath, ftrace_coll: FtraceCollector = None) -> 'ExampleTestBundle':
"""
:meta public:
This class method is the main way of creating a :class:`ExampleTestBundle`.
It takes a first (positional) ``target`` parameter, which is a live
Expand Down Expand Up @@ -133,6 +135,8 @@ def _from_target(cls, target: Target, *, res_dir: ArtifactPath, ftrace_coll: Ftr
@classmethod
def _get_rtapp_profile(cls, plat_info):
"""
:meta public:
This class method is in charge of generating an rt-app profile, to
configure the workload that will be run using
:meth:`lisa.tests.base.RTATestBundle.run_rtapp`.
Expand Down
15 changes: 12 additions & 3 deletions lisa/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ def get_tags(self):
@abc.abstractmethod
def _from_target(cls, target, *, res_dir):
"""
:meta public:
Internals of the target factory method.
.. note:: This must be a classmethod, and all parameters except
Expand Down Expand Up @@ -943,6 +945,8 @@ def from_target(cls, target: Target, *, res_dir: ArtifactPath = None, **kwargs):
@classmethod
def _get_filepath(cls, res_dir):
"""
:meta public:
Returns the path of the file containing the serialized object in
``res_dir`` folder.
"""
Expand Down Expand Up @@ -977,6 +981,8 @@ def update_refs(obj):
@property
def _children_test_bundles(self):
"""
:meta public:
List of references to :class:`TestBundle` instances ``self`` relies on
(directly *and* indirectly).
Expand Down Expand Up @@ -1009,9 +1015,6 @@ def from_dir(cls, res_dir, update_res_dir=True):
It uses :meth:`_get_filepath` to get the name of the serialized file to
reload.
.. automethod:: _get_filepath
"""
res_dir = ArtifactPath(root=res_dir, relative='')

Expand Down Expand Up @@ -1643,6 +1646,8 @@ def add_buffer(task):
@abc.abstractmethod
def _get_rtapp_profile(cls, plat_info):
"""
:meta public:
:returns: a :class:`dict` with task names as keys and
:class:`lisa.wlgen.rta.RTATask` as values
Expand Down Expand Up @@ -1795,13 +1800,17 @@ def run_rtapp(cls, target, res_dir, profile=None, ftrace_coll=None, cg_cfg=None,
@classmethod
def _run_rtapp(cls, *args, **kwargs):
"""
:meta public:
Has been renamed to :meth:`~lisa.tests.base.RTATestBundle.run_rtapp`, as it really is part of the public API.
"""
return cls.run_rtapp(*args, **kwargs)

@classmethod
def _from_target(cls, target: Target, *, res_dir: ArtifactPath, ftrace_coll: FtraceCollector = None) -> 'RTATestBundle':
"""
:meta public:
Factory method to create a bundle using a live target
This will execute the rt-app workload described in
Expand Down
2 changes: 2 additions & 0 deletions lisa/tests/cpufreq/sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def __init__(self, res_dir, plat_info, cpu, freq, work):
@classmethod
def _from_target(cls, target: Target, *, res_dir: ArtifactPath, cpu, freq, switch_governor=True) -> 'UserspaceSanityItem':
"""
:meta public:
Create a :class:`UserspaceSanityItem` from a live :class:`lisa.target.Target`.
:param cpu: CPU to run on.
Expand Down
2 changes: 2 additions & 0 deletions lisa/tests/scheduler/eas_behaviour.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def check_from_target(cls, target):
@classmethod
def _from_target(cls, target: Target, *, res_dir: ArtifactPath = None, ftrace_coll: FtraceCollector = None) -> 'EASBehaviour':
"""
:meta public:
Factory method to create a bundle using a live target
This will execute the rt-app workload described in
Expand Down
8 changes: 6 additions & 2 deletions lisa/tests/scheduler/load_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class LoadTrackingHelpers:
@classmethod
def _get_blacklisted_cpus(cls, plat_info):
"""
:meta public:
Consider some CPUs as blacklisted when the load would not be
proportionnal to utilization on them.
Expand Down Expand Up @@ -86,8 +88,6 @@ def filter_capacity_classes(cls, plat_info):
"""
Filter out capacity-classes key of ``plat_info`` to remove blacklisted
CPUs provided by:
.. automethod:: _get_blacklisted_cpus
"""
blacklisted_cpus = set(cls._get_blacklisted_cpus(plat_info))
return [
Expand Down Expand Up @@ -216,6 +216,8 @@ def get_tags(self):
@classmethod
def _get_rtapp_profile(cls, plat_info, cpu, freq):
"""
:meta public:
Get a specification for a rt-app workload with the specificied duty
cycle, pinned to the given CPU.
"""
Expand All @@ -239,6 +241,8 @@ def _get_rtapp_profile(cls, plat_info, cpu, freq):
@classmethod
def _from_target(cls, target: Target, *, cpu: int, freq: int, freq_list=None, res_dir: ArtifactPath = None, ftrace_coll: FtraceCollector = None) -> 'InvarianceItem':
"""
:meta public:
:param cpu: CPU to use, or ``None`` to automatically choose an
appropriate set of CPUs.
:type cpu: int or None
Expand Down
2 changes: 2 additions & 0 deletions lisa/tests/scheduler/sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def __init__(self, res_dir, plat_info, capacity_work):
@classmethod
def _from_target(cls, target: Target, *, res_dir: ArtifactPath = None) -> 'CapacitySanity':
"""
:meta public:
Factory method to create a bundle using a live target
"""
with target.cpufreq.use_governor("performance"):
Expand Down
2 changes: 1 addition & 1 deletion lisa/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ class TxtTraceParserBase(TraceParserBase):
Mapping of event names to parser description as a dict.
Each event description can include the constructor parameters of the class
used as :data:`DEFAULT_EVENT_PARSER_CLS`, which will be used to build event
used as :attr:`DEFAULT_EVENT_PARSER_CLS`, which will be used to build event
parsers from the descriptions.
If an instance of :class:`EventParserBase` is passed instead of a dict, it
Expand Down
10 changes: 10 additions & 0 deletions lisa/wlgen/rta.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,8 @@ def val(self):
@classmethod
def _from_key(cls, key, val):
"""
:meta public:
Build an instance out of ``key`` and ``val``.
"""
raise NotImplementedError()
Expand Down Expand Up @@ -1565,6 +1567,8 @@ class _SemigroupProperty(PropertyBase):
@abc.abstractmethod
def _SEMIGROUP_OP(x, y):
"""
:meta public:
Function used to combine two non-None values.
"""
pass
Expand Down Expand Up @@ -2112,6 +2116,8 @@ def __and__(self, other):

def _and(self, other):
"""
:meta public:
Combine together two instances by taking the non-default values for
each attribute, and giving priority to ``self``.
"""
Expand Down Expand Up @@ -2186,6 +2192,8 @@ def _from_key(cls, key, val):

def _and(self, other):
"""
:meta public:
Combine clamps by taking the most constraining solution.
"""
def none_shortcircuit(f, x, y):
Expand Down Expand Up @@ -3303,6 +3311,8 @@ def __init__(self, template=None, properties=None, **kwargs):
@abc.abstractmethod
def _make_children(cls, template, **kwargs):
"""
:meta public:
Create a list of children :class:`RTAPhaseBase` based on the parameters
passed from the constructor.
"""
Expand Down

0 comments on commit d1a9f60

Please sign in to comment.