Skip to content

Commit 7c596fc

Browse files
authored
Update sphinx to 4.2.0 (#2261)
* Fix deprecated sphinx method and param names * Update docs.yml * Refactor sphinx autosummary patching * Turn off legacy patch * Revert "Refactor sphinx autosummary patching" This reverts commit 02f0455. * Fix Autosummary patching * Remove cross ref patch * Revert "Update docs.yml" This reverts commit eb8dae7. * Revert docs.yml changes * Downgrade to 3.5.4 * Get back to 4.2.0 * Fix ignite theme css * Add suggestions from code review * Fix code style * Revert docs deps * Fix code snippets line spacing * Expand Notes section * Fix function names * Use empty array for collapsedSections
1 parent 5c2e074 commit 7c596fc

File tree

6 files changed

+35
-24
lines changed

6 files changed

+35
-24
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
- name: make linkcheck
6262
working-directory: ./docs/
63-
run: make linkcheck --jobs 2 SPHINXOPTS="--color -W"
63+
run: make linkcheck
6464

6565
doctest:
6666
if: github.event_name == 'pull_request' || github.event_name == 'push'
@@ -83,6 +83,6 @@ jobs:
8383
- name: make doctest
8484
working-directory: ./docs/
8585
run: |
86-
make html SPHINXOPTS="--color -W"
86+
make html
8787
make doctest
8888
make coverage

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33

44
# You can set these variables from the command line.
5-
SPHINXOPTS =
5+
SPHINXOPTS = -j auto -WT --keep-going --color
66
SPHINXBUILD = sphinx-build
77
SPHINXPROJ = ignite
88
SOURCEDIR = source

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sphinx==3.4.3
1+
sphinx==4.2.0
22
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
33
sphinxcontrib-katex
44
sphinx-copybutton==0.4.0

docs/source/_templates/_static/css/ignite_theme.css

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,23 @@ article.pytorch-article p.rubric {
217217
}
218218

219219
.highlight pre {
220-
border: 1px solid rgba(0,0,0,0.15);
220+
border: 1px solid rgba(0, 0, 0, 0.15);
221221
border-radius: 4px;
222+
line-height: 1.375rem;
223+
}
224+
225+
/* Sphinx >=3.5: Fix class/method/fn names, because of spans */
226+
article.pytorch-article .class dt > span span.pre,
227+
article.pytorch-article .function dt > span span.pre {
228+
color: inherit;
229+
font-size: 87.5%;
230+
font-family: IBMPlexMono, SFMono-Regular, Menlo, Monaco, Consolas,
231+
"Liberation Mono", "Courier New", monospace;
232+
}
233+
234+
/* Sphinx >=3.5: Fix annotations */
235+
article.pytorch-article .class dt span.pre,
236+
article.pytorch-article .function dt span.pre {
237+
color: inherit;
238+
padding: 2px 0.2px;
222239
}

docs/source/_templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ <h2>Resources</h2>
496496
<script type="text/javascript" src="{{ pathto('_static/js/vendor/anchor.min.js', 1) }}"></script>
497497

498498
<script type="text/javascript">
499-
var collapsedSections = ['Notes']
499+
var collapsedSections = []
500500
$(document).ready(function() {
501501
mobileMenu.bind();
502502
mobileTOC.bind();

docs/source/conf.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
import sys
1717

1818
sys.path.insert(0, os.path.abspath("../.."))
19-
import ignite
19+
from datetime import datetime
20+
2021
import pytorch_sphinx_theme
2122

22-
from datetime import datetime
23+
import ignite
2324

2425
# -- Project information -----------------------------------------------------
2526

@@ -133,7 +134,8 @@
133134
}
134135

135136
html_last_updated_fmt = "%m/%d/%Y, %X"
136-
html_add_permalinks = "#"
137+
html_permalinks = True
138+
html_permalinks_icon = "#"
137139

138140
# -- Options for HTMLHelp output ---------------------------------------------
139141

@@ -213,26 +215,17 @@
213215
autodoc_typehints = "description"
214216
napoleon_attr_annotations = True
215217

216-
# -- A patch that turns-off cross refs for type annotations ------------------
217-
218-
import sphinx.domains.python
219-
from docutils import nodes
220-
from sphinx import addnodes
221-
222-
# replaces pending_xref node with desc_type for type annotations
223-
sphinx.domains.python.type_to_xref = lambda t, e=None: addnodes.desc_type("", nodes.Text(t))
224-
225218
# -- Autosummary patch to get list of a classes, funcs automatically ----------
226219

227220
from importlib import import_module
228221
from inspect import getmembers, isclass, isfunction
229-
import sphinx.ext.autosummary
230-
from sphinx.ext.autosummary import Autosummary
222+
231223
from docutils.parsers.rst import directives
232224
from docutils.statemachine import StringList
225+
from sphinx.ext.autosummary import Autosummary
233226

234227

235-
class BetterAutosummary(Autosummary):
228+
class AutolistAutosummary(Autosummary):
236229
"""Autosummary with autolisting for modules.
237230
238231
By default it tries to import all public names (__all__),
@@ -317,9 +310,6 @@ def run(self):
317310
return super().run()
318311

319312

320-
# Patch original Autosummary
321-
sphinx.ext.autosummary.Autosummary = BetterAutosummary
322-
323313
# --- autosummary config -----------------------------------------------------
324314
autosummary_generate = True
325315

@@ -352,3 +342,7 @@ def run(self):
352342
353343
manual_seed(666)
354344
"""
345+
346+
347+
def setup(app):
348+
app.add_directive("autosummary", AutolistAutosummary, override=True)

0 commit comments

Comments
 (0)