我不确定问题究竟在哪里。
我开发了一个名为hwrt
的Python包,它在pythonhosted.org(setuputils会自动放置它的官方网站)上托管其文档。
我让Sphinx自动从docstrings生成文档。某些模块文档字符串包含数学,如features.py
中的以下文档字符串:
"""Take the first ``points_per_stroke=20`` points coordinates of the first
``strokes=4`` strokes as features. This leads to
:math:`2 \cdot \text{points\_per\_stroke} \cdot \text{strokes}`
features.
If ``points`` is set to 0, the first ``points\_per\_stroke`` point
coordinates and the \verb+pen_down+ feature is used. This leads to
:math:`3 \cdot \text{points_per_stroke}` features."""
但是当我转到https://pythonhosted.org/hwrt/features.html#hwrt.features.ConstantPointCoordinates时,它不会显示mathjax的数学运算。为什么会这样,我该如何解决?
我的conf.py
代表狮身人面像
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax'
]
答案 0 :(得分:6)
请参阅Sphinx documentation on math support以获取以下句子:
请记住,当您在Python docstrings中读取数学标记时 通过autodoc,你要么必须加倍所有的反斜杠,要么使用Python 原始字符串(r" raw")。
遵循这个建议你必须改变你的第一个数学句子,例如
:math:`2 \\cdot \\text{points\\_per\\_stroke} \\cdot \\text{strokes}`
<强>更新强>
您的问题是您访问pythonhosted
而不是https
,但尝试在http
上加载mathjax文件,默认情况下会阻止该文件。请参阅Chrome控制台中的错误消息
页面在 &#39; https://pythonhosted.org/hwrt/features.html#hwrt.features.ConstantPointCoordinates&#39; 是通过HTTPS加载的,但运行的是不安全的内容 &#39; http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&#39 ;: 此内容也应通过HTTPS加载。
尝试将https://pythonhosted.org/hwrt/features.html#hwrt.features.ConstantPointCoordinates更改为http://pythonhosted.org/hwrt/features.html#hwrt.features.ConstantPointCoordinates 一切都显示得很好。
解决方案是您不进行硬编码,但省略了导入的JavaScript库的协议。不使用http://cdn.mathjax.org/...
运行外部JavaScript,而只使用//cdn.mathjax.org/...
有关详细信息,请参阅this question on SO和http://blog.jonathanoliver.com/http-and-https-with-google-cdn/
另一个准确解决问题的来源是https://github.com/MDAnalysis/mdanalysis/issues/182