Skip to content

Commit f546ff0

Browse files
author
Jonathan Corbet
committed
Move our minimum Sphinx version to 1.7
As promised, drop support for some ancient sphinx releases, along with a lot of the cruft that was required to make that support work. Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 20ccc8d commit f546ff0

File tree

6 files changed

+21
-166
lines changed

6 files changed

+21
-166
lines changed

Documentation/conf.py

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# -- General configuration ------------------------------------------------
3232

3333
# If your documentation needs a minimal Sphinx version, state it here.
34-
needs_sphinx = '1.3'
34+
needs_sphinx = '1.7'
3535

3636
# Add any Sphinx extension module names here, as strings. They can be
3737
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -112,19 +112,12 @@
112112

113113
else:
114114
extensions.append('cdomain')
115-
if major == 1 and minor < 7:
116-
sys.stderr.write('WARNING: Sphinx 1.7 or greater will be required as of '
117-
'the 5.12 release\n')
118115

119116
# Ensure that autosectionlabel will produce unique names
120117
autosectionlabel_prefix_document = True
121118
autosectionlabel_maxdepth = 2
122119

123-
# The name of the math extension changed on Sphinx 1.4
124-
if (major == 1 and minor > 3) or (major > 1):
125-
extensions.append("sphinx.ext.imgmath")
126-
else:
127-
extensions.append("sphinx.ext.pngmath")
120+
extensions.append("sphinx.ext.imgmath")
128121

