autodoc: Instance variables auto-link to unrelated variables of the same name in other classes/modules
extensions:autodoc
## Bug description
When using `autodoc` (typically via `sphinx-apidoc`), if a global variable (or any variable) exists, and inside a class you document a variable of the same name, the instance variable documentation will automatically link to the other occurrence of a variable with the same name.
This can occur across subpackages and even across other classes of those subpackages. This is problematic because, for example, `somepackage.subA::Foo.somename` could be and usually is completely unrelated to `somepackage.subB::Bar.somename`. Furthermore, `somepackage::Foo.somename` (instance variable) could be completely unrelated to `somepackage.somename` (global variable).
The auto-linking of these two together is unexpected behavior.
## Steps to reproduce
```
$ git clone https://github.com/13steinj/sphinx-issue-examples/
$ cd sphinx-issue-examples
$ git checkout referenced_variables
$ cd docs
$ make html
$ cd _build/html && python -m SimpleHTTPServer 8008
```
Then open http://127.0.0.1:8008 in a browser.
## Expected behavior
The class instance variable documentation should **not** be automatically linked to any other variable of the same name. These are almost certainly unrelated. If they happen to be related, the user can explicitly document that relationship with a reference such as `see :const:`somename```.
There is no reason that a `limit` variable on a database-oriented class should auto-link to the `limit` variable on a config-related class.
## Example project
https://github.com/13steinj/sphinx-issue-examples/tree/referenced_variables
## Environment info
- OS: Ubuntu 14.04.5
- Python version: 2.7.6
- Sphinx version: 1.8.3
- Sphinx extensions: autodoc, intersphinx, and others (todo, viewcode, githubpages)
- Extra tools: sphinx-apidoc
关闭于 22 天前 2 条评论