module sphinxext.import_object_helper

Short summary

module pyquickhelper.sphinxext.import_object_helper

Defines a sphinx extension which if all parameters are documented.

source on GitHub

Classes

class

truncated documentation

_Types

Functions

function

truncated documentation

import_any_object

Extracts an object defined by its name including the module name.

import_object

Extracts an object defined by its name including the module name.

import_path

Determines the import path which is the shortest way to import the function. In case the following from module.submodule import function

Properties

property

truncated documentation

prop

Static Methods

staticmethod

truncated documentation

stat

Documentation

Defines a sphinx extension which if all parameters are documented.

source on GitHub

class pyquickhelper.sphinxext.import_object_helper._Types[source][source]

Bases: object

pyquickhelper.sphinxext.import_object_helper.import_any_object(docname, use_init=True, fLOG=None) → Tuple[object, str, str][source][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'.

source on GitHub

pyquickhelper.sphinxext.import_object_helper.import_object(docname, kind, use_init=True, fLOG=None) → Tuple[object, str][source][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.

source on GitHub

pyquickhelper.sphinxext.import_object_helper.import_path(obj, class_name=None, err_msg=None, fLOG=None)[source][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 be module.submodule.

Parameters
  • obj – object

  • class_namePython 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.

Changed in version 1.8: Parameter err_msg was added.

source on GitHub