Skip to content

Commit

Permalink
javadoc: allow space before parameter direction indication
Browse files Browse the repository at this point in the history
Having whitespace between @param and [direction] fails to match the
param regex:

 @param[in] works
 @param [in] fails

This is detected but not handled properly, leading to a backtrace about
mo.group() being called when mo is None.

Fix the regex and, to an extent, the error handling.

This is just the simplest and quickest fix. There should be better error
handling with proper error messages all around, as well as testing.
  • Loading branch information
jnikula committed Aug 28, 2024
1 parent b597142 commit 1aad1bf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hawkmoth/ext/javadoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,12 @@ class _param(_field_list):
_field_name = 'param'

def header(self):
mo = re.match(r'^(\[(?P<direction>[a-zA-Z, ]+)\])?(?P<sp1>\s*)(?P<name>([a-zA-Z0-9_]+|\.\.\.))(?P<sp2>\s*(?P<desc>.*))', # noqa: E501
mo = re.match(r'^((?P<sp0>\s*)\[(?P<direction>[a-zA-Z, ]+)\])?(?P<sp1>\s*)(?P<name>([a-zA-Z0-9_]+|\.\.\.))(?P<sp2>\s*(?P<desc>.*))', # noqa: E501
self.rest())
if mo is None:
# FIXME
yield ''
return

direction = mo.group('direction')
name = mo.group('name')
Expand Down

0 comments on commit 1aad1bf

Please sign in to comment.