summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-17 20:39:14 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-21 14:05:33 +0200
commitceff746690571092169729d62a3225b9a1a69f8d (patch)
treefb47fae5f9f1bbc9290b24a14b407acec367e362 /scripts
parent4d032271ce65f6ad816ca71cd8d77fc0b6f6fc1a (diff)
scripts: Extend support for formatting comments
Now that comments can span multiple lines, add support for nested lists. The yaml syntax is comments: - The BSP commit bundles 5 different changes: - Disable SN65DSI86 GPIOs - Disable scrambling (for V3U Falcon) - Hot plug detectiong polling - EDID retrieval - 4k support for Display Port v1.2 which gets translated to <ul> <li> <p>The BSP commit bundles 5 different changes</p> <p> <ul> <li> <p>Disable SN65DSI86 GPIOs</p> </li> <li> <p>Disable scrambling (for V3U Falcon)</p> </li> <li> <p>Hot plug detectiong polling</p> </li> <li> <p>EDID retrieval</p> </li> <li> <p>4k support for Display Port v1.2</p> </li> </ul> </p> </li> </ul> The YAML schema is relaxed accordingly to support sequences of anything in comments. Note the need for ':' at the end of the first line in the list. Without that, the full comment will be treated as a single block of text by the yaml parser, and the HTML generation script will render it as a single paragraph without line breaks. This could be addressed, but if we keep going further in that during, maybe a full markdown parser and generator should be integrated instead. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/html_task.py63
1 files changed, 45 insertions, 18 deletions
diff --git a/scripts/html_task.py b/scripts/html_task.py
index 1e6c175..e47bb99 100755
--- a/scripts/html_task.py
+++ b/scripts/html_task.py
@@ -19,9 +19,22 @@ from html_base import html
#====================================
class periject_html(html_base.myhtml):
+ re_http_url = re.compile(r'(https?://[\w/:%#\$&\?\(\)~\.=\+\-]+)')
+ re_blank_line = re.compile(r'\n\n+')
+
def __init__(self):
super().__init__()
+ def _link(self, text):
+ match = periject_html.re_http_url.search(text)
+ if not match:
+ return text
+
+ a = html("a", {"href": match.group(), "target": "_blank"})
+ return match.string[:match.start()] + \
+ a.text(match.group()) + \
+ match.string[match.end():]
+
#--------------------
# task_commit_bsp
#--------------------
@@ -148,28 +161,42 @@ class periject_html(html_base.myhtml):
self.task_commit_upstream(v)
#--------------------
- # task_comment
+ # _task_comments
+ #--------------------
+ def _task_comments(self, v):
+
+ if isinstance(v, list):
+ with html("ul"):
+ for comment in v:
+ with html("li"):
+ self._task_comments(comment)
+
+ elif isinstance(v, dict):
+ for key, value in v.items():
+ html("p").print(self._link(key))
+ with html("p"):
+ self._task_comments(value)
+
+ elif isinstance(v, str):
+ comment = self._link(v)
+
+ comment = periject_html.re_blank_line.split(comment)
+ for para in comment:
+ html("p").print(para)
+
+ else:
+ print(v)
+ raise TypeError(f"Incorrect type for comments ({type(v)})")
+
+ #--------------------
+ # task_comments
#--------------------
- def task_comment(self, v):
+ def task_comments(self, v):
comments = v.get_data("comments")
if (not comments):
return
- with html("ul"):
- for comment in comments:
- str = re.search(r'(https?://[\w/:%#\$&\?\(\)~\.=\+\-]+)', comment)
- if (str):
- a = html("a", {"href":str.group(),
- "target":"_blank"})
- comment = str.string[:str.start()] + a.text(str.group()) + str.string[str.end():]
-
- comment = re.split(r'\n\n+', comment)
- if len(comment) > 1:
- with html("li"):
- for para in comment:
- html("p").print(para)
- else:
- html("li").print(comment[0])
+ self._task_comments(comments)
#--------------------
# print
@@ -188,7 +215,7 @@ class periject_html(html_base.myhtml):
html("h2").print(v.get_data("title"))
self.task_head(v)
self.task_commit(v)
- self.task_comment(v)
+ self.task_comments(v)
#====================================
#