Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/apidoc.py
Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | def visit_problematic(self, node: docutils.nodes.problematic) -> str: | ||||
while subs_made: | while subs_made: | ||||
(text, subs_made) = re.subn(r"(:http:.*)(\(\w+\))", r"\1", text) | (text, subs_made) = re.subn(r"(:http:.*)(\(\w+\))", r"\1", text) | ||||
subs_made = 1 | subs_made = 1 | ||||
while subs_made: | while subs_made: | ||||
(text, subs_made) = re.subn(r"(:http:.*)(\[.*\])", r"\1", text) | (text, subs_made) = re.subn(r"(:http:.*)(\[.*\])", r"\1", text) | ||||
text = re.sub(r"([^:])//", r"\1/", text) | text = re.sub(r"([^:])//", r"\1/", text) | ||||
# transform references to api endpoints doc into valid rst links | # transform references to api endpoints doc into valid rst links | ||||
text = re.sub(":http:get:`([^,`]*)`", r"`\1 <\1doc/>`_", text) | text = re.sub(":http:get:`([^,`]*)`", r"`\1 <\1doc/>`_", text) | ||||
text = re.sub(":http:post:`([^,`]*)`", r"`\1 <\1doc/>`_", text) | |||||
# transform references to some elements into bold text | # transform references to some elements into bold text | ||||
text = re.sub(":http:header:`(.*)`", r"**\1**", text) | text = re.sub(":http:header:`(.*)`", r"**\1**", text) | ||||
text = re.sub(":func:`(.*)`", r"**\1**", text) | text = re.sub(":func:`(.*)`", r"**\1**", text) | ||||
text = re.sub(":mod:`(.*)`", r"**\1**", text) | text = re.sub(":mod:`(.*)`", r"**\1**", text) | ||||
# extract example urls | # extract example urls | ||||
if ":swh_web_api:" in text: | if ":swh_web_api:" in text: | ||||
# Extract examples to their own section | # Extract examples to their own section | ||||
▲ Show 20 Lines • Show All 246 Lines • Show Last 20 Lines |