From 1aad1bfbe9b35b9676b28dc35df7beeacd80a850 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 26 Aug 2024 22:03:52 +0300 Subject: [PATCH] javadoc: allow space before parameter direction indication 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. --- src/hawkmoth/ext/javadoc/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hawkmoth/ext/javadoc/__init__.py b/src/hawkmoth/ext/javadoc/__init__.py index 25ea4916..212a22c1 100644 --- a/src/hawkmoth/ext/javadoc/__init__.py +++ b/src/hawkmoth/ext/javadoc/__init__.py @@ -159,11 +159,12 @@ class _param(_field_list): _field_name = 'param' def header(self): - mo = re.match(r'^(\[(?P[a-zA-Z, ]+)\])?(?P\s*)(?P([a-zA-Z0-9_]+|\.\.\.))(?P\s*(?P.*))', # noqa: E501 + mo = re.match(r'^((?P\s*)\[(?P[a-zA-Z, ]+)\])?(?P\s*)(?P([a-zA-Z0-9_]+|\.\.\.))(?P\s*(?P.*))', # noqa: E501 self.rest()) if mo is None: # FIXME yield '' + return direction = mo.group('direction') name = mo.group('name')