Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added multiply inherited class for PHP objects #630

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@ class PyClasslike(BaseObject, python.PyClasslike):

# ----------------------------------------------------------------------------

# Create multi-inheritance classes to merge BaseObject from Breathe with
# classes from phpdomain.
# We use capitalization (and the namespace) to differentiate between the two

if php is not None:
class PHPNamespaceLevel(BaseObject, php.PhpNamespacelevel):
"""Description of a PHP item *in* a namespace (not the space itself)."""
pass

class PHPClassLike(BaseObject, php.PhpClasslike):
pass

class PHPClassMember(BaseObject, php.PhpClassmember):
pass

class PHPGlobalLevel(BaseObject, php.PhpGloballevel):
pass

# ----------------------------------------------------------------------------

if cs is not None:
class CSharpCurrentNamespace(BaseObject, cs.CSharpCurrentNamespace):
pass
Expand Down Expand Up @@ -239,12 +259,13 @@ class DomainDirectiveFactory:

if php is not None:
php_classes = {
'function': (php.PhpNamespacelevel, 'function'),
'class': (php.PhpClasslike, 'class'),
'attr': (php.PhpClassmember, 'attr'),
'method': (php.PhpClassmember, 'method'),
'global': (php.PhpGloballevel, 'global'),
'function': (PHPNamespaceLevel, 'function'),
'class': (PHPClassLike, 'class'),
'attr': (PHPClassMember, 'attr'),
'method': (PHPClassMember, 'method'),
'global': (PHPGlobalLevel, 'global'),
}
php_classes_default = php_classes['class'] # Directive when no matching ones were found

if cs is not None:
cs_classes = {
Expand Down Expand Up @@ -291,8 +312,12 @@ def create(domain: str, args) -> ObjectDescription:
else:
if arg_0 in ['variable']:
arg_0 = 'global'
cls, name = DomainDirectiveFactory.php_classes.get(
arg_0, (php.PhpClasslike, 'class'))

if arg_0 in DomainDirectiveFactory.php_classes:
cls, name = DomainDirectiveFactory.php_classes[arg_0] # type: ignore
else:
cls, name = DomainDirectiveFactory.php_classes_default # type: ignore

elif cs is not None and domain == 'cs':
cls, name = DomainDirectiveFactory.cs_classes[args[0]] # type: ignore
else:
Expand Down
6 changes: 6 additions & 0 deletions documentation/source/directives.rst
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ Config Values
"h" : "cpp",
}

You can also use this to enable support for Doxygen XML generated from PHP code::

breathe_domain_by_extension = {
"php" : "php",
}

.. confval:: breathe_domain_by_file_pattern

Allows you to specify domains for particular files by wildcard syntax. This
Expand Down