我已经为我的项目安装了 django sphinx。成功安装和 sphinx 快速启动操作后,我尝试使用命令“make html”在“build”文件夹中创建 html,它给了我错误“make: * No rule to make target `html'。停止。”。任何帮助..提前致谢。
Sphinx(http://sphinx-doc.org/index.html)使用重组文本来定义内容.有指令显示来自本地文件系统的图像(使用相对和绝对路径).
我希望能够做的是使用URL声明图像并将其显示为内嵌.我能看到这一点的唯一方法是指定原始HTML,这看起来有点粗糙.有没有替代方案 - 也许是另一个"隐藏"指令或插件来支持这个?
我需要这个的原因是我有很多图像.如果我将它们存储在github上,我将强迫我的用户下载相当大的文件进行同步.我很欣赏我会失去Sphinx警告丢失文件的好处.
我正在将 Sphinx 与 reStructuredText 结合使用。我可以使用反引号来创建内联文字,例如
This is an ``object``
Run Code Online (Sandbox Code Playgroud)
=> 这是一个object.
但是,如果内联文字后面紧跟着一个字母,则反引号文本不会呈现为内联文字
They are ``object``s.
Run Code Online (Sandbox Code Playgroud)
=> 它们是“对象”。
如何才能得到下面想要的渲染效果?
=> 他们是objects。
我正在尝试处理 XML 文件,但出现此错误:
XPathEvalError: Undefined namespace prefix
Run Code Online (Sandbox Code Playgroud)
在这一行:
print "category =", item.xpath("./g:google_product_category")
Run Code Online (Sandbox Code Playgroud)
这是 XML 文件:
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>example.net.br</title>
<link>http://www.example.net.br/</link>
<description>Data feed description.</description>
<item>
<title>
<![CDATA[
example
]]>
</title>
<link>
<![CDATA[
example
]]>
</link>
<description>
<![CDATA[
example]]>
</description>
<g:google_product_category>
<![CDATA[
example
]]>
</g:google_product_category>
...
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
headers = { 'User-Agent' : 'Mozilla/5.0' }
req = urllib2.Request(feed_url, None, headers)
file = urllib2.urlopen(req).read()
file = etree.fromstring(file)
for item in file.xpath('/rss/channel/item'):
print "title =", item.xpath("./title/text()")[0]
print "link =", item.xpath("./link/text()")[0]
print "description =", item.xpath("./description/text()")[0] …Run Code Online (Sandbox Code Playgroud) 我正在使用 python 和 lxml 库从头开始创建一个新的 xml 文件。
<route xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.xxxx" version="1.1"
xmlns:stm="http://xxxx/1/0/0"
xsi:schemaLocation="http://xxxx/1/0/0 stm_extensions.xsd">
Run Code Online (Sandbox Code Playgroud)
我需要将此命名空间信息作为路由标记的属性包含在根标记中。
我无法将信息包含在根声明中。
from lxml import etree
root = etree.Element("route",
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance",
xmlns = "http://www.xxxxx",
version = "1.1",
xmlns: stm = "http://xxxxx/1/0/0"
)
Run Code Online (Sandbox Code Playgroud)
有一个 SyntaxError: invalid syntax
我怎样才能做到这一点 ?
是否可以在 Sphinx 生成的文档中为方法组添加文档字符串?
例如,我想要这样的东西:
class MyClass():
"""Doc of the class"""
def __init__(self):
pass
"""----- The following part is about imports -----"""
def import_from_source_1(self):
"""Doc of import_from_source_1"""
pass
def import_from_source_2(self):
"""Doc of import_from_source_2"""
pass
"""----- The following part is about exports-----"""
def export_to_dest_1(self):
"""Doc of export_to_dest_1"""
pass
def export_to_dest_2(self):
"""Doc of export_to_dest_2"""
pass
Run Code Online (Sandbox Code Playgroud)
预期输出将是:
MyClass
Doc of the class
----- The following part is about imports -----
import_from_source_1
Doc of import_from_source_1
import_from_source_2
Doc of import_from_source_2
----- The following part is about …Run Code Online (Sandbox Code Playgroud) 使用 Sphinx,可以在构建输出的 _static 文件夹中包含静态文件。如何将静态文件复制到构建文件夹的根目录?
背景:我在 Azure 应用服务中托管 Sphinx 项目的输出,并且由于几页中有 mp4 视频,我需要一个包含以下条目的“web.config”文件:
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>
Run Code Online (Sandbox Code Playgroud)
我需要 Sphinx 将 web.config 包含在构建文件夹的根目录中。
我有一个关于 Sphinx 自动文档生成的问题。我觉得我想做的事情应该很简单,但由于某种原因,它不起作用。
我有一个 Python 项目,其目录名为slotting_tool。该目录位于C:\Users\Sam\Desktop\picnic-data-shared-tools\standalone\slotting_tool
我使用sphinx-quickstart. 那么我的目录结构(简化)如下:
slotting_tool/
|_ build/
|_ source/
|___ conf.py
|___ index.rst
|_ main/
|___ run_me.py
Run Code Online (Sandbox Code Playgroud)
现在,我slotting_tool通过将以下内容添加到conf.py文件中来设置项目的根目录。
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
Run Code Online (Sandbox Code Playgroud)
接下来,我将我的index.rst文件更新为如下所示:
.. toctree::
:maxdepth: 2
:caption: Contents:
.. automodule:: main.run_me
:members:
Run Code Online (Sandbox Code Playgroud)
尝试使用该sphinx-build -b html source .\build命令构建我的 html 时,我得到以下输出,并显示no module named错误:
(base) C:\Users\Sam\Desktop\picnic-data-shared-tools\standalone\slotting_tool>sphinx-build -b html source .\build
Running Sphinx v1.8.1
loading pickled environment... done
building [mo]: targets for …Run Code Online (Sandbox Code Playgroud) 我正在尝试从此处运行代码来下载所有 S&P 500 股票:
https://pythonprogramming.net/sp500-company-price-data-python-programming-for-finance/
import bs4 as bs
import datetime as dt
import os
import pandas_datareader.data as web
import pickle
import requests
def save_sp500_tickers():
resp = requests.get('http://en.wikipedia.org/wiki/List_of_S%26P_500_companies')
soup = bs.BeautifulSoup(resp.text, 'lxml')
table = soup.find('table', {'class': 'wikitable sortable'})
tickers = []
for row in table.findAll('tr')[1:]:
ticker = row.findAll('td')[0].text
tickers.append(ticker)
with open("sp500tickers.pickle", "wb") as f:
pickle.dump(tickers, f)
return tickers
# save_sp500_tickers()
def get_data_from_yahoo(reload_sp500=False):
if reload_sp500:
tickers = save_sp500_tickers()
else:
with open("sp500tickers.pickle", "rb") as f:
tickers = pickle.load(f)
if not os.path.exists('stock_dfs'):
os.makedirs('stock_dfs') …Run Code Online (Sandbox Code Playgroud) 我创建了一个带有指令的网格表:
..table:: *Table 1: Power Connector*
:align: center
Run Code Online (Sandbox Code Playgroud)
这是结果:
最大的问题是如何将标题“表 1:电源连接器”移动到表格下方,有什么技巧吗?我确信有,只是请不要深入研究 Sphinx 的源代码,给我一些简单的角色或可以做到这一点的东西(CSS 或其他东西),理想情况下,一个内置角色,如:align:
对于一款流行的文档软件来说,Sphinx确实缺乏很多高级的解释。:align:在对 Sphinx 本身的 python 源代码进行了一系列修改之前,我几乎没有找到该指令。拜托,Sphinx只是学习Python的借口吗?