2

I have decided to use autosummary to create documentation of my module. In index.rst I have "imported" all relevant modules and submodules that I want documentation on. The modules are documented as expected, but one thing bothers me. The module paths are rather long, and they look repulsive in the toctree next to the documentation.

index.rst

Documentation
*************

Documentation of things.

.. toctree::

.. autosummary::
   :toctree: _autosummary

   module
   module.submodule
   module.submodule.sub

   module.long_submodule.sub_1
   module.long_submodule.sub_2
   module.long_submodule.sub_3
   module.long_submodule.sub_4

conf.py

project = 'Name'
author = 'Me'
version = '0.7'

extensions = ['sphinx.ext.autodoc', 'sphinxcontrib.fulltoc', 'sphinx.ext.autosummary']
templates_path = ['_templates']
autosummary_generate = True
master_doc = 'index'

Is there a way to rename the entries in the navigation bar, preferably in index.rst? I would also be willing to consider changing the approach from autosummary to some other system if that accomplishes the task.


I have also used a custom template for the modules named _templates/autosummary/module.rst. Its contents are as follows:

{{ fullname }}
{{ underline }}

.. automodule:: {{ fullname }}
   :members:
   :undoc-members:
   :show-inheritance:
bad_coder
  • 11,289
  • 20
  • 44
  • 72
Felix
  • 2,548
  • 19
  • 48

1 Answers1

0

One can extend sys.path to import submodules without refering to the parent. In conf.py:

import sys
sys.path.insert(0, 'D:/abs/path/to/module')

Then change module.long_sub.etc to long_sub.etc in index.rst. One can insert directories inside the root folder (e.g. D:/abs/path/to/module/long_sub) to have even shorter imports.

Felix
  • 2,548
  • 19
  • 48