module sphinxext.import_object_helper
¶
Short summary¶
module pyquickhelper.sphinxext.import_object_helper
Defines a sphinx extension which if all parameters are documented.
Classes¶
class |
truncated documentation |
---|---|
Functions¶
function |
truncated documentation |
---|---|
Extracts an object defined by its name including the module name. |
|
Extracts an object defined by its name including the module name. |
|
Determines the import path which is the shortest way to import the function. In case the following |
Properties¶
property |
truncated documentation |
---|---|
|
Static Methods¶
staticmethod |
truncated documentation |
---|---|
|
Documentation¶
Defines a sphinx extension which if all parameters are documented.
- pyquickhelper.sphinxext.import_object_helper.import_any_object(docname, use_init=True, fLOG=None) Tuple[object, str, str] [source]¶
Extracts an object defined by its name including the module name.
- Parameters:
docname – full name of the object (example:
pyquickhelper.sphinxext.sphinx_docassert_extension.import_object
)use_init – return the constructor instead of the class
fLOG – logging function
- Returns:
tuple(object, name, kind)
- Raises:
ImportError if unable to import
Kind is among
'function'
or'class'
or'kind'
.
- pyquickhelper.sphinxext.import_object_helper.import_object(docname, kind, use_init=True, fLOG=None) Tuple[object, str] [source]¶
Extracts an object defined by its name including the module name.
- Parameters:
docname – full name of the object (example:
pyquickhelper.sphinxext.sphinx_docassert_extension.import_object
)kind –
'function'
or'class'
or'kind'
use_init – return the constructor instead of the class
fLOG – logging function
- Returns:
tuple(object, name)
- @raises RuntimeError if cannot be imported,
TypeError if it is a method or a property, ValueError if kind is unknown.
- pyquickhelper.sphinxext.import_object_helper.import_path(obj, class_name=None, err_msg=None, fLOG=None)[source]¶
Determines the import path which is the shortest way to import the function. In case the following
from module.submodule import function
works, the import path will bemodule.submodule
.- Parameters:
obj – object
class_name – Python does not really distinguish between static method and functions. If not None, this parameter should contain the name of the class which holds the static method given in obj
err_msg – an error message to display if anything happens
fLOG – logging function
- Returns:
import path
- Raises:
TypeError if object is a property, RuntimeError if cannot be imported
The function does not work for methods or properties. It raises an exception or returns irrelevant results.