Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/apidoc.py
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | def process_paragraph(self, par): | ||||
par = par.replace('</emphasis>', '*') | par = par.replace('</emphasis>', '*') | ||||
par = par.replace('<strong>', '**') | par = par.replace('<strong>', '**') | ||||
par = par.replace('</strong>', '**') | par = par.replace('</strong>', '**') | ||||
par = par.replace('<literal>', '``') | par = par.replace('<literal>', '``') | ||||
par = par.replace('</literal>', '``') | par = par.replace('</literal>', '``') | ||||
# remove parsed document markups | # remove parsed document markups | ||||
par = re.sub('<[^<]+?>', '', par) | par = re.sub('<[^<]+?>', '', par) | ||||
# api urls cleanup to generate valid links afterwards | # api urls cleanup to generate valid links afterwards | ||||
par = re.sub('\(\w+\)', '', par) # noqa | par = re.sub(r'\(\w+\)', '', par) | ||||
par = re.sub('\[.*\]', '', par) # noqa | par = re.sub(r'\[.*\]', '', par) | ||||
par = par.replace('//', '/') | par = par.replace('//', '/') | ||||
# transform references to api endpoints into valid rst links | # transform references to api endpoints into valid rst links | ||||
par = re.sub(':http:get:`([^,]*)`', r'`<\1>`_', par) | par = re.sub(':http:get:`([^,]*)`', r'`<\1>`_', par) | ||||
# transform references to some elements into bold text | # transform references to some elements into bold text | ||||
par = re.sub(':http:header:`(.*)`', r'**\1**', par) | par = re.sub(':http:header:`(.*)`', r'**\1**', par) | ||||
par = re.sub(':func:`(.*)`', r'**\1**', par) | par = re.sub(':func:`(.*)`', r'**\1**', par) | ||||
return par | return par | ||||
▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines |