Repository: pytorch/ignite

Issue:
[DOCS] Rendered class and method signature overlaps with [source] after sphinx update
## 🐛 Bug description

<!-- A clear and concise description of what the bug is. -->
I've noticed that after updating to `sphinx=3.1`, documentation has some problem with class header layout, if you go to the docs webpage, you can find that in some cases type hits overlap with [SOURCE] button, in some cases even definition overlaps as well. Zooming-in/out doesn't help.
<!-- Please, add steps on how to reproduce it. -->
<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->
Here is what I get:
![docs1](https://user-images.githubusercontent.com/30748114/95250758-35894c00-0823-11eb-9cb1-cfc463e64afb.png)
![docs2](https://user-images.githubusercontent.com/30748114/95250768-391cd300-0823-11eb-8a8e-b20e8ad44885.png)
![doc3](https://user-images.githubusercontent.com/30748114/95250941-7da86e80-0823-11eb-84a0-b6cdadee6205.png)
<!-- A clear and concise description of what you expected to happen. -->
After roll back to old version everything works fine, Also, I've noticed in [pytorch repo](https://github.com/pytorch/pytorch/blob/0da6730f029863b3c812e05ddb3cec8a316c7c1c/docs/requirements.txt#L1) that they're using `sphinx==2.4.4`, I've tried that version and it works well too.

## Environment

`sphinx==3.1`



Discussion:
@trsvchn thanks for the report, yes, I noticed that too but I thought that it was due to newly introduced type annotations. 

> After roll back to old version everything works fine

Does it mean, you have you tested current master branch with `sphinx==1.8.5` ?

If yes, maybe we can try the latest version of sphinx == 3.2.1 and check if it was fixed ?
@vfdev-5 Yes, I've tested it with 3 versions: `1.8.5` `2.4.4` and `3.1` (bad one)
Sure, I am going to try `sphinx == 3.2.1`
Nope all new versions after `2.4.4` do not produce the right results, same problem. I've also find this [Pin Sphinx to 2.4.4 ](https://github.com/pytorch/pytorch/pull/36065), they also pinned to `2.4.4` version, looks like pytorch theme has some troubles with newer sphinx.
@trsvchn thanks for details, seems like we have no choice here. However, we wanted to update to 3.1 due to https://github.com/pytorch/ignite/issues/1273 . 
I think we have to downgrade to 2.4.4 and try to autogenerate toc tree somehow differently.
If you guys have other ideas, we are open for that :)

cc @theodumont for visibility
@vfdev-5  I agree with you, we need to downgrade, since for "autotoc" there is alternative solution from SO + we can do it manually (as always :) But I didn't find any solution for that weird header layout.

Resolving patch:
diff --git a/docs/source/conf.py b/docs/source/conf.py
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -192,3 +192,16 @@
 
 # If true, `todo` and `todoList` produce output, else they produce nothing.
 todo_include_todos = True
+
+# -- Type hints configs ------------------------------------------------------
+
+autodoc_typehints = "signature"
+
+# -- A patch that turns-off cross refs for type annotations ------------------
+
+import sphinx.domains.python
+from docutils import nodes
+from sphinx import addnodes
+
+# replaces pending_xref node with desc_type for type annotations
+sphinx.domains.python.type_to_xref = lambda t, e=None: addnodes.desc_type("", nodes.Text(t))


Test patch: