Skip to contentSkip to conversation

Two additional patches for Documentation/conf.py

PATCH New Mauro Carvalho Chehab 1 participant 3 messages Aug 21, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Two additional patches for Documentation/conf.py

The first patch in this series use the type of notice box to color the box, providing a functionality that it is also used on the HTML theme we use.

The second patch is a fix for a non-fatal error when building LaTeX on interactive mode.

Mauro Carvalho Chehab (2):
docs-rst: Use better colors for note/warning/attention boxes
docs-rst: Fix an warning when in interactive mode

 Documentation/conf.py | 44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 docs-rst: Use better colors for note/warning/attention boxes

Instead of painting the box with gray, let's use a colored box. IMHO, that makes easier to warn users about some issue pointed by the Sphinx. It also matches to what we do already with the HTML output.

---
 Documentation/conf.py | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)
Documentation/conf.py +24 -10
index 011f6dac0c6c..f71b71048e37 100644
@@ -277,11 +277,12 @@ latex_elements = {
         % Allow generate some pages in landscape
         \\usepackage{lscape}
 
-        % Put notes in gray color and let them be inside a table
-
-        \\definecolor{MyGray}{rgb}{0.80,0.80,0.80}
-
-        \\makeatletter\\newenvironment{graybox}{%
+        % Put notes in color and let them be inside a table
+	\\definecolor{NoteColor}{RGB}{204,255,255}
+	\\definecolor{WarningColor}{RGB}{255,204,204}
+	\\definecolor{AttentionColor}{RGB}{255,255,204}
+	\\definecolor{OtherColor}{RGB}{204,204,204}
+        \\makeatletter\\newenvironment{coloredbox}[1]{%
 	   \\newlength{\\py@noticelength}
 	   \\setlength{\\fboxrule}{1pt}
 	   \\setlength{\\fboxsep}{7pt}
@@ -289,20 +290,33 @@ latex_elements = {
 	   \\addtolength{\\py@noticelength}{-2\\fboxsep}
 	   \\addtolength{\\py@noticelength}{-2\\fboxrule}
            \\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\py@noticelength}}{\\end{minipage}\\end{lrbox}%
-           \\colorbox{MyGray}{\\usebox{\\@tempboxa}}
+	   \\ifthenelse%
+	      {\\equal{\\py@noticetype}{note}}%
+	      {\\colorbox{NoteColor}{\\usebox{\\@tempboxa}}}%
+	      {%
+	         \\ifthenelse%
+	         {\\equal{\\py@noticetype}{warning}}%
+	         {\\colorbox{WarningColor}{\\usebox{\\@tempboxa}}}%
+		 {%
+	            \\ifthenelse%
+	            {\\equal{\\py@noticetype}{attention}}%
+	            {\\colorbox{AttentionColor}{\\usebox{\\@tempboxa}}}%
+	            {\\colorbox{OtherColor}{\\usebox{\\@tempboxa}}}%
+		 }%
+	      }%
         }\\makeatother
 
         \\makeatletter
-        \\renewenvironment{notice}[2]{
-          \\begin{graybox}
-          \\bf\\it
+        \\renewenvironment{notice}[2]{%
           \\def\\py@noticetype{#1}
+          \\begin{coloredbox}{#1}
+          \\bf\\it
           \\par\\strong{#2}
           \\csname py@noticestart@#1\\endcsname
         }
 	{
           \\csname py@noticeend@\\py@noticetype\\endcsname
-          \\end{graybox}
+          \\end{coloredbox}
         }
 	\\makeatother
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 docs-rst: Fix an warning when in interactive mode

In reply to Mauro Carvalho Chehab

When XeLaTeX is in interactive mode, it complains that py@noticelength already exists. Rename it and declare it only once to avoid such messages.

---
 Documentation/conf.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Documentation/conf.py +5 -5
index f71b71048e37..42045c26581b 100644
@@ -282,14 +282,14 @@ latex_elements = {
 	\\definecolor{WarningColor}{RGB}{255,204,204}
 	\\definecolor{AttentionColor}{RGB}{255,255,204}
 	\\definecolor{OtherColor}{RGB}{204,204,204}
+        \\newlength{\\mynoticelength}
         \\makeatletter\\newenvironment{coloredbox}[1]{%
-	   \\newlength{\\py@noticelength}
 	   \\setlength{\\fboxrule}{1pt}
 	   \\setlength{\\fboxsep}{7pt}
-	   \\setlength{\\py@noticelength}{\\linewidth}
-	   \\addtolength{\\py@noticelength}{-2\\fboxsep}
-	   \\addtolength{\\py@noticelength}{-2\\fboxrule}
-           \\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\py@noticelength}}{\\end{minipage}\\end{lrbox}%
+	   \\setlength{\\mynoticelength}{\\linewidth}
+	   \\addtolength{\\mynoticelength}{-2\\fboxsep}
+	   \\addtolength{\\mynoticelength}{-2\\fboxrule}
+           \\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\mynoticelength}}{\\end{minipage}\\end{lrbox}%
 	   \\ifthenelse%
 	      {\\equal{\\py@noticetype}{note}}%
 	      {\\colorbox{NoteColor}{\\usebox{\\@tempboxa}}}%
Signature · 1 line
2.7.4