mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
In Python 3, the default encoding of source files is utf-8. The encoding cookie is now unnecessary and redundant so remove it. For more details, see the docs: https://docs.python.org/3/howto/unicode.html#the-string-type > The default encoding for Python source code is UTF-8, so you can > simply include a Unicode character in a string literal ... Includes a fix for the flake8 header checks to stop expecting an encoding cookie.
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
"""
|
|
test_util_docstrings
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Test sphinx.util.docstrings.
|
|
|
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
|
:license: BSD, see LICENSE for details.
|
|
"""
|
|
|
|
from sphinx.util.docstrings import prepare_docstring, prepare_commentdoc
|
|
|
|
|
|
def test_prepare_docstring():
|
|
docstring = """multiline docstring
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
|
sed do eiusmod tempor incididunt ut labore et dolore magna
|
|
aliqua::
|
|
|
|
Ut enim ad minim veniam, quis nostrud exercitation
|
|
ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
"""
|
|
|
|
assert (prepare_docstring(docstring) ==
|
|
["multiline docstring",
|
|
"",
|
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit,",
|
|
"sed do eiusmod tempor incididunt ut labore et dolore magna",
|
|
"aliqua::",
|
|
"",
|
|
" Ut enim ad minim veniam, quis nostrud exercitation",
|
|
" ullamco laboris nisi ut aliquip ex ea commodo consequat.",
|
|
""])
|
|
assert (prepare_docstring(docstring, 5) ==
|
|
["multiline docstring",
|
|
"",
|
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit,",
|
|
"sed do eiusmod tempor incididunt ut labore et dolore magna",
|
|
"aliqua::",
|
|
"",
|
|
"Ut enim ad minim veniam, quis nostrud exercitation",
|
|
" ullamco laboris nisi ut aliquip ex ea commodo consequat.",
|
|
""])
|
|
|
|
docstring = """
|
|
|
|
multiline docstring with leading empty lines
|
|
"""
|
|
assert (prepare_docstring(docstring) ==
|
|
["multiline docstring with leading empty lines",
|
|
""])
|
|
|
|
docstring = "single line docstring"
|
|
assert (prepare_docstring(docstring) ==
|
|
["single line docstring",
|
|
""])
|
|
|
|
|
|
def test_prepare_commentdoc():
|
|
assert prepare_commentdoc("hello world") == []
|
|
assert prepare_commentdoc("#: hello world") == ["hello world", ""]
|
|
assert prepare_commentdoc("#: hello world") == [" hello world", ""]
|
|
assert prepare_commentdoc("#: hello\n#: world\n") == ["hello", "world", ""]
|