Open pappasam opened 3 years ago
Thanks, I will greatly appreciate it! As for this specific docstring, this is because it is not RST. I spend quite some time confused here before because it looks like RST, but actually it is stripped of RST qualifiers. Compare with the cPython source: https://github.com/python/cpython/blob/master/Doc/reference/simple_stmts.rst#the-keywordimport-statement
The :keyword:`!import` statement
================================
.. index::
! statement: import
single: module; importing
pair: name; binding
keyword: from
keyword: as
exception: ImportError
single: , (comma); import statement
.. productionlist:: python-grammar
import_stmt: "import" `module` ["as" `identifier`] ("," `module` ["as" `identifier`])*
: | "from" `relative_module` "import" `identifier` ["as" `identifier`]
: ("," `identifier` ["as" `identifier`])*
: | "from" `relative_module` "import" "(" `identifier` ["as" `identifier`]
: ("," `identifier` ["as" `identifier`])* [","] ")"
: | "from" `module` "import" "*"
module: (`identifier` ".")* `identifier`
relative_module: "."* `module` | "."+
The basic import statement (no :keyword:`from` clause) is executed in two
steps:
#. find a module, loading and initializing it if necessary
#. define a name or names in the local namespace for the scope where
the :keyword:`import` statement occurs.
When the statement contains multiple clauses (separated by
commas) the two steps are carried out separately for each clause, just
as though the clauses had been separated out into individual import
statements.
The details of the first step, finding and loading modules are described in
greater detail in the section on the :ref:`import system <importsystem>`,
which also describes the various types of packages and modules that can
be imported, as well as all the hooks that can be used to customize
the import system. Note that failures in this step may indicate either
that the module could not be located, *or* that an error occurred while
initializing the module, which includes execution of the module's code.
If the requested module is retrieved successfully, it will be made
available in the local namespace in one of three ways:
.. index:: single: as; import statement
* If the module name is followed by :keyword:`!as`, then the name
following :keyword:`!as` is bound directly to the imported module.
* If no other name is specified, and the module being imported is a top
level module, the module's name is bound in the local namespace as a
reference to the imported module
* If the module being imported is *not* a top level module, then the name
of the top level package that contains the module is bound in the local
namespace as a reference to the top level package. The imported module
must be accessed using its full qualified name rather than directly
It would be good to determine where (Jedi? cPython?) the conversion happens. Certainly converting it as-is (e.g. without the .. productionlist::
syntax) would lead to formatting issues :(
Seems like jedi just uses the output from pydoc
for keywords. Try running pydoc import
from your terminal and you should see jedi's hover text.
And that gets auto-generated from Sphinx: https://github.com/python/cpython/blob/3.9/Lib/pydoc_data/topics.py (which strips formatting information). It is implemented here: PydocTopicsBuilder.
There is a finite number of keywords so this could potentially be worked around...
I'm going to open issues for specific items I find in my day-to-day. I'll begin the non-crucial issues with "NTH" so you know it's a "nice to have" and not a blocker. Feel free to ignore these issues, I'm just documenting what I find in case you find it helpful.
The following docstring isn't converted from rst to markdown (raises "UnknownFormatError"):