English 中文(简体)
在Sphinx,我能否登记一些关键词,这些关键词应始终转化为联系?
原标题:In Sphinx, can I register a bunch of keywords that should always be translated into links?

我的训示中提到我所定义的其他假课。 每当Sphinx碰到其中一个班级时,我想加上另一个班级的文件链接。 这在Sphinx是否可行?

具体地说,我有这样一句 :

   This class contains a bunch of Foo objects   

我可以写:

   This class contains a bunch of :class:`~foo.Foo` objects   

but I would prefer that Sphinx finds all text matching Foo and makes it seem as though I had typed :class:~foo.Foo

最佳回答

你们可以使用宏观方法。

在我的项目中,我有一份标题文件,其中载有所有“进口”类别和全球职能及其简称。 两个例子:

.. |PostItem| replace:: :class:`PostItem <hklib.PostItem>`
.. |PostNotFoundError| replace:: :class:`PostNotFoundError <hklib.PostNotFoundError>`

在我的<代码>rst文档中,我包括这一标题。 然后,我可在任何<条码>r文档中使用这些宏观:

.. include:: defs.hrst

|PostItem| is a nice class. |PostNotFoundError|, on the other hand is not.

(你也可以使用<条码>autogen的延伸,从灰色源文档中进行探测。) 还将替换其中的Macros。

您的例子: 页: 1 Foo至头盔,并写明:

   This class contains a bunch of |Foo| objects   
问题回答

Sphinx在这方面具有大量解释性案文作用。

https://www.sphinx-doc.org/en/2.0/usage/reructdtext/domains.html# Cross-referencing-python-objects

我想进入“Foo”,并用Sphinx来解释,就像我写的:阶级:~foo”。 Foo

这种做法是不切实际的。 看来,它会瘫痪区域情报和安全局试图使你的案文瘫痪。 查阅解释性案文和《区域统计》支持的少数引用规则(>*>>>><>>>>/代码”是指实际限制。

您再次要求,可能会导致监管局全天检查每一例<代码>。 Foo,在一切可能情况下,并说明您是否希望建立联系。 您只想在未经更正的<编码>事例中这样做。 Foo;三角搜寻和替代 would。

你们能够用在前处理过程中的护卫。

这可能使你能够根据你的说明案文,尝试一项全球搜索和替代战略。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签