pydoc output control for doctest cases
Đang mở
Chưa có ai nhận issue này.
stdlib
type-feature
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Feature or enhancement
#File: pydoc_end_demo.py
"""
I very much appreciate both the doctest and the pydoc features of python for small developement
tasks with minimum overhead.
A slight enhancement to pydoc as proposed in this example would further increase the usefulness.
"""
def rotated( sequence, distance=1 ): # example to demonstrate the <pydoc-end> proposal
""" Returns sequence rotated by distance number of elements.
Examples: # small number of test cases (to be included in the pydoc output) show the use of the function
>>> rotated( ( "one", "two", "three", "four" ) )
('four', 'one', 'two', 'three')
>>> rotated( [ 2, 3, 5, 7, 11, 13 ], 2 )
[11, 13, 2, 3, 5, 7]
>>> rotated( "abcdefgh", -3 )
'defghabc'
<pydoc-end> # the proposed indicator string instructs pydoc to stop ouput here ((for this docstring))
Doctests: # exhaustive number of further test cases - not relevant for the api user
# but needed for test quality - without the proposal the test cases clutter the pydoc output
>>> rotated( "abcde", 0 )
'abcde'
>>> rotated( "abcde", 5 ) # abs(distance) == len(sequence)
'abcde'
>>> rotated( "abcde", -5 )
'abcde'
>>> rotated( "abcde", 6 ) # abs(distance) > len(sequence)
'eabcd'
>>> rotated( "abcde", -6 )
'bcdea'
>>> rotated( "", 5 ) # empty sequence
''
>>> rotated( [], -3 )
[]
"""
length = len(sequence)
if length == 0: return sequence
dist = distance % length
return sequence[-dist:] + sequence[:-dist]
if __name__ == "__main__":
# run the doctest cases:
print( ">>> doctest >>>" )
import doctest
doctest.testmod()
print( "<<< doctest <<<" )
Pitch
extensive doctest cases will no more clutter pydoc output: A single source file is sufficient for concise user docu as well as for comprehensive doctest cases.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng việc kiểm tra hành vi được đề xuất trong pydoc_end_demo.py và cách các entry point của pydoc và doctest hiện xử lý docstring. Xác định tương tác dự kiến giữa marker được đề xuất và các trường hợp doctest, sau đó bổ sung coverage cho thấy tài liệu ngắn gọn vẫn hiển thị trong khi các ví dụ phía sau vẫn có thể được kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- documentation
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100