Hejhej
Hejhej

Reputation: 1

List dictionaries in documentation with Sphinx

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!

Upvotes: 0

Views: 2266

Answers (1)

jbndlr
jbndlr

Reputation: 5210

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.'''

Upvotes: 2

Related Questions