标签: python-sphinx

如何在Sphinx文档中添加自定义页脚?(reStructuredText的)

如果我有一些文档,例如Galleria的文档,我该如何设置它以便在运行make html命令时它会在每个页面上添加一个自定义页脚?

我看到如果我将它输出为pdf格式,我可能会使用conf.py 的latex前言部分.

谢谢!

unix linux restructuredtext makefile python-sphinx

22
推荐指数
1
解决办法
5570
查看次数

如何配置Sphinx有条件地排除某些页面?

使用Sphinx生成文档时,我希望能够生成两个版本的文档:一个包含所有内容,另一个只包含一组特定页面.实现这一目标的最佳方法是什么?

我可以编写一个构建脚本来移动文件来实现这一点,但如果有一种方法可以告诉sphinx在特定构建期间排除或包含特定文档,那将会非常好.

python documentation python-sphinx

22
推荐指数
3
解决办法
6468
查看次数

使用sphinx自动记录python类,模块

我已经安装了Sphinx,以便记录一些我正在研究的python模块和类.虽然标记语言看起来非常好,但我还是没有设法自动记录python代码.

基本上,我有以下python模块:

SegLib.py
Run Code Online (Sandbox Code Playgroud)

还有一个叫它的班级Seg.我想在生成的sphinx文档中显示类和模块的文档字符串,并为其添加更多格式化文本.

index.rst看起来像这样:

Contents:

.. toctree::
:maxdepth: 2

chapter1.rst
Run Code Online (Sandbox Code Playgroud)

并且chapter1.rst:

This is a header
================
Some text, *italic text*, **bold text**

* bulleted list.  There needs to be a space right after the "*"
* item 2

.. note::
   This is a note.

See :class:`Seg`
Run Code Online (Sandbox Code Playgroud)

但是Seg只是以粗体打印,而不是与类的自动生成的文档相关联.

尝试:参见:class:Seg Module:mod:'SegLib'模块:mod:'SegLib.py'

也没有帮助.任何想法或良好的教程链接?

编辑:将SegLib更改为段(感谢,iElectric!),并将chapter1.rst更改为 ::mod:segmentsModule ------------------------- -

.. automodule:: segments.segments

.. autoclass:: segments.segments.Seg
Run Code Online (Sandbox Code Playgroud)

但是,无法让sphinx直接记录类中的函数,或者更好 - 将类中的所有函数自动添加到文档中.试着

.. autofunction:: segments.segments.Seg.sid …
Run Code Online (Sandbox Code Playgroud)

python documentation-generation python-sphinx

21
推荐指数
1
解决办法
2万
查看次数

Sphinx文档中的条件输出

我正在为Sphinx编写一些文档,我想打印出一些仅用于HTML文档的文本块,而不是用于LaTeX文档.有些东西告诉我,我应该能够做到这一点,sphinx.ext.ifconfig但我无法弄清楚如何.有谁知道如何做到这一点?

python documentation python-sphinx

21
推荐指数
1
解决办法
3636
查看次数

如何使用Sphinx记录异常

我似乎无法弄清楚如何使用Sphinx记录异常.

我尝试过以下方法:

def some_funct():
    """
    :raises: ExceptionType: Some multi-line
        exception description.
    """


def some_funct():
    """
    :raises: ExceptionType, Some multi-line
        exception description.
    """


def some_funct():
    """
    :raises ExceptionType: Some multi-line
        exception description.
    """


def some_funct():
    """
    :raises:
        ExceptionType: Some multi-line
            exception description.
    """
Run Code Online (Sandbox Code Playgroud)

斯芬克斯一直说"场名列表没有空白线;意外的不连贯." 那么我如何摆脱信息以及用多行文档记录可能的多个异常的正确方法是什么?

python documentation exception python-sphinx

21
推荐指数
1
解决办法
1万
查看次数

如何在不创建任意标签的情况下在sphinx restructuredtext中创建标题的内部链接?

