Show doc-string of function
See original GitHub issueI’m using the following settings in coc
(from the coc README) to show documentation when pressing K
:
" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
Previously I used coc-python
which then showed the doc-string of the function. However with coc-pyright
I’m just getting the signature of the function which in some cases is totally unusable. For example if I press K
when on subprocess.run
I get the monstrosity
(function) run: Overload[(args: _CMD, bufsize: int = ..., executable: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn:
() -> Any = ..., close_fds: bool = ..., shell: bool = ..., cwd: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., env: Mapping[bytes, _TXT] | Mapping[str, _TXT] | None = ..., universal_newlines:
bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, capture_output: bool = ..., check: bool = ..., encoding: str |
None = ..., errors: str | None = ..., input: str | None = ..., text: Literal[True], timeout: float | None = ...) -> CompletedProcess[str], (args: _CMD, bufsize: int = ..., executable: str | bytes |
_PathLike[str] | _PathLike[bytes] | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: () -> Any = ..., close_fds: bool = ..., shell: bool = ..., cwd: str | bytes |
_PathLike[str] | _PathLike[bytes] | None = ..., env: Mapping[bytes, _TXT] | Mapping[str, _TXT] | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals:
bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, capture_output: bool = ..., check: bool = ..., encoding: str, errors: str | None = ..., input: str | None = ..., text: bool | None = ...,
timeout: float | None = ...) -> CompletedProcess[str], (args: _CMD, bufsize: int = ..., executable: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., stdin: _FILE = ..., stdout: _FILE = ...,
stderr: _FILE = ..., preexec_fn: () -> Any = ..., close_fds: bool = ..., shell: bool = ..., cwd: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., env: Mapping[bytes, _TXT] | Mapping[str, _TXT] |
None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, capture_output: bool = ...,
check: bool = ..., encoding: str | None = ..., errors: str, input: str | None = ..., text: bool | None = ..., timeout: float | None = ...) -> CompletedProcess[str], (args: _CMD, bufsize: int = ...,
executable: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: () -> Any = ..., close_fds: bool = ..., shell: bool = ...,
cwd: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., env: Mapping[bytes, _TXT] | Mapping[str, _TXT] | None = ..., *, universal_newlines: Literal[True], startupinfo: Any = ..., creationflags: int
= ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., capture_output: bool = ..., check: bool = ..., encoding: str | None = ..., errors: str | None = ..., input: str | None
= ..., text: bool | None = ..., timeout: float | None = ...) -> CompletedProcess[str], (args: _CMD, bufsize: int = ..., executable: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., stdin: _FILE
= ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: () -> Any = ..., close_fds: bool = ..., shell: bool = ..., cwd: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., env: Mapping[bytes,
_TXT] | Mapping[str, _TXT] | None = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any
= ..., *, capture_output: bool = ..., check: bool = ..., encoding: None = ..., errors: None = ..., input: bytes | None = ..., text: Literal[False] | None = ..., timeout: float | None = ...) ->
CompletedProcess[bytes], (args: _CMD, bufsize: int = ..., executable: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn:
() -> Any = ..., close_fds: bool = ..., shell: bool = ..., cwd: str | bytes | _PathLike[str] | _PathLike[bytes] | None = ..., env: Mapping[bytes, _TXT] | Mapping[str, _TXT] | None = ..., universal_newlines:
bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, capture_output: bool = ..., check: bool = ..., encoding: str |
None = ..., errors: str | None = ..., input: bytes | str | None = ..., text: bool | None = ..., timeout: float | None = ...) -> CompletedProcess[Any]]
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Getting the docstring from a function - python - Stack Overflow
Interactively, you can display it with help(my_func). Or from code you can retrieve it with (surround it with print(.) to get a formatted...
Read more >Python Docstrings (With Examples) - Programiz
Python docstrings are the string literals that appear right after the definition of a function, method, class, or module. Let's take an example....
Read more >Python Docstrings - GeeksforGeeks
Python documentation strings (or docstrings) provide a convenient way of associating documentation with Python modules, functions, classes, ...
Read more >Python Docstrings Tutorial : Examples & Format for Pydoc ...
Python documentation string or commonly known as docstring, is a string literal, and it is used in the class, module, function, or method...
Read more >Python Docstring: Documenting And Introspecting Functions
This tutorial explains what is Python Docstring and how to use it to document Python functions with examples.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@meandmymind I had a hack previously for earlier version of
coc-python
to get the correct python path for virtual environments. However, now I just set it back to:and things worked