pydoc output control for doctest cases
未關閉
還沒有人認領這個 Issue。
stdlib
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
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.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先檢查 pydoc_end_demo.py 中提議的行為,以及 pydoc 和 doctest 入口點目前如何處理 docstring。確定提議的 標記與 doctest 案例之間預期的互動,然後新增涵蓋範圍,顯示簡潔的文件仍然可見,同時後續範例仍然可測試。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100