diff --git a/doc/ext/support_matrix.py b/doc/ext/support_matrix.py index 6e423fdc02..19f487784b 100644 --- a/doc/ext/support_matrix.py +++ b/doc/ext/support_matrix.py @@ -412,12 +412,39 @@ class SupportMatrixDirective(rst.Directive): ids=[id]), ] if impl.notes is not None: - subitem.append(nodes.paragraph(text=impl.notes)) + subitem.append(self._create_notes_paragraph(impl.notes)) impls.append(subitem) item.append(impls) details.append(item) + def _create_notes_paragraph(self, notes): + """ Constructs a paragraph which represents the implementation notes + + The paragraph consists of text and clickable URL nodes if links were + given in the notes. + """ + para = nodes.paragraph() + # links could start with http:// or https:// + link_idxs = [m.start() for m in re.finditer('https?://', notes)] + start_idx = 0 + for link_idx in link_idxs: + # assume the notes start with text (could be empty) + para.append(nodes.inline(text=notes[start_idx:link_idx])) + # create a URL node until the next text or the end of the notes + link_end_idx = notes.find(" ", link_idx) + if link_end_idx == -1: + # In case the notes end with a link without a blank + link_end_idx = len(notes) + uri = notes[link_idx:link_end_idx + 1] + para.append(nodes.reference("", uri, refuri=uri)) + start_idx = link_end_idx + 1 + + # get all text after the last link (could be empty) or all of the + # text if no link was given + para.append(nodes.inline(text=notes[start_idx:])) + return para + def setup(app): app.add_directive('support_matrix', SupportMatrixDirective)