5

最近、プロジェクトにドキュメントを追加し始め、Google スタイル ガイドに従おうとしています。私は Sphinx を使用してドキュメントを生成し、Sphinx 拡張 napoleon を使用して Google スタイルガイドと reST の間のギャップを埋めています。

パラメータとメモのレンダリングに問題はありませんが、サンプル セクションでコード スニペットをレンダリングできないようです。

class Chicken(object):
      """Animal that lays egg and has feathers

         Note:
             Chickens love to eat feed

         Example:
             chicken.eats(feed)
      """

例のセクションで二重コロンも試しました。

Example::
4

2 に答える 2

6

Example::セクション区切りとリテラル ブロックの間には、二重コロンと空白行が必要です。

Napoleon docsの例を参照してください。

"""Example Google style docstrings.

This module demonstrates documentation as specified by the `Google Python
Style Guide`_. Docstrings may extend over multiple lines. Sections are created
with a section header and a colon followed by a block of indented text.

Example:
    Examples can be given using either the ``Example`` or ``Examples``
    sections. Sections support any reStructuredText formatting, including
    literal blocks::

        $ python example_google.py

Section breaks are created by resuming unindented text. Section breaks
are also implicitly created anytime a new section starts.
"""

したがって、あなたの例では、これを試してください:

class Chicken(object):
      """Animal that lays egg and has feathers

         Note:
             Chickens love to eat feed

         Example::

             chicken.eats(feed)
      """
于 2017-07-07T14:30:04.673 に答える