Skip to content

Commit

Permalink
API: use descriptive names for regular expression flags
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof committed Aug 26, 2024
1 parent 38004be commit cef34e5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/api/generate-openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,17 @@ def gen_fn_spec(name, fn):
,'dict': 'object'
,'list': 'array'}

paramdocs = oDict(*[(k, (types[(re.findall(r'^\s*:type\s+' +re.escape(k)+r':\s*(.+?)\s*$', doc, re.M) or ['str'])[-1]],
(re.findall(r'^\s*:param\s+'+re.escape(k)+r':\s*(.+?)\s*$', doc, re.M) or ['(undocumented)'])[-1],
paramdocs = oDict(*[(k, (types[(re.findall(r'^\s*:type\s+' +re.escape(k)+r':\s*(.+?)\s*$', doc, re.MULTILINE) or ['str'])[-1]],
(re.findall(r'^\s*:param\s+'+re.escape(k)+r':\s*(.+?)\s*$', doc, re.MULTILINE) or ['(undocumented)'])[-1],
None if i < len(required) else a_defaults[i-len(required)]))
for i, k in enumerate(required+optional)])

# Sphinx-compatible parameter documentation.
doc = re.sub(r'^\s*:param.*?\n', '', doc, flags=re.M|re.S)
doc = re.sub(r'^\s*:type.*?\n', '', doc, flags=re.M|re.S)
doc = re.sub(r'^\s*:param.*?\n', '', doc, flags=re.MULTILINE|re.DOTALL)
doc = re.sub(r'^\s*:type.*?\n', '', doc, flags=re.MULTILINE|re.DOTALL)

# Only retrieve summary.
doc = re.sub(r'^\s*[\r\n].*', '', doc, flags=re.M|re.S)
doc = re.sub(r'^\s*[\r\n].*', '', doc, flags=re.MULTILINE|re.DOTALL)

req = list(required)
props = oDict(*[(name, { 'type': paramdocs[name][0],
Expand Down

0 comments on commit cef34e5

Please sign in to comment.