From 49b576298409df02669733ee8c6e64a335ec27b8 Mon Sep 17 00:00:00 2001 From: Pavel Korshunov <pavel.korshunov@idiap.ch> Date: Sun, 23 Oct 2016 15:47:53 +0200 Subject: [PATCH] Better fix of sphinx issue --- bob/bio/base/algorithm/__init__.py | 36 +++++++++++++++++++++------ bob/bio/base/database/__init__.py | 19 ++++++++++++++ bob/bio/base/extractor/__init__.py | 17 +++++++++++++ bob/bio/base/preprocessor/__init__.py | 17 +++++++++++++ 4 files changed, 82 insertions(+), 7 deletions(-) diff --git a/bob/bio/base/algorithm/__init__.py b/bob/bio/base/algorithm/__init__.py index 7e8b8411..d5e2f3fd 100644 --- a/bob/bio/base/algorithm/__init__.py +++ b/bob/bio/base/algorithm/__init__.py @@ -5,13 +5,35 @@ from .LDA import LDA from .PLDA import PLDA from .BIC import BIC -# to fix sphinx warnings of not being able to find classes, when path is shortened -Algorithm.__module__ = "bob.bio.base.algorithm" -Distance.__module__ = "bob.bio.base.algorithm" -PCA.__module__ = "bob.bio.base.algorithm" -LDA.__module__ = "bob.bio.base.algorithm" -PLDA.__module__ = "bob.bio.base.algorithm" -BIC.__module__ = "bob.bio.base.algorithm" +# # to fix sphinx warnings of not being able to find classes, when path is shortened +# Algorithm.__module__ = "bob.bio.base.algorithm" +# Distance.__module__ = "bob.bio.base.algorithm" +# PCA.__module__ = "bob.bio.base.algorithm" +# LDA.__module__ = "bob.bio.base.algorithm" +# PLDA.__module__ = "bob.bio.base.algorithm" +# BIC.__module__ = "bob.bio.base.algorithm" # gets sphinx autodoc done right - don't remove it +def __appropriate__(*args): + """Says object was actually declared here, and not in the import module. + Fixing sphinx warnings of not being able to find classes, when path is shortened. + Parameters: + + *args: An iterable of objects to modify + + Resolves `Sphinx referencing issues + <https://github.com/sphinx-doc/sphinx/issues/3048>` + """ + + for obj in args: obj.__module__ = __name__ + +__appropriate__( + Algorithm, + Distance, + PCA, + LDA, + PLDA, + BIC, + ) + __all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/bio/base/database/__init__.py b/bob/bio/base/database/__init__.py index 3c4f8673..f0d04d66 100644 --- a/bob/bio/base/database/__init__.py +++ b/bob/bio/base/database/__init__.py @@ -10,4 +10,23 @@ BioDatabase.__module__ = "bob.bio.base.database" ZTBioDatabase.__module__ = "bob.bio.base.database" # gets sphinx autodoc done right - don't remove it +def __appropriate__(*args): + """Says object was actually declared here, and not in the import module. + Fixing sphinx warnings of not being able to find classes, when path is shortened. + Parameters: + + *args: An iterable of objects to modify + + Resolves `Sphinx referencing issues + <https://github.com/sphinx-doc/sphinx/issues/3048>` + """ + + for obj in args: obj.__module__ = __name__ + +__appropriate__( + BioFile, + BioFileSet, + BioDatabase, + ZTBioDatabase, + ) __all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/bio/base/extractor/__init__.py b/bob/bio/base/extractor/__init__.py index deae933a..e8aab1a3 100644 --- a/bob/bio/base/extractor/__init__.py +++ b/bob/bio/base/extractor/__init__.py @@ -6,4 +6,21 @@ Extractor.__module__ = "bob.bio.base.extractor" Linearize.__module__ = "bob.bio.base.extractor" # gets sphinx autodoc done right - don't remove it +def __appropriate__(*args): + """Says object was actually declared here, and not in the import module. + Fixing sphinx warnings of not being able to find classes, when path is shortened. + Parameters: + + *args: An iterable of objects to modify + + Resolves `Sphinx referencing issues + <https://github.com/sphinx-doc/sphinx/issues/3048>` + """ + + for obj in args: obj.__module__ = __name__ + +__appropriate__( + Extractor, + Linearize, + ) __all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/bio/base/preprocessor/__init__.py b/bob/bio/base/preprocessor/__init__.py index fb7b2eb6..3f426657 100644 --- a/bob/bio/base/preprocessor/__init__.py +++ b/bob/bio/base/preprocessor/__init__.py @@ -6,4 +6,21 @@ Preprocessor.__module__ = "bob.bio.base.preprocessor" Filename.__module__ = "bob.bio.base.preprocessor" # gets sphinx autodoc done right - don't remove it +def __appropriate__(*args): + """Says object was actually declared here, and not in the import module. + Fixing sphinx warnings of not being able to find classes, when path is shortened. + Parameters: + + *args: An iterable of objects to modify + + Resolves `Sphinx referencing issues + <https://github.com/sphinx-doc/sphinx/issues/3048>` + """ + + for obj in args: obj.__module__ = __name__ + +__appropriate__( + Preprocessor, + Filename, + ) __all__ = [_ for _ in dir() if not _.startswith('_')] -- GitLab