如何在节点中使用rst?例如我要输出隐藏文件about.rst
class Foo(Directive):
def run(self):
return [
nodes.Text("**adad**"), # <-- Must be a bold text
nodes.Text(".. include:: about.rst"), # <-- Must include file
]
Run Code Online (Sandbox Code Playgroud) 我正在使用reStructured文本来创建一些简单的网站.所以我有很多*.rst文件,我想在其中添加Google Analytics代码.但据我所知,不可能添加这样的东西?!
我使用rst2html将文件转换为html.
我正在尝试使用DocUtils和reStructuredText注释SQL代码。当我在多行注释中包含标记时,可以使它起作用。然后,我使用--Some text ::来介绍每个代码块。
我无法使内部超链接正常工作。我想写-.. Step1_:但是解析器由于前导注释而忽略了这一点。使用多行样式也会失败。有没有办法让它工作?
这是一个例子:
/*
==========
this query
==========
:Author: Me
Outline
==========
- Create table 1
- Create table 2
- Output the result
*/
-- _Step1: build the table::
create table table1
-- _Step2: use Step1_ to build table 2::
create table table2
Run Code Online (Sandbox Code Playgroud) 我正在尝试添加带有外部链接的图像。
|facebook| |tw|
.. |facebook| image:: http://www.summerbounce.ca/wp-content/uploads/2012/11/facebook-logo-small.png
.. |tw| image:: http://www.summerbounce.ca/wp-content/uploads/2012/11/facebook-logo-small.png
Run Code Online (Sandbox Code Playgroud)
上面的代码显示了图像,但是如何将这些图像链接到外部站点?
谢谢!
当我看到这个(编辑)时,我正在查看docutil源代码(在python中):
def __init__(self, **attributes):
for att, value in attributes.items():
att = att.lower()
if att in self.list_attributes:
# mutable list; make a copy for this node
self.attributes[att] = value[:]
else:
self.attributes[att] = value
Run Code Online (Sandbox Code Playgroud)
我正在谈论的是这一行:
self.attributes[att] = value[:]
Run Code Online (Sandbox Code Playgroud)
"[:]"究竟做了什么?它上面的评论提示某种副本,但我的谷歌搜索并没有那么成功,我无法确定它是语言功能还是某种特技/快捷方式.
我在reStructuredText中有以下整洁的小表:
====== ======= ====== =====================
Symbol Meaning Type Example
====== ======= ====== =====================
G Era Text "GG" -> "AD"
y Year Number "yy" -> "03"
"yyyy" -> "2003"
M Month Text "M" -> "7"
or "M" -> "12"
Number "MM" -> "07"
"MMM" -> "Jul"
"MMMM" -> "December"
====== ======= ====== =====================
Run Code Online (Sandbox Code Playgroud)
根据关于简单表的Docutils文档,我希望Spinx生成的HTML表格在文本中生成,因此"yy"和"yyyy"将在不同的行上,就像"M","MM" " 等等.但结果如下:

我尝试了一些替代方法,比如在最后一列的开头使用管道(|),空行,缩进.我最接近的是在"yyyy"之前使用缩进.然后"yyyy"在下一行,但它是缩进的.当然我希望它与"yy"处于相同的缩进级别.
这是我第一次在 PyCharm 5.0 和 Python 3.5 中使用 Sphinx。
当我sphinx task在 PyCharm 中运行时,出现以下错误:
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0\helpers\docutils\__init__.py", line 63, in <module>
class ApplicationError(StandardError): pass
NameError: name 'StandardError' is not defined
Run Code Online (Sandbox Code Playgroud)
在这个页面上,我发现在 Python 3.xStandardError中现在被替换为Exception. 但是,当我尝试编辑__init__.py文件时,PyCharm 阻止我保存它。
我还注意到它__init__.py基于 docutils 0.8 版。这并不直观,因为我在我的 virtualenv 中安装了 docutils 0.12 版。这意味着版本 0.12 被忽略。
有谁知道如何解决这一问题?
我曾经在 readthedocs.io 服务器上保存一个项目文档。这是CoFEA Initiative 的链接
自 4 月 3 日以来,由于发布了新版本的 docutils 库,它看起来有点破损(例如,主徽标向左对齐,而它应该居中)。docutils 的最新版本是 0.17,这个特定的 Sphinx 主题在 0.16 版本之前工作得很好。
日志文件显示了它不工作的原因。首先,readthedocs服务器安装最新版本的docutils
Collecting docutils>=0.11
Downloading docutils-0.17-py2.py3-none-any.whl (575 kB)
Run Code Online (Sandbox Code Playgroud)
然后 Sphinx 主题尝试根据中定义的内容下载并安装特定版本的 docutilssetup.py
Installed /home/docs/checkouts/readthedocs.org/user_builds/cofea/envs/latest/lib/python3.7/site-packages/ipygany-0.5.0-py3.7.egg
Searching for docutils==0.16
Reading https://pypi.org/simple/docutils/
Downloading https://files.pythonhosted.org/packages/81/44/8a15e45ffa96e6cf82956dd8d7af9e666357e16b0d93b253903475ee947f/docutils-0.16-py2.py3-none-any.whl#sha256=0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af
Best match: docutils 0.16
Processing docutils-0.16-py2.py3-none-any.whl
Installing docutils-0.16-py2.py3-none-any.whl to /home/docs/checkouts/readthedocs.org/user_builds/cofea/envs/latest/lib/python3.7/site-packages
Run Code Online (Sandbox Code Playgroud)
我认为发生的情况是,当调用 Sphinx 命令时,它使用的是版本 0.17 而不是 0.16。
有没有办法强制为 Sphinx 使用 docutils 0.16 版本?
如何.rst使用实际值自定义文件中的占位符?
例如,我有example.rst以下内容的文件:
Header
------------------------------------
${custom_text}
Run Code Online (Sandbox Code Playgroud)
我想通过运行以下命令将${custom_text}属性替换为值this is the value of custom property:
rst2html example.rst -o example.html -Dcustom_text="this is the value of custom property"
Run Code Online (Sandbox Code Playgroud)
另外我想知道是否可以使用.properties文件自定义模板?例如,我想rst2html example.rst -o example.html -p example.properties使用example.properties包含以下内容的文件运行命令:
custom_text=this is the value of custom property
Run Code Online (Sandbox Code Playgroud)
可能吗?reStructuredText是否支持模板功能?
编辑:请注意我想从命令行或使用传统.properties文件(可以由Ant/Maven构建管理工具使用)自定义模板.
docutils ×9
python ×3
image ×1
markup ×1
pycharm ×1
python-3.x ×1
setup.py ×1
sql ×1
virtualenv ×1