Shorter name for the class link in Sphinx(Sphinx中类链接的较短名称)

本文介绍了Sphinx中类链接的较短名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.. seealso::

   Class :class:`apps.business.models.Department`
      Explanation goes here

   `GNU tar manual, Basic Tar Format <http://link>`_
      Documentation for tar archive files, including GNU tar extensions.

这将创建到类Department的适当链接。

如何将HTML输出更改为只有一个类名,而不使用‘apps.Bus.Models’前缀?

所以它以HTML显示ClassDepartment?

推荐答案

standard cross-referencing syntax中有~(波浪号)。

如果为内容添加前缀~,则链接文本将只是目标的最后一个组件。例如,

:py:meth:`~Queue.Queue.get`

将引用Queue.Queue.get,但仅显示get作为链接文本。这不适用于所有交叉引用角色,但特定于域。

还有.. currentmodule::和example in another SO answer指令.. currentmodule::

这篇关于Sphinx中类链接的较短名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!