SF.net SVN: docutils:[9942 ] trunk/docutils

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9942
          http://sourceforge.net/p/docutils/code/9942
Author:   milde
Date:     2024-09-29 09:31:17 +0000 (Sun, 29 Sep 2024)
Log Message:
-----------
LaTeX writers update.

Deprecate `writers.latex2e.SortableDict`.

Remove `writers.latex2e.Table.get_caption` (obsolete).

Test and fix local ToC without global ToC.
Package "minitoc" needs a ``\faketableofcontents`` in this case so that a
".toc" file is generated.
Move the conditional insertion code in `depart_document()` before the
conversion of `self.requirements` from a dict to a list, so that the
test works again as intended.

Modified Paths:
--------------
    trunk/docutils/RELEASE-NOTES.rst
    trunk/docutils/docutils/writers/latex2e/__init__.py
    trunk/docutils/docutils/writers/latex2e/xelatex.tex
    trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
    trunk/docutils/test/functional/expected/xetex-cyrillic.tex
    trunk/docutils/test/test_writers/test_latex2e.py
    trunk/docutils/test/test_writers/test_latex2e_misc.py

Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst	2024-09-28 21:23:32 UTC (rev 9941)
+++ trunk/docutils/RELEASE-NOTES.rst	2024-09-29 09:31:17 UTC (rev 9942)
@@ -113,6 +113,8 @@
 * Remove `io.BinaryFileOutput` and `core.publish_cmdline_to_binary()`
   in Docutils 0.24.
 
+* Remove `writers.latex2e.SortableDict` in Docutils 0.24.
+
 * Remove `parsers.rst.directives.CSVTable.HeaderDialect`
   in Docutils 1.0.
 
@@ -365,6 +367,8 @@
     Python 2 compatibility hacks
   `docutils.utils.Reporter.set_conditions()`
     obsolete
+  `writers.latex2e.Table.get_caption`
+    obsolete
 
 * New files:
 

Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py	2024-09-28 21:23:32 UTC (rev 9941)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py	2024-09-29 09:31:17 UTC (rev 9942)
@@ -490,9 +490,15 @@
 class SortableDict(dict):
     """Dictionary with additional sorting methods
 
-    Tip: use key starting with with '_' for sorting before small letters
-         and with '~' for sorting after small letters.
+    Deprecated. Will be removed in Docutils 0.24.
     """
+
+    def __init__(self, *args, **kwargs):
+        warnings.warn('`writers.latex2e.SortableDict` is obsolete'
+                      ' and will be removed in Docutils 0.24.',
+                      DeprecationWarning, stacklevel=2)
+        super().__init__(*args, **kwargs)
+
     def sortedkeys(self):
         """Return sorted list of keys"""
         return sorted(self.keys())
@@ -1025,19 +1031,6 @@
         except IndexError:
             return 'l'
 
-    def get_caption(self) -> str:
-        """Deprecated. Will be removed in Docutils 0.22."""
-        warnings.warn('`writers.latex2e.Table.get_caption()` is obsolete'
-                      ' and will be removed in Docutils 0.22.',
-                      DeprecationWarning, stacklevel=2)
-
-        if not self.caption:
-            return ''
-        caption = ''.join(self.caption)
-        if 1 == self._translator.thead_depth():
-            return r'\caption{%s}\\' '\n' % caption
-        return r'\caption[]{%s (... continued)}\\' '\n' % caption
-
     def need_recurse(self):
         if self._latex_type == 'longtable':
             return 1 == self._translator.thead_depth()
@@ -1257,9 +1250,9 @@
         self.head_prefix = [r'\documentclass[%s]{%s}' %
                             (self.documentoptions,
                              settings.documentclass)]
-        self.requirements = SortableDict()  # made a list in depart_document()
+        self.requirements = {}  # converted to a list in depart_document()
         self.latex_preamble = [settings.latex_preamble]
-        self.fallbacks = SortableDict()  # made a list in depart_document()
+        self.fallbacks = {}  # converted to a list in depart_document()
         self.pdfsetup = []  # PDF properties (hyperref package)
         self.title = []
         self.subtitle = []
@@ -2023,10 +2016,6 @@
         if (self.babel.otherlanguages
             or self.babel.language not in ('', 'english')):
             self.requirements['babel'] = self.babel()
-        # * conditional requirements (before style sheet)
-        self.requirements = self.requirements.sortedvalues()
-        # * coditional fallback definitions (after style sheet)
-        self.fallbacks = self.fallbacks.sortedvalues()
         # * PDF properties
         self.pdfsetup.append(PreambleCmds.linking % self.hyperref_options)
         if self.pdfauthor:
@@ -2044,6 +2033,12 @@
         # * make sure to generate a toc file if needed for local contents:
         if 'minitoc' in self.requirements and not self.has_latex_toc:
             self.out.append('\n\\faketableofcontents % for local ToCs\n')
