File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -457,6 +457,28 @@ def run(self):
457457 return ret
458458
459459
460+ class PhpCurrentNamespace (Directive ):
461+ """
462+ This directive is just to tell Sphinx that we're documenting
463+ stuff in namespace foo, but links to namespace foo won't lead here.
464+ """
465+
466+ has_content = False
467+ required_arguments = 1
468+ optional_arguments = 0
469+ final_argument_whitespace = False
470+ option_spec = {}
471+
472+ def run (self ):
473+ env = self .state .document .settings .env
474+ modname = self .arguments [0 ].strip ()
475+ if modname == 'None' :
476+ env .temp_data ['php:namespace' ] = None
477+ else :
478+ env .temp_data ['php:namespace' ] = modname
479+ return []
480+
481+
460482class PhpXRefRole (XRefRole ):
461483 """
462484 Provides cross reference links for PHP objects
@@ -578,6 +600,8 @@ class PhpDomain(Domain):
578600 'interface' : PhpClasslike ,
579601 'trait' : PhpClasslike ,
580602 'namespace' : PhpNamespace ,
603+ 'currentmodule' : PhpCurrentNamespace ,
604+ 'currentnamespace' : PhpCurrentNamespace ,
581605 }
582606
583607 roles = {
Original file line number Diff line number Diff line change @@ -316,6 +316,7 @@ Test Case - not including namespace
316316
317317:php:class: `LibraryClass `
318318
319+
319320:php:class: `~LibraryName\\ LibraryClass `
320321
321322:php:func: `LibraryClass::instanceMethod `
@@ -326,6 +327,10 @@ Test Case - not including namespace
326327
327328:php:const: `LibraryClass::TEST_CONST `
328329
330+ :php:class: `LibraryName\\ OtherClass `
331+
332+ :php:class: `LibraryName\\ ThirdClass `
333+
329334:php:class: `NamespaceClass `
330335
331336:php:func: `NamespaceClass::firstMethod `
Original file line number Diff line number Diff line change @@ -23,3 +23,22 @@ Instance of this interface is returned by :php:meth:`Imagine\Image\ImageInterfac
2323
2424 :returns: Imagine\D raw\D rawerInterface
2525
26+ Re-used namespace
27+ =================
28+
29+ .. php :currentmodule :: LibraryName
30+
31+ No indexing errors or links should point to this namespace.
32+
33+ .. php :class :: ThirdClass
34+
35+ Another class in a currentmodule block
36+
37+ .. php :currentnamespace :: LibraryName
38+
39+ No indexing errors or links should point to this namespace.
40+
41+ .. php :class :: OtherClass
42+
43+ Another class in a reused namespace
44+
You can’t perform that action at this time.
0 commit comments