简体   繁体   中英

sphinx: internal short reference to python class

How can I achieve something like this in sphinx?

Creates a `ClassName`_ instance.

.. _ClassName: :class:`~very.long.path.to.ClassName`

I would like to have short links to long class/methods/etc references in order to make my documentation more readable.

The best way I've found so far to reduce the length of my python references is to use the current module directive:

.. py:currentmodule:: very.long.path.to.package

This is my :class:`~module_in_package.ClassName`. 

I had the same problem, but I finally got things to work using reST Substitutions . Try this:

Creates a |ClassName| instance.

.. |ClassName| replace:: :class:`~very.long.path.to.ClassName`

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