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

Đang mở
#640 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu với entry point của NumpyDocString và chạy wrapper docstring reproducer được cung cấp trên phiên bản 1.9.0. Theo dõi cách nội dung thụt lề giống tiêu đề được nhận diện khi phân tích các section, sau đó bổ sung coverage cho thấy văn bản Parameters lồng nhau vẫn là nội dung thông thường và không gây ra lỗi section trùng lặp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
354
Fork
185
Merge trung bình
4 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của numpy/numpydoc

Tất cả issue của numpy/numpydoc

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.