Skip to content

Commit

Permalink
test out with revert
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Aug 1, 2023
1 parent 05e7d08 commit c5e199d
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions sphinxcontrib/phpdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ def log_assert(
php_sig_re = re.compile(
r'''^ (public\ |protected\ |private\ )? # visibility
(final\ |abstract\ |static\ )? # modifiers
([\w\\]+\:\:)? # class name(s)
(\$?[\w\\]+) \s* # thing name
(?:
\((.*)\) # optional: arguments
(?:\s* -> \s* (.*))? # return annotation
)?
([\w.]*\:\:)? # class name(s)
(\$?\w+) \s* # thing name
(?: \((.*)\) # optional: arguments
(?:\s* -> \s* (.*))?)? # return annotation
(?:\s* : \s* (.*))? # backed enum type / case value
$ # and nothing more
''', re.VERBOSE)
Expand Down Expand Up @@ -200,13 +198,13 @@ def handle_signature(self, sig, signode):
# determine module and class name (if applicable), as well as full name
modname = self.options.get(
'namespace', self.env.temp_data.get('php:namespace'))

classname = self.env.temp_data.get('php:class')
separator = separators[self.objtype]

if '::' in name_prefix:
# Method declared as Class::methodName
if not classname and '::' in name_prefix:
classname = name_prefix.rstrip('::')
else:
classname = self.env.temp_data.get('php:class')

if self.objtype == 'global' or self.objtype == 'function':
add_module = False
modname = None
Expand Down Expand Up @@ -580,9 +578,6 @@ def process_link(self, env, refnode, has_explicit_title, title, target):
if m:
title = m.group(1)

if title.startswith(NS):
title = title[1:]

refnode['php:namespace'] = env.temp_data.get('php:namespace')
refnode['php:class'] = env.temp_data.get('php:class')

Expand Down Expand Up @@ -784,20 +779,14 @@ def find_obj(self, env, fromdocnode, modname, classname, name, type, searchorder
if name[-2:] == '()':
name = name[:-2]

objects = self.data['objects']
if not name:
return None, None

if name.startswith(NS):
absname = name[1:]
else:
absname = (modname + NS if modname else "") \
+ (classname + NS if classname and '::' not in name else "") \
+ name
objects = self.data['objects']

newname = None
if searchorder == 1:
if absname in objects:
newname = absname
elif modname and classname and \
if modname and classname and \
modname + NS + classname + '::' + name in objects:
newname = modname + NS + classname + '::' + name
elif modname and modname + NS + name in objects:
Expand All @@ -811,9 +800,7 @@ def find_obj(self, env, fromdocnode, modname, classname, name, type, searchorder
elif name in objects:
newname = name
else:
if absname in objects:
newname = absname
elif name in objects:
if name in objects:
newname = name
elif classname and classname + '::' + name in objects:
newname = classname + '::' + name
Expand All @@ -832,7 +819,7 @@ def find_obj(self, env, fromdocnode, modname, classname, name, type, searchorder
'object::' + name in objects:
newname = 'object::' + name
if newname is None:
log_info(fromdocnode, f"Target not found '{absname}'")
log_info(fromdocnode, f"Target not found '{newname}'")
return None, None
return newname, objects[newname]

Expand Down

0 comments on commit c5e199d

Please sign in to comment.