Skip to content

Commit 4c23ebb

Browse files
committed
Fix prefix removal on namespaced symbols
Pull in the changes made my @n-peugnet and also fix prefix removal on namespaced class links as they were wrong too. Fixes #44
1 parent 2d06842 commit 4c23ebb

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jobs:
2929
pip install -r requirements.txt
3030
pip install .
3131
32-
- name: Build Test
32+
- name: Build test/
3333
run: |
3434
cd test && make html SPHINXOPTS='-W'

sphinxcontrib/phpdomain.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,16 +508,15 @@ def process_link(self, env, refnode, has_explicit_title, title, target):
508508
if title.startswith("::"):
509509
title = title[2:]
510510
target = target.lstrip('~') # only has a meaning for the title
511-
# if the first character is a tilde, don't display the module/class
512-
# parts of the contents
513-
if title[0:1] == '~':
514-
m = re.search(r"(?:.+[:]{2}|(?:.*?\\{2})+)?(.*)\Z", title)
511+
512+
# If the first char is ~ don't display the leading namespace & class.
513+
if title.startswith('~'):
514+
m = re.search(r"(?:.+[:]{2}|(?:.*?\\{1,2})+)?(.*)\Z", title)
515515
if m:
516516
title = m.group(1)
517517

518-
if not title.startswith("$"):
519-
refnode['php:namespace'] = env.temp_data.get('php:namespace')
520-
refnode['php:class'] = env.temp_data.get('php:class')
518+
refnode['php:namespace'] = env.temp_data.get('php:namespace')
519+
refnode['php:class'] = env.temp_data.get('php:class')
521520

522521
return title, target
523522

test/test_doc.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,16 @@ Test Case - Global symbols with no namespaces
166166

167167
:php:func:`DateTime::getLastErrors()`
168168

169-
:php:func:`~DateTime::setDate()`
169+
:php:func:`DateTime::setDate()`
170+
171+
:php:func:`~DateTime::setDate()` Should not be prefixed with a classname
170172

171173
:php:func:`DateTime::ATOM`
172174

173175
:php:func:`DateTime::$testattr`
174176

177+
:php:func:`~DateTime::$testattr` Should not be prefixed with classname
178+
175179
:php:func:`OtherClass::update`
176180

177181
:php:attr:`OtherClass::$nonIndentedAttribute`
@@ -316,17 +320,23 @@ Test Case - not including namespace
316320

317321
:php:class:`LibraryClass`
318322

319-
320-
:php:class:`~LibraryName\\LibraryClass`
323+
:php:class:`~LibraryName\\LibraryClass` Should not be be prefixed with
324+
classname.
321325

322326
:php:func:`LibraryClass::instanceMethod`
323327

328+
:php:func:`~LibraryClass::instanceMethod` Should not be prefixed with classname.
329+
324330
:php:func:`LibraryClass::staticMethod()`
325331

326332
:php:attr:`LibraryClass::$property`
327333

334+
:php:attr:`~LibraryClass::$property` Should not be prefixed with classname.
335+
328336
:php:const:`LibraryClass::TEST_CONST`
329337

338+
:php:const:`~LibraryClass::TEST_CONST` Should not be prefixed with classname.
339+
330340
:php:class:`LibraryName\\OtherClass`
331341

332342
:php:class:`LibraryName\\ThirdClass`
@@ -378,6 +388,8 @@ Test Case - global access
378388

379389
:php:attr:`LibraryName\\LibraryClass::$property`
380390

391+
:php:attr:`~LibraryName\\LibraryClass::$property` Should not be prefixed with classname.
392+
381393
:php:const:`LibraryName\\LibraryClass::TEST_CONST`
382394

383395
:php:const:`LibraryName\\NS_CONST`

0 commit comments

Comments
 (0)