summaryrefslogtreecommitdiffstats
path: root/tools/lint/perfdocs/generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lint/perfdocs/generator.py')
-rw-r--r--tools/lint/perfdocs/generator.py66
1 files changed, 51 insertions, 15 deletions
diff --git a/tools/lint/perfdocs/generator.py b/tools/lint/perfdocs/generator.py
index 3f3a0acefa..240468d62c 100644
--- a/tools/lint/perfdocs/generator.py
+++ b/tools/lint/perfdocs/generator.py
@@ -70,6 +70,17 @@ class Generator(object):
rst_content = read_file(
pathlib.Path(framework["path"], framework["rst"]), stringify=True
)
+ gatherer = self._verifier._gatherer.framework_gatherers[
+ yaml_content["name"]
+ ]
+
+ metrics_rst_content = None
+ metrics_info = self._verifier.metrics_info[yaml_content["name"]]
+ if framework.get("metrics"):
+ metrics_rst_content = read_file(
+ pathlib.Path(framework["path"], framework["metrics"]),
+ stringify=True,
+ )
# Gather all tests and descriptions and format them into
# documentation content
@@ -87,21 +98,41 @@ class Generator(object):
tests = suite_info.get("tests", {})
for test_name in sorted(tests.keys()):
- gatherer = self._verifier._gatherer.framework_gatherers[
- yaml_content["name"]
- ]
test_description = gatherer.build_test_description(
- test_name, tests[test_name], suite_name
+ test_name,
+ test_description=tests[test_name],
+ suite_name=suite_name,
+ metrics_info=metrics_info,
)
documentation.extend(test_description)
documentation.append("")
+ # For each framework, we may want to organize the metrics differently
+ # so delegate the complete setup of the metric documentation to the
+ # framework-specific gatherers
+ metrics_rst = ""
+ if metrics_rst_content:
+ metrics_documentation = gatherer.build_metrics_documentation(
+ metrics_info
+ )
+ metrics_rst = re.sub(
+ r"{metrics_documentation}",
+ "\n".join(metrics_documentation),
+ metrics_rst_content,
+ )
+ rst_content = re.sub(
+ r"{metrics_rst_name}",
+ f"{yaml_content['name']}-metrics",
+ rst_content,
+ )
+
# Insert documentation into `.rst` file
framework_rst = re.sub(
r"{documentation}", "\n".join(documentation), rst_content
)
frameworks_info[yaml_content["name"]] = {
"dynamic": framework_rst,
+ "metrics": metrics_rst,
"static": [],
}
@@ -165,6 +196,12 @@ class Generator(object):
pathlib.Path(perfdocs_tmpdir, framework_name),
)
+ if framework_docs[framework_name]["metrics"]:
+ save_file(
+ framework_docs[framework_name]["metrics"],
+ pathlib.Path(perfdocs_tmpdir, f"{framework_name}-metrics"),
+ )
+
for static_name in framework_docs[framework_name]["static"]:
if static_name["file"].endswith(".rst"):
# XXX Replace this with a shutil.copy call (like below)
@@ -266,16 +303,15 @@ class Generator(object):
perfdocs_tmpdir = self._create_perfdocs()
if self._generate:
self._save_perfdocs(perfdocs_tmpdir)
- else:
+ elif not are_dirs_equal(perfdocs_tmpdir, self.perfdocs_path):
# If we are not generating, then at least check if they
# should be regenerated by comparing the directories.
- if not are_dirs_equal(perfdocs_tmpdir, self.perfdocs_path):
- logger.warning(
- "PerfDocs are outdated, run ./mach lint -l perfdocs --fix .` "
- + "to update them. You can also apply the "
- + f"{'perfdocs.diff' if ON_TRY else 'diff.txt'} patch file "
- + f"{'produced from this reviewbot test ' if ON_TRY else ''}"
- + "to fix the issue.",
- files=get_changed_files(self._workspace),
- restricted=False,
- )
+ logger.warning(
+ "PerfDocs are outdated, run ./mach lint -l perfdocs --fix .` "
+ + "to update them. You can also apply the "
+ + f"{'perfdocs.diff' if ON_TRY else 'diff.txt'} patch file "
+ + f"{'produced from this reviewbot test ' if ON_TRY else ''}"
+ + "to fix the issue.",
+ files=get_changed_files(self._workspace),
+ restricted=False,
+ )