Skip to content

Commit 77ae60b

Browse files
authored
Merge pull request #29 from ramsey/return-object
Link body of return type to the xref for the type
2 parents 7914298 + 7f58d18 commit 77ae60b

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

doc/reference.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ Each directive populates the index, and or the namespace index.
8888
8989
:param string $one: The first parameter.
9090
:param string $two: The second parameter.
91-
:returns: An array of stuff.
91+
:returns: A description of what this returns.
92+
:returntype: LibraryName\\LibraryClass
9293
:throws: InvalidArgumentException
9394
9495
This is an instance method.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sphinx>=1.3, <2.3
1+
sphinx>=1.3, <2.5

sphinxcontrib/phpdomain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class PhpObject(ObjectDescription):
128128
Field('returnvalue', label=_('Returns'), has_arg=False,
129129
names=('returns', 'return')),
130130
Field('returntype', label=_('Return type'), has_arg=False,
131-
names=('rtype', 'returntype')),
131+
names=('rtype', 'returntype'), bodyrolename='obj'),
132132
]
133133

134134
def get_signature_prefix(self, sig):

test/test_doc.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,51 @@ Test Case - Test subpackage links
424424
:php:class:`LibraryName\\SubPackage\\SubpackageInterface`
425425

426426
:php:exc:`LibraryName\\SubPackage\\NestedNamespaceException`
427+
428+
Return Types
429+
============
430+
431+
.. php:namespace:: OtherLibrary
432+
433+
.. php:class:: ReturningClass
434+
435+
A class to do some returning.
436+
437+
.. php:method:: returnClassFromSameNamespace()
438+
439+
:returns: An object instance of a class from the same namespace.
440+
:returntype: OtherLibrary\\ReturnedClass
441+
442+
.. php:method:: returnClassFromOtherNamespace()
443+
444+
:returns: An object instance of a class from another namespace.
445+
:returntype: LibraryName\\SubPackage\\SubpackageInterface
446+
447+
.. php:method:: returnClassConstant()
448+
449+
:returns: The value of a specific class constant.
450+
:returntype: LibraryName\\NamespaceClass::NAMESPACE_CONST
451+
452+
.. php:method:: returnGlobalConstant()
453+
454+
:returns: The value of a specific global constant.
455+
:returntype: SOME_CONSTANT
456+
457+
.. php:method:: returnExceptionInstance()
458+
459+
:returns: An instance of an exception.
460+
:returntype: InvalidArgumentException
461+
462+
.. php:method:: returnScalarType()
463+
464+
:returns: A scalar string type.
465+
:returntype: string
466+
467+
.. php:method:: returnUnionType()
468+
469+
:returns: Any of a whole bunch of things specified with a PHP 8 union type.
470+
:returntype: int|string|OtherLibrary\\ReturnedClass|LibraryName\\SubPackage\\SubpackageInterface|null
471+
472+
.. php:class:: ReturnedClass
473+
474+
A class to return.

0 commit comments

Comments
 (0)