0

I have a project with a few .py files that only contains a few dictionaries. Like this:

# My file
dictionary = {'key1': 'value1', 'key2: 'value2'}

But much larger and longer and I would like to document this with Sphinx but I can't get it to work properly.

The files are found by Sphinx just fine and show up under Modules as folder.file but they are all empty? What am I doing wrong? Why won't the dictionaries show up?

in the .rst file for the folder it shows:

    folder.file module
--------------------

.. automodule:: folder.file
    :members:
    :undoc-members:
    :show-inheritance:

Am I missing something? Thanks in advance!

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Hejhej
  • 1
  • 2

1 Answers1

2

Sphinx does require extra docstrings for all members that are not classes or methods. You probably don't want to edit autodoc (even though this can come handy for individualization under certain conditions), you can overcome this issue by adding a docstring below the variable:

# My file
dictionary = {'key1': 'value1', 'key2': 'value2'}
'''A dictionary containing secret values.

Do not expose this dictionary's values to the public. By default, the 
keys 'key1' and 'key2' are available.'''
jbndlr
  • 4,965
  • 2
  • 21
  • 31
  • 2
    You also can add comment before the dictionnary with this format: `#: `. but this is single line comment and the `#: ` has to be repeated for each line. http://www.sphinx-doc.org/en/stable/ext/autodoc.html#directive-autoattribute – Tryph Oct 12 '16 at 12:32