Commit Graph
2424 Commits
Author SHA1 Message Date
Jon Dufresne 43ff640b58 Deprecate quickstart.term_decode() and remove internal uses
Per the Python 3 docs, input() always returns a string:

https://docs.python.org/3/library/functions.html#input

> The function then reads a line from input, converts it to a
> string (stripping a trailing newline), and returns that.

The stubs from typeshed say the same:

https://github.com/python/typeshed/blob/5c69373890dfaf4f07f0638766fb0a4903352892/stdlib/3/builtins.pyi#L835

Here is the implementation from CPython with also shows a call to
PyUnicode_Decode on the result:

https://github.com/python/cpython/blob/3.7/Python/bltinmodule.c#L1960-L2143

As the value is always a string, there is nothing to decode. Therefore
the call to term_decode() unnecessary and can safely be removed.

With this in mind, must adjust quickstart tests to be more
representative.
2018-12-17 06:44:17 -08:00
Takeshi KOMIYA 5e5bdb8a64 Remove absolute_import 2018-12-17 20:47:49 +09:00
Takeshi KOMIYA 8ea3f7fad9 Merge pull request #5509 from stephenfin/remove-future-imports
Remove future imports
2018-12-17 20:32:39 +09:00
Takeshi KOMIYA d8b69c7f98 Merge pull request #5819 from jdufresne/coding-comment
Remove unnecessary encoding cookie from Python source files
2018-12-17 19:15:00 +09:00
Takeshi KOMIYA c7ed4f3ddd Merge pull request #5814 from jdufresne/str-format-coerce
Remove redundant coerce to str in string formatting
2018-12-17 19:08:28 +09:00
Takeshi KOMIYA 71a7ce1453 Merge branch 'master' into string-classes 2018-12-17 18:58:32 +09:00
Stephen Finucane 5a9033e5aa Specifically request Python 3
If Sphinx is Python 3-only, Sphinx's tooling should be Python 3-only
too.

Signed-off-by: Stephen Finucane <stephen@that.guru>
2018-12-17 09:46:18 +00:00
Stephen Finucane d345d0f8c1 py3: Remove (most) __future__ imports
There were two used:

- print_function
- absolute_import

Both of these are mandatory in Python 3.0 onwards [1] and can therefore
be removed...mostly. Unfortunately, mypy is still running in Python 2.7
mode, meaning we need the 'print_function' future wherever we're calling
'print' with the 'file' argument. There's also a single
'absolute_import' future that must be retained as its removal breaks a
test for as-yet unknown reasons.  TODOs are added to resolve both issues
in the future.

[1] https://docs.python.org/3/library/__future__.html

Signed-off-by: Stephen Finucane <stephen@that.guru>
2018-12-17 09:46:15 +00:00
Jon Dufresne d210da96f6 Fix invalid escape sequence in test_directive_code.py
Fixes error when running tests:

tests/test_directive_code.py:359
  sphinx/tests/test_directive_code.py:359: DeprecationWarning: invalid escape sequence \s
    includes = '\\end{sphinxVerbatim}\n\sphinxresetverbatimhllines\n'
2018-12-16 13:37:47 -08:00
Jon Dufresne bade33c7e4 Remove unnecessary encoding cookie from Python source files
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.
2018-12-16 12:22:12 -08:00
Jon Dufresne 80861d105b Deprecate sphinx.config.string_classes; remove all internal uses
With only a single text type across supported Python versions, the
string_classes is no longer necessary.

Internally, all uses were converted to the value `[str]`. For
.add_config_value() uses that also supply a default string, the type is
inferred.
2018-12-16 11:35:06 -08:00
Jon Dufresne 2b0096fba9 Remove redundant coerce to str in string formatting
When an object is passed to a string format placeholder '%s', Python
will implicitly call str() on the object. This applies to print() and
logging as well.
2018-12-16 10:03:45 -08:00
jfbu 30ec4b6bba Merge branch '1.8' 2018-12-16 18:34:05 +01:00
Jakob Lykke Andersen 73a8b7e658 Merge branch 'cpp_fix_float_literals' into 1.8 2018-12-16 17:19:57 +01:00
Jakob Lykke Andersen b3de33deef C++, fix parsing of floating point literals
Fixes sphinx-doc/sphinx#5636
2018-12-16 16:56:55 +01:00
jfbu 88a019dc99 LaTeX: allow sphinxVerbatim usage without explicit "hllines" extra setup
Fixes: #5810
2018-12-16 16:54:28 +01:00
Takeshi KOMIYA c6bd84a614 refactor: Remove u-prefix from strings 2018-12-16 21:28:51 +09:00
Takeshi KOMIYA ea1d2d06f8 Merge pull request #5803 from jdufresne/encoding-utf8
Avoid respecifying default encoding for .encode()/.decode() calls
2018-12-16 20:01:43 +09:00
Takeshi KOMIYA 2597c4174e Merge pull request #5796 from jdufresne/super
Use Python 3 super() argument-less syntax
2018-12-16 19:46:47 +09:00
Jon Dufresne 5bf25eb445 Avoid respecifying default encoding for .encode()/.decode() calls
In Python 3, both .encode() and .decode() default the encoding to
'utf-8'. See the docs:

