From: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>, Daniel Vetter <daniel@ffwll.ch>
Subject: [igt-dev] [PATCH i-g-t 5/5] docs: Embed subtest descriptions in the documentation
Date: Mon, 17 Jun 2019 13:54:43 +0300 [thread overview]
Message-ID: <20190617105443.8264-5-arkadiusz.hiler@intel.com> (raw)
In-Reply-To: <20190617105443.8264-1-arkadiusz.hiler@intel.com>
This rewrites generate_description_xml in Python, so that we generate
properly escaped XML. The switch also makes the code more manageable.
Changes in the generated docbook:
1. subtests are not simply listed anymore, they are now another (sub)section
2. subtests are now linkable,
e.g. docs/igt-kms-tests.html#kms_hdmi_inject@inject-4k
3. subtest's section now includes output of --describe
Python is required already by gtk-doc and we are not using anything
other than the standard library.
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
.../igt-gpu-tools/generate_description_xml.py | 112 ++++++++++++++++++
.../igt-gpu-tools/generate_description_xml.sh | 46 -------
docs/reference/igt-gpu-tools/meson.build | 2 +-
3 files changed, 113 insertions(+), 47 deletions(-)
create mode 100755 docs/reference/igt-gpu-tools/generate_description_xml.py
delete mode 100644 docs/reference/igt-gpu-tools/generate_description_xml.sh
diff --git a/docs/reference/igt-gpu-tools/generate_description_xml.py b/docs/reference/igt-gpu-tools/generate_description_xml.py
new file mode 100755
index 00000000..87af945d
--- /dev/null
+++ b/docs/reference/igt-gpu-tools/generate_description_xml.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+import os.path
+import subprocess
+import xml.etree.cElementTree as ET
+
+from collections import namedtuple
+
+Subtest = namedtuple("Subtest", "name description")
+KEYWORDS=re.compile(r'\b(invalid|hang|swap|thrash|crc|tiled|tiling|rte|ctx|render|blt|bsd|vebox|exec|rpm)\b')
+
+
+def get_testlist(path):
+ "read binaries' names from test-list.txt"
+ with open(path, 'r') as f:
+ assert(f.readline() == "TESTLIST\n")
+ tests = f.readline().strip().split(" ")
+ assert(f.readline() == "END TESTLIST\n")
+
+ return tests
+
+
+def keywordize(root, text, keywords):
+ "set text for root element and wrap KEYWORDS in a <acronym>"
+ matches = list(keywords.finditer(text))
+
+ if not matches:
+ root.text = text
+ return
+
+ pos = 0
+ last_element = None
+ root.text = ""
+
+ for match in matches:
+ if match.start() > pos:
+ to_append = text[pos:match.start()]
+
+ if last_element == None:
+ root.text += to_append
+ else:
+ last_element.tail += to_append
+
+ last_element = ET.SubElement(root, "acronym")
+ last_element.tail = ""
+ last_element.text=match.group()
+ pos = match.end()
+
+
+def get_subtests(testdir, test):
+ "execute test and get subtests with their descriptions via --describe"
+ output = []
+ full_test_path = os.path.join(testdir, test)
+ proc = subprocess.run([full_test_path, "--describe"], stdout=subprocess.PIPE)
+ description = ""
+ current_subtest = None
+
+ for line in proc.stdout.decode().splitlines():
+ if line.startswith("SUB "):
+ output += [Subtest(current_subtest, description)]
+ description = ""
+ current_subtest = line.split(' ')[1]
+ else:
+ description += line
+
+ output += [Subtest(current_subtest, description)]
+
+ return output
+
+def main():
+ output_file = sys.argv[1]
+ test_filter = re.compile(sys.argv[2])
+ testlist_file = sys.argv[3]
+ testdir = os.path.abspath(os.path.dirname(testlist_file))
+
+ root = ET.Element("refsect1")
+ ET.SubElement(root, "title").text = "Description"
+
+ tests = get_testlist(testlist_file)
+
+ for test in tests:
+ if not test_filter.match(test):
+ continue
+
+ test_section = ET.SubElement(root, "refsect2", id=test)
+ test_title = ET.SubElement(test_section, "title")
+ keywordize(test_title, test, KEYWORDS)
+
+ subtests = get_subtests(testdir, test)
+
+ # we have description with no subtest name, add it at the top level
+ if subtests and not subtests[0].name:
+ ET.SubElement(test_section, "para").text = subtests[0].description
+
+ if len(subtests) > 100:
+ ET.SubElement(test_section, "para").text = "More than 100 subtests, skipping listing"
+ continue
+
+ for name, description in subtests:
+ if not name:
+ continue
+
+ subtest_section = ET.SubElement(test_section, "refsect3", id="{}@{}".format(test, name))
+ subtest_title = ET.SubElement(subtest_section, "title")
+ keywordize(subtest_title, name, KEYWORDS)
+ ET.SubElement(subtest_section, "para").text = description
+
+ ET.ElementTree(root).write(output_file)
+
+main()
diff --git a/docs/reference/igt-gpu-tools/generate_description_xml.sh b/docs/reference/igt-gpu-tools/generate_description_xml.sh
deleted file mode 100644
index 705a7bf3..00000000
--- a/docs/reference/igt-gpu-tools/generate_description_xml.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-
-output=$1
-filter=$2
-testlist=$3
-testdir=$(dirname $testlist)
-
-KEYWORDS="(invalid|hang|swap|thrash|crc|tiled|tiling|rte|ctx|render|blt|bsd|vebox|exec|rpm)"
-
-echo "<?xml version=\"1.0\"?>" > $output
-echo "<!DOCTYPE refsect1 PUBLIC \"-//OASIS//DTD DocBook XML V4.3//EN\"" >> $output
-echo " \"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd\"" >> $output
-echo "[" >> $output
-echo " <!ENTITY % local.common.attrib \"xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'\">" >> $output
-echo " <!ENTITY version SYSTEM \"version.xml\">" >> $output
-echo "]>" >> $output
-echo "<refsect1>" >> $output
-echo "<title>Description</title>" >> $output
-for test in `cat $testlist | tr ' ' '\n' | grep "^$filter" | sort`; do
- echo "<refsect2 id=\"$test\"><title>" >> $output;
- echo "$test" | perl -pe "s/(?<=_)$KEYWORDS(?=(_|\\W))/<acronym>\\1<\\/acronym>/g" >> $output;
- echo "</title><para><![CDATA[" >> $output;
- testprog=$testdir/$test;
- ./$testprog --help-description >> $output;
- echo "]]></para>" >> $output;
- if ./$testprog --list-subtests > /dev/null ; then
- echo "<refsect3><title>Subtests</title>" >> $output;
- subtest_list=`./$testprog --list-subtests`;
- subtest_count=`echo $subtest_list | wc -w`;
- if [ $subtest_count -gt 100 ]; then
- echo "<para>This test has over 100 subtests. " >> $output;
- echo "Run <command>$test</command> <option>--list-subtests</option> to list them.</para>" >> $output;
- else
- echo "<simplelist>" >> $output;
- for subtest in $subtest_list; do
- echo "<member>" >> $output;
- echo "$subtest" | perl -pe "s/\\b$KEYWORDS\\b/<acronym>\\1<\\/acronym>/g" >> $output;
- echo "</member>" >> $output;
- done;
- echo "</simplelist>" >> $output;
- fi;
- echo "</refsect3>" >> $output;
- fi;
- echo "</refsect2>" >> $output;
-done;
-echo "</refsect1>" >> $output
diff --git a/docs/reference/igt-gpu-tools/meson.build b/docs/reference/igt-gpu-tools/meson.build
index 4d177e49..e2bdc495 100644
--- a/docs/reference/igt-gpu-tools/meson.build
+++ b/docs/reference/igt-gpu-tools/meson.build
@@ -45,7 +45,7 @@ test_groups = [
'vgem',
]
-gen_description = find_program('generate_description_xml.sh')
+gen_description = find_program('generate_description_xml.py')
gen_programs = find_program('generate_programs_xml.sh')
generated_docs = []
--
2.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-06-17 10:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 10:54 [igt-dev] [PATCH i-g-t 1/5] lib/igt_core: Add support for subtest descriptions Arkadiusz Hiler
2019-06-17 10:54 ` [igt-dev] [PATCH i-g-t 2/5] tests/kms_hdmi_inject: Provide igt_descriptions Arkadiusz Hiler
2019-06-17 12:54 ` Ser, Simon
2019-06-18 10:36 ` [igt-dev] [PATCH v2 " Arkadiusz Hiler
2019-06-19 6:44 ` Ser, Simon
2019-06-17 10:54 ` [igt-dev] [PATCH i-g-t 3/5] tests/kms_plane_multiple: Describe the test Arkadiusz Hiler
2019-06-18 9:36 ` Kahola, Mika
2019-06-17 10:54 ` [igt-dev] [PATCH i-g-t 4/5] CONTRIBUTING: Rework a bit and update Arkadiusz Hiler
2019-06-20 13:49 ` Ser, Simon
2019-06-27 12:57 ` Arkadiusz Hiler
2019-06-27 14:00 ` Ser, Simon
2019-06-17 10:54 ` Arkadiusz Hiler [this message]
2019-06-20 8:20 ` [igt-dev] [PATCH i-g-t 5/5] docs: Embed subtest descriptions in the documentation Petri Latvala
2019-06-20 10:52 ` Arkadiusz Hiler
2019-06-20 11:05 ` Ser, Simon
2019-06-20 11:16 ` Arkadiusz Hiler
2019-06-20 11:11 ` Petri Latvala
2019-06-20 11:38 ` Arkadiusz Hiler
2019-06-20 12:16 ` Petri Latvala
2019-06-24 8:00 ` Ser, Simon
2019-06-27 12:52 ` Arkadiusz Hiler
2019-06-17 13:28 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] lib/igt_core: Add support for subtest descriptions Patchwork
2019-06-17 19:59 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-06-18 12:02 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] lib/igt_core: Add support for subtest descriptions (rev2) Patchwork
2019-06-18 22:45 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2019-07-01 12:21 [igt-dev] [PATCH i-g-t 1/5] lib/igt_core: Add support for subtest descriptions Arkadiusz Hiler
2019-07-01 12:21 ` [igt-dev] [PATCH i-g-t 5/5] docs: Embed subtest descriptions in the documentation Arkadiusz Hiler
2019-07-03 7:18 ` Ser, Simon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190617105443.8264-5-arkadiusz.hiler@intel.com \
--to=arkadiusz.hiler@intel.com \
--cc=daniel@ffwll.ch \
--cc=igt-dev@lists.freedesktop.org \
--cc=petri.latvala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.