Background

I have a project called ciscoconfparse, which is documented with Sphinx; the documentation for the project is here.

The source code directory has multiple files:

  • ciscoconfparse.py contains the classes CiscoConfParse and IOSConfigList
  • models_cisco.py contains a class called IOSCfgLine

This is an example of how I'm documenting IOSCfgLine...

.. module:: models_cisco

IOSCfgLine Object
-----------------

.. autoclass:: IOSCfgLine
      :members:
      :inherited-members:

The existing Sphinx documentation has class hyperlinks that are hideous, including both the file name and the class name; one example is models_cisco.IOSCfgLine.

Example documentation screenshot: enter image description here

Question

How can I use autoclass to document classes in the various Python files and only see the class name in the rendered documentation, instead of the file name included with the class? In other words, I just want to see hyperlinks to IOSCfgLine instead of models_cisco.IOSCfgLine.

有帮助吗?

解决方案

To only see the the name itself in links, you can use the ~ in links:

:class:`~models_cisco.IOSCfgLine`

this will render as IOSCfgLine instead of models_cisco.IOSCfgLine.


But as, if I see it correctly in your codebase, all classes are available in the toplevel package name space. So you can also document them like that (so without the .. module:: models_cisco, but .. module:: ciscoconfparse).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top