+        # * conditional requirements (before style sheet)
+        self.requirements = [self.requirements[key]
+                             for key in sorted(self.requirements.keys())]
+        # * coditional fallback definitions (after style sheet)
+        self.fallbacks = [self.fallbacks[key]
+                          for key in sorted(self.fallbacks.keys())]
 
     def make_title(self) -> None:
         # Auxiliary function called by `self.depart_document()`.

Modified: trunk/docutils/docutils/writers/latex2e/xelatex.tex
===================================================================
--- trunk/docutils/docutils/writers/latex2e/xelatex.tex	2024-09-28 21:23:32 UTC (rev 9941)
+++ trunk/docutils/docutils/writers/latex2e/xelatex.tex	2024-09-29 09:31:17 UTC (rev 9942)
@@ -2,7 +2,7 @@
 % rubber: set program xelatex
 \usepackage{fontspec}
 % \defaultfontfeatures{Scale=MatchLowercase}
-% straight double quotes (defined T1 but missing in TU):
+% straight double quotes (defined in T1 but missing in TU):
 \ifdefined \UnicodeEncodingName
   \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
     {\addfontfeatures{RawFeature=-tlig,Mapping=}\char34}}%

Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex	2024-09-28 21:23:32 UTC (rev 9941)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex	2024-09-29 09:31:17 UTC (rev 9942)
@@ -3,7 +3,7 @@
 % rubber: set program xelatex
 \usepackage{fontspec}
 % \defaultfontfeatures{Scale=MatchLowercase}
-% straight double quotes (defined T1 but missing in TU):
+% straight double quotes (defined in T1 but missing in TU):
 \ifdefined \UnicodeEncodingName
   \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
     {\addfontfeatures{RawFeature=-tlig,Mapping=}\char34}}%

Modified: trunk/docutils/test/functional/expected/xetex-cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/xetex-cyrillic.tex	2024-09-28 21:23:32 UTC (rev 9941)
+++ trunk/docutils/test/functional/expected/xetex-cyrillic.tex	2024-09-29 09:31:17 UTC (rev 9942)
@@ -3,7 +3,7 @@
 % rubber: set program xelatex
 \usepackage{fontspec}
 % \defaultfontfeatures{Scale=MatchLowercase}
-% straight double quotes (defined T1 but missing in TU):
+% straight double quotes (defined in T1 but missing in TU):
 \ifdefined \UnicodeEncodingName
   \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
     {\addfontfeatures{RawFeature=-tlig,Mapping=}\char34}}%

Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py	2024-09-28 21:23:32 UTC (rev 9941)
+++ trunk/docutils/test/test_writers/test_latex2e.py	2024-09-29 09:31:17 UTC (rev 9942)
@@ -177,6 +177,14 @@
     dict(parts, requirements=parts['requirements']
          + '\\usepackage{graphicx}\n'))
 
+head_minitoc = head_template.substitute(
+    dict(parts, requirements=parts['requirements']
+         + '%% local table of contents\n'
+           '\\usepackage{minitoc}\n'
+           '\\dosecttoc\n'
+           '\\mtcsetdepth{secttoc}{5}\n'
+           '\\setcounter{secnumdepth}{0}\n'))
+
 head_textcomp = head_template.substitute(
     dict(parts, requirements=parts['requirements']
          + '\\usepackage{textcomp} % text symbol macros\n'))
@@ -249,6 +257,40 @@
 """],
 ]
 
+samples_default['minitoc'] = [
+# local toc reqires the minitoc package
+# and either \tableofcontents or \faketableofcontents
+["""\
+section with local ToC
+======================
+
+.. contents::
+   :local:
+
+section not in local toc
+========================
+""",
+head_minitoc + r"""
+
+\section{section with local ToC%
+  \label{section-with-local-toc}%
+}
+
+\phantomsection\label{contents}
+\mtcsettitle{secttoc}{}
+\secttoc
+
+
+\section{section not in local toc%
+  \label{section-not-in-local-toc}%
+}
+
+\faketableofcontents % for local ToCs
+
+\end{document}
+"""],
+]
+
 samples_docutils_toc['table_of_contents'] = [
 ["""\
 .. contents:: Table of Contents

Modified: trunk/docutils/test/test_writers/test_latex2e_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e_misc.py	2024-09-28 21:23:32 UTC (rev 9941)
+++ trunk/docutils/test/test_writers/test_latex2e_misc.py	2024-09-29 09:31:17 UTC (rev 9942)
@@ -143,6 +143,10 @@
             core.publish_string('warnings test', writer=latex2e.Writer(),
                                 settings_overrides=settings)
 
+    def test_deprecation_warnings(self):
+        with self.assertWarnsRegex(DeprecationWarning, 'will be removed'):
+            latex2e.SortableDict(deprecated=True)
 
+
 if __name__ == '__main__':
     unittest.main()

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



_______________________________________________
Docutils-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-checkins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.