2017-10-03 5 views
0

私はnumpyのドキュメントストリングのガイドラインに従って私のドキュメントストリングを書いています。それから、私はドキュメントを生成するためにsphinxのautodocを使用します。いくつかのドキュメントストリングの中で私はLaTeX式(sphinx.ext.mathjax)を使用しています。 \rは新しい行のような特別な意味を持つようです。次のコマンドがある場合:スフィンクスには何かがありますか?

""" 
This :math:`\langle a, b\rangle` denotes the dot product of a and b 
""" 

正しく表示されません。 インラインで解釈されるテキストまたはフレーズ参照の開始文字列(末尾文字列なし) \ rangleを\ langleに置き換えると、すべて正常に動作します。これをどうすれば解決できますか?そこ

r""" 
This :math:`\langle a, b\rangle` denotes the dot product of a and b 
""" 

+1

はスフィンクスだけではなく、法的SphinxQLスペースになりましhttp://sphinxsearch.com/bugs/view.php?id=332 – planet260

+0

です - '\ r'は多くの場所での改行文字です。コメントのために – jonrsharpe

+0

@ planet260 thxしかし、どうすればこの作業をすることができますか? – math

答えて

1

ソリューションは、ダブルスラッシュでエスケープするか、トリプル引用符の中から(引用符なし)「R」を配置することで、これは引用符内のスラッシュの解釈を無効にします文字列リテラルの定義に影響するいくつかの接頭辞です(documentation of Pythonを参照)。

関連抜粋:

The backslash() character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character.

とr \

Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and treat backslashes as literal characters. As a result, in string literals, '\U' and '\u' escapes in raw strings are not treated specially.

関連する問題