Failure to parse docstrings where a section contains header-like content

オープン
#640 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
documentation

調査の方向性

NumpyDocStringのエントリポイントから開始し、提供されたwrapper docstring reproducerをバージョン1.9.0に対して実行します。セクションの解析中にインデントされたヘッダーのような内容がどのように認識されるかを追跡し、ネストされたParametersのテキストが通常の内容として扱われ、重複セクションエラーを発生させないことを示すカバレッジを追加します。

索引モデルが issue の本文から書いたものです。

説明

numpydoc.docscrape.NumpyDocString in version 1.9.0 fails to parse docstrings if there is content within a section that resembles a section header, e.g. the "Parameters\n----------" contains " Parameters\n----------"

Example reproducer: a function that takes a function as an argument and returnsanother function. The following docstring explains the returned function:

def wrapper(func):
    '''
    Wrap a simple function so that it takes a message string that gets printed to stdout when invoked.

    Parameters
    ----------
    func: function
        Function to be wrapped. This can be any arbitrary synchronous function.

    Returns
    -------
    wrapped_function: function
        The returned function has the following signature::

            wrapped_function(
                message,
                *args,
                *kwargs,
            )
                \'\'\'
                Parameters
                ----------
                message: str
                A custom message to be printed when the wrapped function is called.
                *args
                    Additional arguments that are passed into the original function.
                **kwargs
                    Extra arguments to the original function.
                \'\'\'
    '''

However, when using numpydoc.docscrape.NumpyDocString to parse this docstring, for example:

parsed = NumpyDocString(<example docstring above>)

...an exception is raised claiming to have duplicate Parameters section:

ValueError: The section `Parameters` appears twice in  
Wrap a simple function so that it takes a message string that gets printed to stdout when invoked.

The desired behavior is to treat the nested Parameters "section" as regular content and not an actual section.

主要言語
Python
スター
354
フォーク
185
平均マージ
4分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

numpy/numpydoc のほかの issue

numpy/numpydoc の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。