Sphinx is not creating cross-reference link - python

Any ideas Why sphinx is not creating cross reference links?
I have tried every possible combination to try to get a link to work, no luck.
I have tried with the napoleon_google_docstring on and off.
Other references that are create automatically are working ok.

You are using straight single quotes instead of backticks to delimit the role content. For example, :func:'atest' must be changed to :func:`atest`.
References:
http://www.sphinx-doc.org/en/latest/markup/inline.html
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#interpreted-text

Related

Shortening cross-references in Sphinx documentaton

When using the intersphinx extension to cross-reference objects from external Python packages the references can get pretty long if the module the object is defined in is nested several layers deep. Specifically I'm working with the Sympy library which leads to constantly having to type things like :class:`sympy.core.symbol.Symbol` all over the place.
I know that you can:
Prepend a ~ character to the reference to make the link only appear as "Symbol" in the generated documentation.
Truncate the path from the beginning, leaving a dot at the beginning, like .Symbol, .symbol.Symbol, .core.symbol.Symbol, etc.
Just use Symbol and count on Sphinx to find it, if I know there won't be any conflicts.
#1 is fine for the generated documentation but is still very verbose in the source files. #2 and #3 are shorter but leave out the most important part, which is the actual root package.
Is there a way shorten references in a way that removes the intermediate module names but also keeps the root package namespace? Something like sympy.*.Symbol or sympy::Symbol?

Troubles with XPath Plugin Python

So i am getting the path id('page-content')/x:div[6]/x:div/x:div/x:div/x:a[1]/x:img
How would i go about clicking the img?
I've tried
lol=find_element_by_xpath("//div[#class='emoji-items nano-content']//a[#title=':heart:']/img")
as well as
lol=find_element_by_xpath("//a[#title=':heart:']/img")
which i believe should work, but it instead gives me an error
What i did is: select all links elements (a) that contains heart in the title.
I tried to avoid using #title= because sometimes you might have issues due syntax used in the methods for finding the element or in other methods due to special characters like :.
The resulted path was:
//a[contains(#title, 'heart')]
If more elements are found you need to add another element in front of this to restrict the section that is searched in.

Is it possible to bulk-add docstrings to all the functions in PyCharm?

I have a python project that many of the functions and classes missing docstrings.
I know that PyCharm can automatically add docstrings by the Insert documentation string stub command using intention action. However, for large number of methods and functions, it is tedious.
Is there a method to bulk add docstrings to all the functions at once? then I will fill what is necessary manually.
If not in PyCharm, Is there any alternative client that can do it?
Thanks in advance for helps...
Finally, I found an answer, or may be a workaround
In pyCharm,
goto File\Settings\Code Style\Inspections then put a tick in front of 'Missing or empty docstring' Then press OK button.
goto Code\Inspect Code\ then select Custom scope>>Open Files
You will find a panel below with your project's name, then Python\Missing or empty docstring\
Right click on the title "Missing or empty docstring", and select the command {Apply fix 'Fix docstring'}
The program will automatically add docsrtings to all functions, and classes.
This works for me,
If anyone have better solution or workaround, so please share it with us.

Getting Vim to be aware of ctag type annotations for python

I use Vim+Ctags to write Python, and my problem is that Vim often jumps to the import for a tag, rather than the definition. This is a common issue, and has already been addressed in a few posts here.
this post shows how to remove the imports from the tags file. This works quite well, except that sometimes it is useful to have tags form the imports (e.g. when you want to list all places where a class/function has been imported).
this post shows how to get to the definition without removing the imports from the tags file. This is basically what I've been doing so far (just remapped :tjump to a single keystroke). However, you still need to navigate the list of tags that comes up to find the definition entry.
It would be nice it if it were possible to just tell Vim to "got the the definition" with a single key chord (e.g. ). Exuberant Ctags annotates the tag entries with the type of entry (e.g. c for classes, i for imports). Does anyone know if there is a way to get Vim to utilize these annotations, so that I could say things like "go to the first tag that is not of type i"?
Unfortunately, there's no way for Vim itself to do that inference business and jump to an import or a definition depending on some context: when searching for a tag in your tags file, Vim stops at the first match whatever it is. A plugin may help but I'm not aware of such a thing.
Instead of <C-]> or :tag foo, you could use g] or :ts foo which shows you a list of matches (with kinds and a preview of the line of each match) instead of jumping to the first one. This way, you are able to tell Vim exactly where you want to go.

VIM: How to access the redo-register

As a secondary task to a Python auto-completion (https://github.com/davidhalter/jedi), I'm writing a VIM plugin with the ability to do renaming (refactoring).
The most comfortable way to do renaming is to use cw and autocommand InsertLeave :call do_renaming_func(). To do this I need to access the redo-register (see help redo-register) or something similar, which would record the written text.
If possible, I like to do this without macros, because I don't want to mess up anything.
The . register (#.) contains all editing keys, unfortunately in raw form, so also <Del> and <BS>, which show up as <80>kD, and which insert completion does not interpret. Instead, to extract only the net text entered, use the range delimited by the marks '[ and '] (last one exclusive).
For an example on how to do this, have a look at my PrevInsertComplete plugin.
The . register contains the last inserted text. See :help quote_..
The help doesn't specifically mention any caveats of when this register is populated, however it does mention that it doesn't work when editing the command line. This shouldn't be an issue for you.
The problem was not knowing which register it was, but to access it.
I eventually found the method:
getreg('.')
As #Ingo Karkat points out, this register might include some escape chars.
However, I used a different method in the end. I just read expand('<cword>') to get the new word (because a rename is always only one word). This is far easier and more reliable.
Here's the code (line 113):
https://github.com/davidhalter/jedi/commit/6920f15caf332cd14a7833a071765dfa77d82328

Categories