mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-07-15 03:23:47 +01:00
Initial commit of open source Workload Automation.
This commit is contained in:
.gitignoreLICENSEMANIFEST.inREADME.rst
dev_scripts
doc
Makefilebuild_extension_docs.pybuild_instrumentation_method_map.py
source
_static
_templates
additional_topics.rstagenda.rstchanges.rstconf.pyconfiguration.rstcontributing.rstconventions.rstdaq_device_setup.rstdevice_setup.rstexecution_model.rstindex.rstinstallation.rstinstrumentation_method_map.rstinstrumentation_method_map.templateinvocation.rstquickstart.rstresources.rstrevent.rstwa-execution.pngwriting_extensions.rstextras
scripts
setup.pywlauto
__init__.pyagenda-example-biglittle.yamlagenda-example-tutorial.yaml
commands
common
config_example.pycore
__init__.pyagenda.pybootstrap.pycommand.pyconfiguration.pydevice.pyentry_point.pyexecution.pyextension.pyextension_loader.pyexttype.pyinstrumentation.pyresolver.pyresource.pyresult.pysignal.pyversion.pyworkload.py
devices
exceptions.pyexternal
README
bbench_server
daq_server
louie
LICENSE__init__.pydispatcher.pyerror.pyplugin.pyprioritylist.pyrobustapply.pysaferef.pysender.pysignal.py
test
__init__.pyconftest.pyfixture.pytest_dispatcher.pytest_plugin.pytest_prioritydispatcher.pytest_prioritylist.pytest_robustapply.pytest_saferef.py
version.pypmu_logger
readenergy
revent
terminalsize.pyuiauto
instrumentation
__init__.py
coreutil
daq
delay
dmesg
energy_probe
fps
hwmon
juno_energy
misc
perf
pmu_logger
streamline
trace_cmd
modules
resource_getters
result_processors
tests
README__init__.py
data
test_agenda.pytest_config.pytest_device.pytest_diff.pytest_execution.pytest_extension.pytest_extension_loader.pytest_instrumentation.pytest_results_manager.pytest_utils.pytools
utils
__init__.pyandroid.pycli.pycpuinfo.pydoc.pyformatter.pyhwmon.pylog.pymisc.pynetio.pyserial_port.pyssh.pytypes.pyuefi.py
workloads
__init__.py
andebench
angrybirds
angrybirds_rio
anomaly2
antutu
applaunch
audio
bbench
benchmarkpi
caffeinemark
cameracapture
camerarecord
castlebuilder
castlemaster
cfbench
citadel
cyclictest
dex2oat
dhrystone
dungeondefenders
facebook
geekbench
glbcorp
glbenchmark
gunbros2
homescreen
idle
ironman
krazykart
linpack
manual
memcpy
nenamark
peacekeeper
quadrant
real_linpack
realracing3
shellscript
skypevideo
smartbench
spec2000
sqlite
sysbench
templerun
thechase
truckerparking3d
vellamo
video
videostreaming
134
wlauto/tools/extdoc.py
Normal file
134
wlauto/tools/extdoc.py
Normal file
@ -0,0 +1,134 @@
|
||||
# Copyright 2014-2015 ARM Limited
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
"""
|
||||
This module contains utilities for generating user documentation for Workload
|
||||
Automation Extensions.
|
||||
|
||||
"""
|
||||
import re
|
||||
import inspect
|
||||
|
||||
|
||||
PARAGRAPH_SEP = re.compile(r'\n\n+')
|
||||
LINE_START = re.compile(r'\n\s*')
|
||||
|
||||
|
||||
def get_paragraphs(text):
|
||||
"""returns a list of paragraphs contained in the text"""
|
||||
return [LINE_START.sub(' ', p) for p in PARAGRAPH_SEP.split(text)]
|
||||
|
||||
|
||||
class ExtensionDocumenter(object):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.ext.name
|
||||
|
||||
@property
|
||||
def summary(self):
|
||||
"""Returns the summary description for this Extension, which, by
|
||||
convention, is the first paragraph of the description."""
|
||||
return get_paragraphs(self.description)[0]
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
"""
|
||||
The description for an extension is specified in the ``description``
|
||||
attribute, or (legacy) as a docstring for the extension's class. If
|
||||
neither method is used in the Extension, an empty string is returned.
|
||||
|
||||
Description is assumed to be formed as reStructuredText. Leading and
|
||||
trailing whitespace will be stripped away.
|
||||
|
||||
"""
|
||||
if hasattr(self.ext, 'description'):
|
||||
return self.ext.description.strip()
|
||||
elif self.ext.__class__.__doc__:
|
||||
return self.ext.__class__.__doc__.strip()
|
||||
else:
|
||||
return ''
|
||||
|
||||
@property
|
||||
def parameters(self):
|
||||
return [ExtensionParameterDocumenter(p) for p in self.ext.parameters]
|
||||
|
||||
def __init__(self, ext):
|
||||
self.ext = ext
|
||||
|
||||
|
||||
class ExtensionParameterDocumenter(object):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.param.name
|
||||
|
||||
@property
|
||||
def kind(self):
|
||||
return self.param.get_type_name()
|
||||
|
||||
@property
|
||||
def default(self):
|
||||
return self.param.default
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
return self.param.description
|
||||
|
||||
@property
|
||||
def constraint(self):
|
||||
constraints = []
|
||||
if self.param.allowed_values:
|
||||
constraints.append('value must be in {}'.format(self.param.allowed_values))
|
||||
if self.param.constraint:
|
||||
constraint_text = self.param.constraint.__name__
|
||||
if constraint_text == '<lambda>':
|
||||
constraint_text = _parse_lambda(inspect.getsource(self.param.constraint))
|
||||
constraints.append(constraint_text)
|
||||
return ' and '.join(constraints)
|
||||
|
||||
def __init__(self, param):
|
||||
self.param = param
|
||||
|
||||
|
||||
# Utility functions
|
||||
|
||||
|
||||
def _parse_lambda(text):
|
||||
"""Parse the definition of a lambda function in to a readable string."""
|
||||
text = text.split('lambda')[1]
|
||||
param, rest = text.split(':')
|
||||
param = param.strip()
|
||||
# There are three things that could terminate a lambda: an (unparenthesized)
|
||||
# comma, a new line and an (unmatched) close paren.
|
||||
term_chars = [',', '\n', ')']
|
||||
func_text = ''
|
||||
inside_paren = 0 # an int rather than a bool to keep track of nesting
|
||||
for c in rest:
|
||||
if c in term_chars and not inside_paren:
|
||||
break
|
||||
elif c == ')': # must be inside paren
|
||||
inside_paren -= 1
|
||||
elif c == '(':
|
||||
inside_paren += 1
|
||||
func_text += c
|
||||
|
||||
# Rename the lambda parameter to 'value' so that the resulting
|
||||
# "description" makes more sense.
|
||||
func_text = re.sub(r'\b{}\b'.format(param), 'value', func_text)
|
||||
|
||||
return func_text
|
||||
|
Reference in New Issue
Block a user