diff --git a/docs/conf.py b/docs/conf.py index 9de6f2608..0a319229f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -35,8 +35,10 @@ needs_sphinx = '1.3' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['codeblockext', 'onlineinclude', 'sphinx.ext.todo', 'sphinx.ext.autodoc', 'sphinxcontrib.httpdomain', - 'sphinx.ext.napoleon', 'sphinxcontrib.mermaid'] + 'sphinx.ext.napoleon', 'sphinxcontrib.mermaid', 'sphinx.ext.intersphinx'] todo_include_todos = True +intersphinx_mapping = {'python': ('https://docs.python.org/3', None), + 'python2': ('https://docs.python.org/2', None)} # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index dd7274d6b..bdb5ab164 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -42,15 +42,12 @@ logger = logging.getLogger(__name__) def to_bytes(s_or_u, encoding="utf-8", errors="strict"): # type: (Union[unicode, bytes], str, str) -> bytes """ - Make sure ``s_or_u`` is a bytestring. + Make sure ``s_or_u`` is a byte string. Arguments: s_or_u (string or unicode): The value to convert - encoding (string): default 'utf-8' - errors (string): The errors argument is the same as the argument of the decode() method but supports a few more possible handlers. - As well as 'strict', 'ignore', and 'replace' (which in this case inserts a question mark instead of the unencodable character), - there is also 'xmlcharrefreplace' (inserts an XML character reference), backslashreplace (inserts a \\uNNNN escape sequence) - and namereplace (inserts a \\N{...} escape sequence). + encoding (string): encoding to use if necessary, see :meth:`python:str.encode` + errors (string): error handling to use if necessary, see :meth:`python:str.encode` Returns: bytes: converted bytes. """ @@ -73,10 +70,8 @@ def to_unicode(s_or_u, encoding="utf-8", errors="strict"): Arguments: s_or_u (string or unicode): The value to convert - encoding (string): default 'utf-8' - errors (string): The errors argument specifies the response when the input string can’t be converted according to the encoding’s rules. - Legal values for this argument are 'strict' (raise a UnicodeDecodeError exception), 'replace' (use U+FFFD, REPLACEMENT CHARACTER), - 'ignore' (just leave the character out of the Unicode result), or 'backslashreplace' (inserts a \\xNN escape sequence). + encoding (string): encoding to use if necessary, see :meth:`python:bytes.decode` + errors (string): error handling to use if necessary, see :meth:`python:bytes.decode` Returns: string: converted string. """