diff --git a/docs/conf.py b/docs/conf.py index f4b73e2..015a40e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -274,7 +274,7 @@ autodoc_default_flags = [] # -- Options for intersphinx module -------------------------------------------- intersphinx_mapping = { - 'http://docs.python.org/': None, + 'http://docs.python.org/': ('https://docs.python.org/3.6', None), } diff --git a/docs/docs/parser-tree.rst b/docs/docs/parser-tree.rst index 52ad8b7..1924478 100644 --- a/docs/docs/parser-tree.rst +++ b/docs/docs/parser-tree.rst @@ -3,13 +3,7 @@ Parser Tree =========== -Usage ------ - -.. automodule:: parso.python - :members: - :undoc-members: - +The parser tree is returned by calling :py:meth:`parso.Grammar.parse`. Parser Tree Base Class ---------------------- diff --git a/parso/__init__.py b/parso/__init__.py index d879fc3..e532516 100644 --- a/parso/__init__.py +++ b/parso/__init__.py @@ -30,9 +30,9 @@ __version__ = '0.0.5' def parse(code=None, **kwargs): """ A utility function to avoid loading grammars. - Params are documented in :py:meth:`parso.Grammar.parse` + Params are documented in :py:meth:`parso.Grammar.parse`. - :param string version: The version used by :py:func:`parso.Grammar.load_grammar`. + :param str version: The version used by :py:func:`parso.load_grammar`. """ version = kwargs.pop('version', None) grammar = load_grammar(version=version) diff --git a/parso/grammar.py b/parso/grammar.py index 11731d1..317cbb6 100644 --- a/parso/grammar.py +++ b/parso/grammar.py @@ -47,7 +47,7 @@ class Grammar(object): :param str code: A unicode or bytes string. When it's not possible to decode bytes to a string, returns a - :py:class:`exceptions.UnicodeDecodeError`. + :py:class:`UnicodeDecodeError`. :param bool error_recovery: If enabled, any code will be returned. If it is invalid, it will be returned as an error node. If disabled, you will get a ParseError when encountering syntax errors in your diff --git a/parso/python/tree.py b/parso/python/tree.py index 652176e..614079c 100644 --- a/parso/python/tree.py +++ b/parso/python/tree.py @@ -1,16 +1,18 @@ """ -If you know what an syntax tree is, you'll see that this module is pretty much -that. The classes represent syntax elements like functions and imports. +This is the syntax tree for Python syntaxes (2 & 3). The classes represent +syntax elements like functions and imports. -This is the "business logic" part of the parser. There's a lot of logic here -that makes it easier for Jedi (and other libraries) to deal with a Python syntax -tree. +All of the nodes can be traced back to the `Python grammar file +`_. If you want to know how +a tree is structured, just analyse that file (for each Python version it's a +bit different). -By using `get_code` on a module, you can get back the 1-to-1 representation of -the input given to the parser. This is important if you are using refactoring. +There's a lot of logic here that makes it easier for Jedi (and other libraries) +to deal with a Python syntax tree. -The easiest way to play with this module is to use :class:`parsing.Parser`. -:attr:`parsing.Parser.module` holds an instance of :class:`Module`: +By using :py:meth:`parso.tree.NodeOrLeaf.get_code` on a module, you can get +back the 1-to-1 representation of the input given to the parser. This is +important if you are using refactoring. >>> from parso import parse >>> parser = parse('import os') diff --git a/parso/utils.py b/parso/utils.py index e3621c9..a4801b9 100644 --- a/parso/utils.py +++ b/parso/utils.py @@ -14,7 +14,7 @@ def split_lines(string, keepends=False): Intended for Python code. In contrast to Python's :py:meth:`str.splitlines`, looks at form feeds and other special characters as normal text. Just splits ``\n`` and ``\r\n``. - Also different: Returns ``['']`` for an empty string input. + Also different: Returns ``[""]`` for an empty string input. In Python 2.7 form feeds are used as normal characters when using str.splitlines. However in Python 3 somewhere there was a decision to split @@ -51,10 +51,10 @@ def split_lines(string, keepends=False): def python_bytes_to_unicode(source, encoding='utf-8', errors='strict'): """ Checks for unicode BOMs and PEP 263 encoding declarations. Then returns a - unicode object like in :py:meth:`str.decode`. + unicode object like in :py:meth:`bytes.decode`. - :param encoding: See :py:meth:`str.decode` documentation. - :param errors: See :py:meth:`str.decode` documentation. ``errors`` can be + :param encoding: See :py:meth:`bytes.decode` documentation. + :param errors: See :py:meth:`bytes.decode` documentation. ``errors`` can be ``'strict'``, ``'replace'`` or ``'ignore'``. """ def detect_encoding():