我有一份包含许多标题和小标题的文件.进一步在文本中我想链接回其中一个标题.如果没有:ref:标签的冗余,我怎么能这样做?内容似乎拿起标题就好了.我希望得到这样的东西:`#polled-data-retrieval`_.

restructuredtext python-sphinx

21
推荐指数
4
解决办法
1万
查看次数

是否有一个Sphinx reST Python docstring字段用于收益?

我正在尝试使用reST风格的文档字符串,即

def foo(bar):
    """a method that takes a bar

    :param bar: a Bar instance
    :type bar: Bar
Run Code Online (Sandbox Code Playgroud)

是否有标准的文件记录方式yields?我查看了http://sphinx-doc.org/domains.html#info-field-lists,a-la这个问题[ 使用javadoc for Python文档 ],但没有运气.我想象的是,

    :yields: transformed bars
    :yield type: Baz
Run Code Online (Sandbox Code Playgroud)

谢谢!

python documentation restructuredtext python-sphinx

21
推荐指数
2
解决办法
5636
查看次数

Make Read the Docs包括特殊成员的autodoc文档?

我有一个模块,有两个记录的全球特殊成员.

在本地运行Sphinx会创建包含其文档的文档,但"阅读文档"却没有.它使用内置类型的文档.

我尝试了两种样式:#:和定义后的docstring.我已多次阅读autodoc的文档,并阅读了文档条目.我无法弄清楚我缺少什么,因为我甚至没有看到阅读文档中的任何构建错误.

有任何想法吗?

python documentation python-sphinx autodoc read-the-docs

21
推荐指数
1
解决办法
423
查看次数

如何使用intersphinx正确编写外部文档的交叉引用?

我正在尝试将外部API的交叉引用添加到我的文档中,但我面临三种不同的行为.

我正在使用sphinx(1.3.1)和Python(2.7.3),我的intersphinx映射配置为:

{
'python': ('https://docs.python.org/2.7', None),
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
'cv2' : ('http://docs.opencv.org/2.4/', None),
'h5py' : ('http://docs.h5py.org/en/latest/', None)
}
Run Code Online (Sandbox Code Playgroud)

我可以毫不费力地编写numpy API的交叉引用,:class:`numpy.ndarray`或者:func:`numpy.array`像我们预期的那样给我一些像numpy.ndarray这样的东西.

但是,使用h5py,我可以生成链接的唯一方法是省略模块名称.例如,:class:`Group`(或:class:`h5py:Group`)给我Group:class:`h5py.Group`无法生成链接.

最后,我找不到一种方法来编写一个工作交叉引用OpenCV API,这些似乎都没有工作:

:func:`cv2.convertScaleAbs`
:func:`cv2:cv2.convertScaleAbs`
:func:`cv2:convertScaleAbs`
:func:`convertScaleAbs`
Run Code Online (Sandbox Code Playgroud)

如何正确编写对外部API的交叉引用,或配置intersphinx,以便在numpy情况下生成链接?

python documentation opencv python-sphinx autodoc

21
推荐指数
3
解决办法
6585
查看次数

如何在第一个文档字符串中断链接以满足pep8?

我正在使用Sphinxdoc生成api文档,并且在编写docstring时遇到了pep8一致性问题.

如下所示,OWASP站点的链接在第105列结束,远远超过pep8规定的最大行长度

def handle_csrf(...):
    """The general recommendation by people in the know [OWASP]_, is
       'to implement the Synchronizer Token Pattern (STP_)'.

       .. [OWASP] The Open Web Application Security Project
          (https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet)
       .. _STP: http://www.corej2eepatterns.com/Design/PresoDesign.htm

    """
Run Code Online (Sandbox Code Playgroud)

有没有办法包装网址,同时仍然保持生成的文档中的URL?

插入反斜杠不起作用.

python restructuredtext pep8 python-sphinx

20
推荐指数
2
解决办法
3540
查看次数