Skip to content

Commit 9fdcd6a

Browse files
mchehabJonathan Corbet
authored andcommitted
docs-rst: conf.py: only setup notice box colors if Sphinx < 1.6
Sphinx 1.5 added a new way to change backward colors for note boxes, but kept backward compatibility with 1.4. On Sphinx 1.6, the old way stopped working, in favor of a new less hackish way. Unfortunately, this is currently too buggy to be used, and the old way doesn't work anymore. So, we have no option but to stick with boring notice boxes. One example of such bug is the notice that it is inside struct v4l2_plane, at the "bytesused" field. At least, add a notice about how to use, as maybe some day the bug will vanish. Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]>
1 parent c4b326e commit 9fdcd6a

File tree

1 file changed

+43
-19
lines changed

1 file changed

+43
-19
lines changed

Documentation/conf.py

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,31 @@
271271

272272
# Additional stuff for the LaTeX preamble.
273273
'preamble': '''
274+
% Use some font with UTF-8 support with XeLaTeX
275+
\\usepackage{fontspec}
276+
\\setsansfont{DejaVu Serif}
277+
\\setromanfont{DejaVu Sans}
278+
\\setmonofont{DejaVu Sans Mono}
279+
280+
% To allow adjusting table sizes
281+
\\usepackage{adjustbox}
282+
283+
'''
284+
}
285+
286+
# Fix reference escape troubles with Sphinx 1.4.x
287+
if major == 1 and minor > 3:
288+
latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
289+
290+
if major == 1 and minor <= 4:
291+
latex_elements['preamble'] += '\\usepackage[margin=0.5in, top=1in, bottom=1in]{geometry}'
292+
elif major == 1 and (minor > 5 or (minor == 5 and patch >= 3)):
293+
latex_elements['sphinxsetup'] = 'hmargin=0.5in, vmargin=1in'
294+
latex_elements['preamble'] += '\\fvset{fontsize=auto}\n'
295+
296+
# Customize notice background colors on Sphinx < 1.6:
297+
if major == 1 and minor < 6:
298+
latex_elements['preamble'] += '''
274299
\\usepackage{ifthen}
275300
276301
% Put notes in color and let them be inside a table
@@ -322,27 +347,26 @@
322347
}
323348
\\makeatother
324349
325-
% Use some font with UTF-8 support with XeLaTeX
326-
\\usepackage{fontspec}
327-
\\setsansfont{DejaVu Serif}
328-
\\setromanfont{DejaVu Sans}
329-
\\setmonofont{DejaVu Sans Mono}
330-
331-
% To allow adjusting table sizes
332-
\\usepackage{adjustbox}
333-
334350
'''
335-
}
336-
337-
# Fix reference escape troubles with Sphinx 1.4.x
338-
if major == 1 and minor > 3:
339-
latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
340351

341-
if major == 1 and minor <= 4:
342-
latex_elements['preamble'] += '\\usepackage[margin=0.5in, top=1in, bottom=1in]{geometry}'
343-
elif major == 1 and (minor > 5 or (minor == 5 and patch >= 3)):
344-
latex_elements['sphinxsetup'] = 'hmargin=0.5in, vmargin=1in'
345-
latex_elements['preamble'] += '\\fvset{fontsize=auto}\n'
352+
# With Sphinx 1.6, it is possible to change the Bg color directly
353+
# by using:
354+
# \definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
355+
# \definecolor{sphinxwarningBgColor}{RGB}{255,204,204}
356+
# \definecolor{sphinxattentionBgColor}{RGB}{255,255,204}
357+
# \definecolor{sphinximportantBgColor}{RGB}{192,255,204}
358+
#
359+
# However, it require to use sphinx heavy box with:
360+
#
361+
# \renewenvironment{sphinxlightbox} {%
362+
# \\begin{sphinxheavybox}
363+
# }
364+
# \\end{sphinxheavybox}
365+
# }
366+
#
367+
# Unfortunately, the implementation is buggy: if a note is inside a
368+
# table, it isn't displayed well. So, for now, let's use boring
369+
# black and white notes.
346370

347371
# Grouping the document tree into LaTeX files. List of tuples
348372
# (source start file, target name, title,

0 commit comments

Comments
 (0)