sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.46k stars 2.1k forks source link

colorrows not working #10928

Closed Gatherer closed 1 year ago

Gatherer commented 1 year ago

Describe the bug

The newly added colorrows feature seems not to work.

After 5.3 is out I started to update my documentations and replace (the old #6666 and #6671 syntax)

latex_booktabs = True
latex_zebra_stripes = True

with

latex_table_style = ['booktabs', 'colorrows']

While the booktabs feature works fine all row colors are always white.

Will continue testing tomorrow, maybe create a small example.

How to Reproduce

Example of used table

.. list-table::  AXI4-S TCP master interface
    :widths: 30 65
    :header-rows: 1

    * - **Name**
      - **Description**

    * - **m_axis_tcp_tvalid_out**
      - Master TVALID output

    * - **m_axis_tcp_tready_in**
      - Master TREADY input

    * - **m_axis_tcp_tdata_out**
      - Master TDATA output

    * - **m_axis_tcp_tkeep_out**
      - Master TKEEP output

    * - **m_axis_tcp_tlast_out**
      - Master TLAST output

Environment Information

N/A

Sphinx extensions

extensions = [ 'sphinx_rtd_theme', 'sphinx.ext.intersphinx', 'sphinx.ext.autodoc', 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', 'sphinx.ext.todo', 'sphinxcontrib.bibtex', 'sphinxcontrib.scalebybuilder', 'sphinxcontrib.globalsubs', 'sphinxcontrib.wavedrom', 'sphinxcontrib.inkscapeconverter' ]

Additional context

Linux amd-linux 5.4.0-97-generic #110-Ubuntu SMP Thu Jan 13 18:22:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux LuaTeX, Version 1.10.0 (TeX Live 2019/Debian)

AA-Turner commented 1 year ago

cc @jfbu

Gatherer commented 1 year ago

Can not test it in my work environment yet. Has to contact IT. For now no new information from my side. Will test more at home.

jfbu commented 1 year ago

I tested with the extensions listed and latex_engine set to lualatex which seems to be your use case and both with 5.3.0 and conf.py containing

latex_table_style = ['booktabs', 'colorrows']

and with 6.0.0beta2 and nothing in conf.py because the above is default anyhow I obtain this: Capture du 2022-10-19 11-55-31

Can you share the latex build log file (file ending in .log present in latex build repertory where produced pdf file resides) and the complete latex configuration in conf.py, particularly for the latex preamble or anything latex relatex such as things inserted by raw directive? Ideally please provide some as small as possible reproducible example.

jfbu commented 1 year ago

Have you by any chance kept some patches inherited from initial #6666 and #6671? The

latex_booktabs = True
latex_zebra_stripes = True

was never supported by any official Sphinx release.

jfbu commented 1 year ago

Also of note is that installing sphinx_rtd_theme via pip may forcefully downgrade the Sphinx version. As it stands sphinx_rtd_theme pins Docutils to 0.17.1 if I recall correctly and Sphinx to some earlier version (don't recall which one).

Gatherer commented 1 year ago

Have you by any chance kept some patches inherited from initial #6666 and #6671? The

latex_booktabs = True
latex_zebra_stripes = True

was never supported by any official Sphinx release.

No, no leftover code are used. After Stefan created the feature we made a patched version (v2.1.2-mle1) which is still in use. Pretty much the same code as it was in the original pull requests. Currently I do update our company Sphinx template to v5.3.

Also of note is that installing sphinx_rtd_theme via pip may forcefully downgrade the Sphinx version. As it stands sphinx_rtd_theme pins Docutils to 0.17.1 if I recall correctly and Sphinx to some earlier version (don't recall which one).

As sphinx_rtd_theme only supports Docutils < 0.18.0 we do use this one.

Can you share the latex build log file (file ending in .log present in latex build repertory

Yes, will do as soon I back home.

Currently used requirements text file to build the virtual environment.

docutils<0.18
https://github.com/brechtm/rinohtype/archive/refs/tags/v0.5.4.tar.gz
https://github.com/sphinx-doc/sphinx/archive/refs/tags/v5.3.0.tar.gz
sphinx_rtd_theme==1.0.0
sphinx-autobuild==2021.3.14
sphinxcontrib-bibtex==2.5.0
sphinxcontrib-globalsubs==0.1.0
sphinxcontrib-scalebybuilder==0.1.0
sphinxcontrib-svg2pdfconverter==1.2.1
sphinxcontrib-wavedrom==3.0.4
Gatherer commented 1 year ago

I did found the cause of the problem. I do not understand it but I can try to work around it. Maybe it's not even needed.

As requested the log file sphinx-project.log

Description of the problem.

We have a company template with a style, fonts etc. Part of it is a _templates folder wit a latex.tex_t file in it. The folder is added via templates_path = ['_templates']. If I remove the template colorrows works as expected. If it's added the tables stay plain white. I do not know if it's because of this specific template file or general.

latex.tex_t file renamed to be able to add it here. latex.tex_t.log

jfbu commented 1 year ago

@Gatherer Great that you figured that out and could provide all these details,

latex.tex_t file renamed to be able to add it here. latex.tex_t.log

Indeed it explains it, as we see from the diff of your company template from our current latex.tex_t template (which I comment next)

--- latex.tex_t 2022-10-19 21:45:28.637872301 +0200
+++ 10928_latex.tex_t   2022-10-19 21:36:58.650276376 +0200
@@ -9,31 +9,14 @@
   {** Add the LaTeX package luatex85 to your TeX installation, and try again **}
   \endinput\fi\fi}
 <% endif -%>
-\documentclass[<%= papersize %>,<%= pointsize %><%= classoptions %>]{<%= wrapperclass %>}
+\documentclass[<%= papersize %>,<%= pointsize %><%= classoptions %>]{<%= wrapperclass.replace('sphinx', 'mle') %>}
 \ifdefined\pdfpxdimen
    \let\sphinxpxdimen\pdfpxdimen\else\newdimen\sphinxpxdimen
 \fi \sphinxpxdimen=<%= pxunit %>\relax
-\ifdefined\pdfimageresolution
-    \pdfimageresolution= \numexpr \dimexpr1in\relax/\sphinxpxdimen\relax
-\fi
-%% let collapsible pdf bookmarks panel have high depth per default
-\PassOptionsToPackage{bookmarksdepth=5}{hyperref}
 <% if use_xindy -%>
 %% turn off hyperref patch of \index as sphinx.xdy xindy module takes care of
 %% suitable \hyperpage mark-up, working around hyperref-xindy incompatibility
 \PassOptionsToPackage{hyperindex=false}{hyperref}
-%% memoir class requires extra handling
-\makeatletter\@ifclassloaded{memoir}
-{\ifdefined\memhyperindexfalse\memhyperindexfalse\fi}{}\makeatother
-<% endif %>
-<% if booktabs -%>
-\PassOptionsToPackage{booktabs}{sphinx}
-<% endif -%>
-<% if borderless -%>
-\PassOptionsToPackage{borderless}{sphinx}
-<% endif -%>
-<% if colorrows -%>
-\PassOptionsToPackage{colorrows}{sphinx}
 <% endif -%>
 <%= passoptionstopackages %>
 \PassOptionsToPackage{warn}{textcomp}
@@ -46,14 +29,12 @@
 <%= substitutefont %>
 <%= textcyrillic %>
 <%= fontpkg %>
-<%= fontsubstitution %>
 <%= textgreek %>
 <%= fncychap %>
 \usepackage<%= sphinxpkgoptions %>{sphinx}
 <%= sphinxsetup %>
 <%= fvset %>
 <%= geometry %>
-<%= extrapackages %>

 <%- for name, option in packages %>
 <%- if option %>
@@ -64,14 +45,7 @@
 <%- endfor %>

 <%= hyperref %>
-<%- for name, option in packages_after_hyperref %>
-<%- if option %>
-\usepackage[<%= option %>]{<%= name %>}
-<%- else %>
-\usepackage{<%= name %>}
-<%- endif %>
-<%- endfor %>
-
+<%= glossaries %>
 <%= contentsname %>
 \usepackage{sphinxmessages}
 <%= tocdepth %>
@@ -80,7 +54,7 @@

 \title{<%= title %>}
 \date{<%= date %>}
-\release{<%= release | e %>}
+\release{<%= release %>}
 \author{<%= author %>}
 <%- if logofilename %>
 \newcommand{\sphinxlogo}{\sphinxincludegraphics{<%= logofilename %>}\par}
@@ -93,6 +67,8 @@
 \renewcommand{\releasename}{}
 <%- endif %>
 <%= makeindex %>
+<%= abbreviations %>
+<%= makeglossaries %>
 \begin{document}
 <%= shorthandoff %>
 \pagestyle{empty}
@@ -100,6 +76,7 @@
 \pagestyle{plain}
 <%= tableofcontents %>
 \pagestyle{normal}
+<%= printacronyms %>
 <%= body %>
 <%= atendofbody %>
 <%= indices %>

Clearly the relevant part is

-<% if colorrows -%>
-\PassOptionsToPackage{colorrows}{sphinx}

This indeed is enough to explain it.

Make sure your company does not have additionnally also customized templates named longtable.tex_t or tabular.tex_t or tabulary.tex_t but as you said 'booktabs' works fine I suppose not.

As per the above, we see that mainly your company template is not updated for Sphinx 5.3.0, I can see the extras which were added, you need to apply the same extras but to current latex.tex_t.

Thanks also the latex log. I noticed the following in there

(./mle.sty
Package: mle 2018/01/18 v1.0.0 MLE corporate design

(/usr/share/texlive/texmf-dist/tex/xelatex/xltxtra/xltxtra.sty
Package: xltxtra 2018/12/31 v0.7 Improvements for the "XeLaTeX" format

Package xltxtra Warning: 
 XLTXTRA IS TO BE USED ONLY UNDER XETEX. LOAD FONTSPEC DIRECTLY, INSTEAD.
 ABORTING LOADING.

so you could consider modifying mle.sty to make the loading of xltxtra conditional on being used with xelatex not lualatex as here, although one can also live with this warning in the log and ignore it.

I did not see anything else of relevance except that your style file loads tcolorbox so I guess some Sphinx environments are redefined to use it (for example for warning boxes?).

Make me thing Sphinx should perhaps provide a way to use tcolorbox in place of the more rudimentary sphinxpackageboxes which however is orders of magnitude faster than tcolorbox, but much more limited in what it can do in terms of box decorations.

Gatherer commented 1 year ago

@jfbu Thank for the info.

Yes the template is pretty old. We still use a patched 2.1.2 version. Lack of time, workload and why change something working prevented us from updating. Not the task started.

I will work through it. Thanks for the informations and sorry for the false alarm.

jfbu commented 1 year ago

Thanks for the informations and sorry for the false alarm.

No worries, to the contrary, hopefully this will help those who have been using the template overwrite mechanism. The changes done here at Sphinx have consisted into additions to the templates, and your old one works fine except that in the colorrows case a crucial activation was thus omitted. Rather than updating the template you can also use the 'passoptionstopackages' key of configuration dict variable latex_elements in file conf.py to pass 'colorrows' as option to 'sphinx' LaTeX package and this should fix it.

latex_elements = {
    'passoptionstopackages': r'\PassOptionsToPackage{colorrows}{sphinx}',
}