简体   繁体   中英

Python-Sphinx documentation: link source code

I have a dictionary that represent a schema (JSON-Schema to be more precise).

Sometimes the schema gets complex and in the documentation I need to link to it in order to give a better picture.

I have the viewcode extension enabled, I tried the following with no luck:

.. data:: netjsonconfig.backends.openvpn.schema.schema

.. automodule:: netjsonconfig.backends.openvpn.schema

The dictionary python path is netjsonconfig.backends.openvpn.schema.schema .

Is it possible to achieve this? If yes how?

Try this:

.. literalinclude:: your_json_filename.json
    :language: json

You can even select a part of this file to display by

.. literalinclude:: your_json_filename.json
    :language: json
    :lines: 18-43

This displays the lines 18 to 43 of your_json_filename.json .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM