5

I'm using docstrings to document python code and sphinx-autodoc to generate apidoc HTMLs. The structure of my packages is as follows: mainpackage.subpackage.module, I want apidocs to link to classes from a module as mainpackage.subpackage.Class and not mainpackage.subpackage.module.Class. My problem comes from the scikit-multilearn project, for example: I have an MLClassifierBase class in skmultilearn.base.base, but I'm importing it in __init__.py in skmultilearn.base, and I want the sphinx-generated apidocs to only use this class as skmultilearn.base.MLClassifierBase and not skmultilearn.base.base.MLClassifierBase as it does now. Can someone help?

I've already tried:

I'm still having a Bases: skmultilearn.base.base.MLClassifierBase in every class that derives from MLClassifierBase. How do I change this?

mzjn
  • 48,958
  • 13
  • 128
  • 248
niedakh
  • 2,819
  • 2
  • 20
  • 19
  • 1
    Similar to http://stackoverflow.com/q/15115514/407651 and http://stackoverflow.com/q/30856279/407651 – mzjn Feb 14 '17 at 14:46

1 Answers1

3

I have found a solution:

"""
The :mod:`skmultilearn.base` module implements base
classifier classes for scikit-multilearn's multi-label classification.
"""

from .base import MLClassifierBase
from .problem_transformation import ProblemTransformationBase

__all__ = ["MLClassifierBase", 
           "ProblemTransformationBase"]

It produces documentation for base.ProblemTransformationBase and not base.base.ProblemTransformationBase. You need to have the three elements alltogether in your __init__.py:

  • the definition of :mod: mentioned anywhere
  • the imports of classes
  • the names of classes in `all``
niedakh
  • 2,819
  • 2
  • 20
  • 19