https://docs.python.org/3/library/stdtypes.html#str.encode
https://docs.python.org/3/library/stdtypes.html#bytes.decode

Simplify and shorten the code by using the default instead of
respecifying it.
2018-12-15 17:19:56 -08:00
Jon Dufresne 49d3a3c0c1 Replace ENOENT errno checks with Python 3 FileNotFoundError
The error is more specific and self documenting.

This removes the last use of sphinx.util.osutil.ENOENT, so it is now
deprecated for removal. sphinx.util.osutil.EEXIST was already unused so
that is deprecated as well.
2018-12-15 09:02:55 -08:00
Jon Dufresne ade973f4e3 Use Python 3 super() argument-less syntax
The form is less verbose and more idiomatic for Python 3 only code.

https://docs.python.org/3/library/functions.html#super
2018-12-15 08:35:55 -08:00
Takeshi KOMIYA c70e65fc6c Merge branch 'master' into 5770_doctest_refers_highlight_language 2018-12-16 00:32:10 +09:00
Takeshi KOMIYA b56f4f9022 Remove print_function feature 2018-12-15 23:16:10 +09:00
Takeshi KOMIYA 415ebc15c5 Merge pull request #5784 from tk0miya/refactor_hack_for_py2
Refactor hack for py2
2018-12-15 22:40:46 +09:00
Takeshi KOMIYA 66fad4e22d Remove a hack for py2 from testcode 2018-12-15 22:01:22 +09:00
Takeshi KOMIYA fd1dd13a50 refactor: Replace six.StringIO by io.StringIO 2018-12-15 21:00:38 +09:00
Takeshi KOMIYA 001a557fcf Merge pull request #5781 from tk0miya/refactor_six.PY2
refactor: Drop six.PY2
2018-12-15 20:57:51 +09:00
Takeshi KOMIYA e789080b54 refactor: Drop six.PY2 2018-12-15 20:08:39 +09:00
Takeshi KOMIYA 5f8b1ede8e refactor: Replace six.add_metaclass by __metaclass_ attribute 2018-12-15 20:06:26 +09:00
Takeshi KOMIYA d6d4406ce9 Fix #5770: doctest: Follow highlight_language on highlighting doctest block 2018-12-15 18:35:12 +09:00
Takeshi KOMIYA 389f756f88 refactor: special rubric for footnotes 2018-12-10 00:07:25 +09:00
Takeshi KOMIYA 8a6179aa61 Process prolog and epilog on RSTParser (instead Input component) 2018-12-05 23:11:16 +09:00
Takeshi KOMIYA 5fa8ca492b Add prepend_prolog() and append_epilog() 2018-12-05 23:10:23 +09:00
Takeshi KOMIYA ab3eb1b61d Add testcases for mock() 2018-12-04 23:57:01 +09:00
Takeshi KOMIYA 825426c841 refactor figure_wrapper() using state.inline_text() 2018-12-04 01:14:53 +09:00
Takeshi KOMIYA b3d71ca683 Merge branch 'master' into refactor_SphinxTranslator 2018-12-03 23:16:03 +09:00
Takeshi KOMIYA 3863256cb6 Add SphinxTranslator as an abstract class 2018-12-03 22:30:56 +09:00
Takeshi KOMIYA b76966815c Fix annotations of testing 2018-12-03 22:22:07 +09:00
Takeshi KOMIYA 28add225f2 Merge branch '1.8' 2018-12-02 22:26:12 +09:00
Takeshi KOMIYA e8ea448474 Merge pull request #5699 from tk0miya/smart_manpage_conf_py
quickstart: Simplify generated conf.py (for manpage)
2018-12-02 18:18:55 +09:00
Takeshi KOMIYA a5e7e85e92 quickstart: Simplify generated conf.py (for manpage) 2018-12-02 17:57:20 +09:00
Takeshi KOMIYA 5e1c45355e quickstart: Simplify generated conf.py (for htmlhelp) 2018-12-02 11:30:40 +09:00
Takeshi KOMIYA e527be396a Merge pull request #5607 from tk0miya/smart_texinfo_conf_py
quickstart: Simplify generated conf.py (for texinfo)
2018-12-02 01:30:51 +09:00
Takeshi KOMIYA 8608102da6 Refactor metadata handling 2018-11-30 17:56:19 +09:00
Takeshi KOMIYA 3808405b50 Fix #5659: linkcheck: crashes for a hyperlink containing multibyte character 2018-11-25 01:37:32 +09:00
Takeshi KOMIYA 722c92250c Fix #5648: NodeMatcher matches Text node on attribute match 2018-11-25 01:16:17 +09:00
Takeshi KOMIYA b2f069ba6e Add testcase for default_texinfo_documents 2018-11-24 01:23:27 +09:00
Jon Dufresne d99e2cae19 Deprecate evaluating Python 2 syntax in configuration files 2018-11-22 19:05:14 -08:00
Takeshi KOMIYA 4761e70c37 Merge branch '1.8' 2018-11-22 22:14:32 +09:00