129122
# Add any paths that contain templates here, relative to this directory.
130123
templates_path = ['_templates']
@@ -375,71 +368,9 @@
375368
'''
376369

377370
# Fix reference escape troubles with Sphinx 1.4.x
378-
if major == 1 and minor > 3:
371+
if major == 1:
379372
latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
380373

381-
if major == 1 and minor <= 4:
382-
latex_elements['preamble'] += '\\usepackage[margin=0.5in, top=1in, bottom=1in]{geometry}'
383-
elif major == 1 and (minor > 5 or (minor == 5 and patch >= 3)):
384-
latex_elements['sphinxsetup'] = 'hmargin=0.5in, vmargin=1in'
385-
latex_elements['preamble'] += '\\fvset{fontsize=auto}\n'
386-
387-
# Customize notice background colors on Sphinx < 1.6:
388-
if major == 1 and minor < 6:
389-
latex_elements['preamble'] += '''
390-
\\usepackage{ifthen}
391-
392-
% Put notes in color and let them be inside a table
393-
\\definecolor{NoteColor}{RGB}{204,255,255}
394-
\\definecolor{WarningColor}{RGB}{255,204,204}
395-
\\definecolor{AttentionColor}{RGB}{255,255,204}
396-
\\definecolor{ImportantColor}{RGB}{192,255,204}
397-
\\definecolor{OtherColor}{RGB}{204,204,204}
398-
\\newlength{\\mynoticelength}
399-
\\makeatletter\\newenvironment{coloredbox}[1]{%
400-
\\setlength{\\fboxrule}{1pt}
401-
\\setlength{\\fboxsep}{7pt}
402-
\\setlength{\\mynoticelength}{\\linewidth}
403-
\\addtolength{\\mynoticelength}{-2\\fboxsep}
404-
\\addtolength{\\mynoticelength}{-2\\fboxrule}
405-
\\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\mynoticelength}}{\\end{minipage}\\end{lrbox}%
406-
\\ifthenelse%
407-
{\\equal{\\py@noticetype}{note}}%
408-
{\\colorbox{NoteColor}{\\usebox{\\@tempboxa}}}%
409-
{%
410-
\\ifthenelse%
411-
{\\equal{\\py@noticetype}{warning}}%
412-
{\\colorbox{WarningColor}{\\usebox{\\@tempboxa}}}%
413-
{%
414-
\\ifthenelse%
415-
{\\equal{\\py@noticetype}{attention}}%
416-
{\\colorbox{AttentionColor}{\\usebox{\\@tempboxa}}}%
417-
{%
418-
\\ifthenelse%
419-
{\\equal{\\py@noticetype}{important}}%
420-
{\\colorbox{ImportantColor}{\\usebox{\\@tempboxa}}}%
421-
{\\colorbox{OtherColor}{\\usebox{\\@tempboxa}}}%
422-
}%
423-
}%
424-
}%
425-
}\\makeatother
426-
427-
\\makeatletter
428-
\\renewenvironment{notice}[2]{%
429-
\\def\\py@noticetype{#1}
430-
\\begin{coloredbox}{#1}
431-
\\bf\\it
432-
\\par\\strong{#2}
433-
\\csname py@noticestart@#1\\endcsname
434-
}
435-
{
436-
\\csname py@noticeend@\\py@noticetype\\endcsname
437-
\\end{coloredbox}
438-
}
439-
\\makeatother
440-
441-
'''
442-
443374
# With Sphinx 1.6, it is possible to change the Bg color directly
444375
# by using:
445376
# \definecolor{sphinxnoteBgColor}{RGB}{204,255,255}

Documentation/sphinx/cdomain.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,7 @@ def add_target_and_index(self, name, sig, signode):
236236

237237
indextext = self.get_index_text(name)
238238
if indextext:
239-
if major == 1 and minor < 4:
240-
# indexnode's tuple changed in 1.4
241-
# https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
242-
self.indexnode['entries'].append(
243-
('single', indextext, targetname, ''))
244-
else:
245-
self.indexnode['entries'].append(
239+
self.indexnode['entries'].append(
246240
('single', indextext, targetname, '', None))
247241

248242
class CDomain(Base_CDomain):

Documentation/sphinx/kernel_abi.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,7 @@
4545
from docutils.statemachine import ViewList
4646
from docutils.parsers.rst import directives, Directive
4747
from docutils.utils.error_reporting import ErrorString
48-
49-
#
50-
# AutodocReporter is only good up to Sphinx 1.7
51-
#
52-
import sphinx
53-
54-
Use_SSI = sphinx.__version__[:3] >= '1.7'
55-
if Use_SSI:
56-
from sphinx.util.docutils import switch_source_input
57-
else:
58-
from sphinx.ext.autodoc import AutodocReporter
48+
from sphinx.util.docutils import switch_source_input
5949

6050
__version__ = '1.0'
6151

@@ -179,16 +169,5 @@ def nestedParse(self, lines, fname):
179169
return node.children
180170

181171
def do_parse(self, content, node):
182-
if Use_SSI:
183-
with switch_source_input(self.state, content):
184-
self.state.nested_parse(content, 0, node, match_titles=1)
185-
else:
186-
buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
187-
188-
self.state.memo.title_styles = []
189-
self.state.memo.section_level = 0
190-
self.state.memo.reporter = AutodocReporter(content, self.state.memo.reporter)
191-
try:
192-
self.state.nested_parse(content, 0, node, match_titles=1)
193-
finally:
194-
self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
172+
with switch_source_input(self.state, content):
173+
self.state.nested_parse(content, 0, node, match_titles=1)

Documentation/sphinx/kernel_feat.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,7 @@
4242
from docutils.statemachine import ViewList
4343
from docutils.parsers.rst import directives, Directive
4444
from docutils.utils.error_reporting import ErrorString
45-
46-
#
47-
# AutodocReporter is only good up to Sphinx 1.7
48-
#
49-
import sphinx
50-
51-
Use_SSI = sphinx.__version__[:3] >= '1.7'
52-
if Use_SSI:
53-
from sphinx.util.docutils import switch_source_input
54-
else:
55-
from sphinx.ext.autodoc import AutodocReporter
45+
from sphinx.util.docutils import switch_source_input
5646

5747
__version__ = '1.0'
5848

@@ -154,16 +144,7 @@ def nestedParse(self, lines, fname):
154144

155145
buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
156146

157-
if Use_SSI:
158-
with switch_source_input(self.state, content):
159-
self.state.nested_parse(content, 0, node, match_titles=1)
160-
else:
161-
self.state.memo.title_styles = []
162-
self.state.memo.section_level = 0
163-
self.state.memo.reporter = AutodocReporter(content, self.state.memo.reporter)
164-
try:
165-
self.state.nested_parse(content, 0, node, match_titles=1)
166-
finally:
167-
self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
147+
with switch_source_input(self.state, content):
148+
self.state.nested_parse(content, 0, node, match_titles=1)
168149

169150
return node.children

Documentation/sphinx/kerneldoc.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,8 @@
3737
from docutils import nodes, statemachine
3838
from docutils.statemachine import ViewList
3939
from docutils.parsers.rst import directives, Directive
40-
41-
#
42-
# AutodocReporter is only good up to Sphinx 1.7
43-
#
4440
import sphinx
45-
46-
Use_SSI = sphinx.__version__[:3] >= '1.7'
47-
if Use_SSI:
48-
from sphinx.util.docutils import switch_source_input
49-
else:
50-
from sphinx.ext.autodoc import AutodocReporter
51-
41+
from sphinx.util.docutils import switch_source_input
5242
import kernellog
5343

5444
__version__ = '1.0'
@@ -163,18 +153,8 @@ def run(self):
163153
return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
164154

165155
def do_parse(self, result, node):
166-
if Use_SSI:
167-
with switch_source_input(self.state, result):
168-
self.state.nested_parse(result, 0, node, match_titles=1)
169-
else:
170-
save = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
171-
self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
172-
self.state.memo.title_styles, self.state.memo.section_level = [], 0
173-
try:
174-
self.state.nested_parse(result, 0, node, match_titles=1)
175-
finally:
176-
self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = save
177-
156+
with switch_source_input(self.state, result):
157+
self.state.nested_parse(result, 0, node, match_titles=1)
178158

179159
def setup(app):
180160
app.add_config_value('kerneldoc_bin', None, 'env')

Documentation/sphinx/kernellog.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,19 @@
44
# only goes back to 1.6. So here's a wrapper layer to keep around for
55
# as long as we support 1.4.
66
#
7+
# We don't support 1.4 anymore, but we'll keep the wrappers around until
8+
# we change all the code to not use them anymore :)
9+
#
710
import sphinx
11+
from sphinx.util import logging
812

9-
if sphinx.__version__[:3] >= '1.6':
10-
UseLogging = True
11-
from sphinx.util import logging
12-
logger = logging.getLogger('kerneldoc')
13-
else:
14-
UseLogging = False
13+
logger = logging.getLogger('kerneldoc')
1514

1615
def warn(app, message):
17-
if UseLogging:
18-
logger.warning(message)
19-
else:
20-
app.warn(message)
16+
logger.warning(message)
2117

2218
def verbose(app, message):
23-
if UseLogging:
24-
logger.verbose(message)
25-
else:
26-
app.verbose(message)
19+
logger.verbose(message)
2720

2821
def info(app, message):
29-
if UseLogging:
30-
logger.info(message)
31-
else:
32-
app.info(message)
22+
logger.info(message)

0 commit comments

Comments
 (0)