'Sphinx - Specific file documentation with autosummary

I'm trying to use Sphinx's autosummary extension to generate the documentation automatically for the methods of a single file. I have the following folder structure on sphinx

-docs
  -source
    -api.rst
    -conf.py
-src
  -players
    -a.py
    -b.py

My api.rst is as follows

API
===

A
-
Description of file A
.. autosummary::
   :toctree: generated

   src.players.a

B
-
.. autosummary::
   :toctree: generated

   src.players.b

Where in file a.py and b.py I have a class with some methods documented using docstring.

What I would like is to see the class and its methods' documentation under each corresponding section, but I cannot make it work.

In my conf.py file I have added the following:

import sys
import os
sys.path.insert(0, os.path.abspath('../..'))

But it does not generate the documentation. I have also tried to include in the path the src/players folders, but no luck either.

In general, which is the preferred way to tell Sphinx where to find the code to be documented?

EDIT: The error it throws is the following

[autosummary] generating autosummary for: api.rst, index.rst, usage.rst
WARNING: [autosummary] failed to import src.players.a.
Possible hints:
* AttributeError: module 'src.players' has no attribute 'a'
* PycodeError: no source found for module 'src'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source