From 52aed87bfb077947abdc7a74cba6dd84f5f0ddb9 Mon Sep 17 00:00:00 2001 From: thuttinpasseron <87776406+thuttinpasseron@users.noreply.github.com> Date: Tue, 9 May 2023 01:10:34 +0200 Subject: [PATCH 1/2] Added tentative visibility and abstract/final options Signed-off-by: Thibault HUTTIN-PASSERON <87776406+thuttinpasseron@users.noreply.github.com> --- sphinxcontrib/phpdomain.py | 60 ++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/sphinxcontrib/phpdomain.py b/sphinxcontrib/phpdomain.py index af78ba9..7782581 100644 --- a/sphinxcontrib/phpdomain.py +++ b/sphinxcontrib/phpdomain.py @@ -386,8 +386,31 @@ class PhpClasslike(PhpObject): (classes, exceptions, interfaces, traits, enums). """ + option_spec = { + 'noindex': directives.flag, + 'noindexentry': directives.flag, + 'nocontentsentry': directives.flag, + 'module': directives.unchanged, + 'private': directives.flag, + 'public': directives.flag, + 'protected': directives.flag, + 'final': directives.flag, + 'abstract': directives.flag + } + def get_signature_prefix(self, sig): - return self.objtype + ' ' + prefix = '' + if 'final' in self.options: + prefix += _('final ') + elif self.objtype == 'class' and 'abstract' in self.options: + prefix += _('abstract') + if 'private' in self.options: + prefix += _('private ') + elif 'protected' in self.options: + prefix += _('protected') + elif 'public' in self.options: + prefix += _('public ') + return prefix + self.objtype + ' ' def get_index_text(self, modname, name_cls): if self.objtype == 'class': @@ -425,14 +448,39 @@ class PhpClassmember(PhpObject): Description of a class member (methods, attributes). """ + option_spec = { + 'noindex': directives.flag, + 'noindexentry': directives.flag, + 'nocontentsentry': directives.flag, + 'module': directives.unchanged, + 'private': directives.flag, + 'public': directives.flag, + 'protected': directives.flag, + 'static': directives.flag, + 'final': directives.flag + } + def get_signature_prefix(self, sig): + prefix = '' + if self.objtype != 'case': + if self.objtype == 'method': + if 'final' in self.options: + prefix += _('final ') + elif 'abstract' in self.options: + prefix += _('abstract ') + if 'private' in self.options: + prefix += _('private ') + elif 'protected' in self.options: + prefix += _('protected ') + elif 'public' in self.options: + prefix += _('public ') + if 'static' in self.options or self.objtype == 'staticmethod': + prefix += _('static ') if self.objtype == 'attr': - return _('property ') - if self.objtype == 'staticmethod': - return _('static ') + prefix += _('property ') if self.objtype == 'case': - return _('case ') - return '' + prefix += _('case ') + return prefix def needs_arglist(self): return self.objtype == 'method' From cd986c1426f454b4b4115114dbca7576a45193e5 Mon Sep 17 00:00:00 2001 From: Thibault HUTTIN-PASSERON <87776406+thuttinpasseron@users.noreply.github.com> Date: Sun, 14 May 2023 15:11:30 +0200 Subject: [PATCH 2/2] Moved visibility to relvant classes, added final and abstract options to classes --- sphinxcontrib/phpdomain.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/sphinxcontrib/phpdomain.py b/sphinxcontrib/phpdomain.py index 7782581..48aeee8 100644 --- a/sphinxcontrib/phpdomain.py +++ b/sphinxcontrib/phpdomain.py @@ -391,9 +391,6 @@ class PhpClasslike(PhpObject): 'noindexentry': directives.flag, 'nocontentsentry': directives.flag, 'module': directives.unchanged, - 'private': directives.flag, - 'public': directives.flag, - 'protected': directives.flag, 'final': directives.flag, 'abstract': directives.flag } @@ -401,15 +398,9 @@ class PhpClasslike(PhpObject): def get_signature_prefix(self, sig): prefix = '' if 'final' in self.options: - prefix += _('final ') + prefix += 'final ' elif self.objtype == 'class' and 'abstract' in self.options: - prefix += _('abstract') - if 'private' in self.options: - prefix += _('private ') - elif 'protected' in self.options: - prefix += _('protected') - elif 'public' in self.options: - prefix += _('public ') + prefix += 'abstract ' return prefix + self.objtype + ' ' def get_index_text(self, modname, name_cls): @@ -465,17 +456,17 @@ def get_signature_prefix(self, sig): if self.objtype != 'case': if self.objtype == 'method': if 'final' in self.options: - prefix += _('final ') + prefix += 'final ' elif 'abstract' in self.options: - prefix += _('abstract ') + prefix += 'abstract ' if 'private' in self.options: - prefix += _('private ') + prefix += 'private ' elif 'protected' in self.options: - prefix += _('protected ') + prefix += 'protected ' elif 'public' in self.options: - prefix += _('public ') + prefix += 'public ' if 'static' in self.options or self.objtype == 'staticmethod': - prefix += _('static ') + prefix += 'static ' if self.objtype == 'attr': prefix += _('property ') if self.objtype == 'case':