Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 指定Sphinx(restructuredtext)格式的联机图像_Image_Python Sphinx_Restructuredtext_Directive - Fatal编程技术网

Image 指定Sphinx(restructuredtext)格式的联机图像

Image 指定Sphinx(restructuredtext)格式的联机图像,image,python-sphinx,restructuredtext,directive,Image,Python Sphinx,Restructuredtext,Directive,关于如何在使用Sphinx进行文档记录时参考在线图像,有什么想法吗 这不起作用: .. image:: http://www.mysite.com/images/someimage.png 给我: /home/user/proj/2010/11/08/the_forever_war.rst:11: WARNING: nonlocal image URI found: http://www.mysite.com/images/someimage.png 谢谢…这真让人尴尬 正如德尔南在评论中提

关于如何在使用Sphinx进行文档记录时参考在线图像,有什么想法吗

这不起作用:

.. image:: http://www.mysite.com/images/someimage.png
给我:

/home/user/proj/2010/11/08/the_forever_war.rst:11: WARNING: nonlocal image URI found: http://www.mysite.com/images/someimage.png

谢谢…

这真让人尴尬

正如德尔南在评论中提到的,我只得到一个警告

在我的辩护中,我在确定image指令之前尝试了一些非常复杂的raw指令,我只是在查看Sphinx的输出,而不是在渲染页面上。当我看到Sphinx的长输出时,我认为我又遇到了另一个错误


尽管如此,我还是应该受到责备。。。图像加载良好。

我使用原始html代码,例如:

.. raw:: html

   <p style="height:22px">
     <a href="https://travis-ci.org/aio-libs/aiozmq" >
       <img src="https://travis-ci.org/aio-libs/aiozmq.svg?branch=master"/>
     </a>
   </p>
。。原始::html

从sphinx 1.4开始,您可以从
docs/conf.py
文件中“猴子补丁”sphinx,如下所示:

import sphinx.environment
from docutils.utils import get_source_line

def _warn_node(self, msg, node, **kwargs):
    if not msg.startswith('nonlocal image URI found:'):
        self._warnfunc(msg, '%s:%s' % get_source_line(node), **kwargs)

sphinx.environment.BuildEnvironment.warn_node = _warn_node
此答案的早期版本提供了与最新sphinx 1.4版本不兼容的修补程序[1]。此外,sphinx的下一版本应支持此配置选项[2]:

suppress_warnings = ['image.nonlocal_uri']
这将排除“找到非本地图像URI”的任何警告

我发现这是必要的,因为我希望
sphinx构建-W
能够 将“警告作为错误”作为我的测试和构建基础结构的一部分发出, 为了确保文档中没有错误 非常清楚我使用的是非本地图像URI,我同意 但是我不想忽视其他警告

[1]


[2]

您显示它会发出警告,但没有任何迹象表明它不起作用。事实上,它表示对它有一些支持(它识别URI),但不推荐使用。这种格式允许在没有警告的情况下使用外部图像,这允许在像travis/tox这样的连续集成套件中使用
sphinx build-W
(将警告转化为错误)。但是,GitHub上的RST解析器忽略
raw::html
:(我的sphinx文档中不包含README.rst,也不希望有人查看我的/docs目录——GitHub破坏了sphinx标记。虽然这样可以避免错误,但PyPi不会呈现它。它只是转储丑陋的
.raw::html
语句,而不是显示travis图标。因此@anonymousepythonhacker建议的猴子补丁可能是错误的。)如果你正在做这个特定的事情,那就是链接到自述文件中的travis状态图像。这是可行的,但会破坏Sphinx>1.3,因为警告会导致异常(例如,如果链接的引用不存在)。需要稍微修改它以接受kwargs**。更多信息:这里是另一个猴子补丁