Anonymous avatar Anonymous committed e083072

Support all rst admonitions in LaTeX.

Comments (0)

Files changed (4)

 
 * sphinx.ext.autodoc: descriptors are detected properly now.
 
+* sphinx.latexwriter: implement all reST admonitions, not just ``note``
+  and ``warning``.
+
 * Lots of little fixes to the LaTeX output and style.
 
 * Fix OpenSearch template and make template URL absolute.  The
 slashes.  All values, parameters and suchlike referring to "documents" expect
 such a document name.
 
-.. cfunction:: Class::method(int bla, int foo) const
-
-   pass
-
-.. cmdoption:: --longopt <arg>
-
-.. class:: Test
-
-   .. method:: X
-
 
 The TOC tree
 ------------

sphinx/latexwriter.py

     def depart_image(self, node):
         pass
 
-    def visit_note(self, node):
-        self.body.append('\n\\begin{notice}[note]')
-    def depart_note(self, node):
+    def _make_visit_admonition(name):
+        def visit_admonition(self, node):
+            self.body.append('\n\\begin{notice}[%s]' % name)
+        return visit_admonition
+    def depart_admonition(self, node):
         self.body.append('\\end{notice}\n')
 
-    def visit_warning(self, node):
-        self.body.append('\n\\begin{notice}[warning]')
-    def depart_warning(self, node):
-        self.body.append('\\end{notice}\n')
+    visit_attention = _make_visit_admonition('attention')
+    depart_attention = depart_admonition
+    visit_caution = _make_visit_admonition('caution')
+    depart_caution = depart_admonition
+    visit_danger = _make_visit_admonition('danger')
+    depart_danger = depart_admonition
+    visit_error = _make_visit_admonition('error')
+    depart_error = depart_admonition
+    visit_hint = _make_visit_admonition('hint')
+    depart_hint = depart_admonition
+    visit_important = _make_visit_admonition('important')
+    depart_important = depart_admonition
+    visit_note = _make_visit_admonition('note')
+    depart_note = depart_admonition
+    visit_tip = _make_visit_admonition('tip')
+    depart_tip = depart_admonition
+    visit_warning = _make_visit_admonition('warning')
+    depart_warning = depart_admonition
 
     def visit_versionmodified(self, node):
         self.body.append('\\%s' % node['type'])

sphinx/texinputs/sphinx.sty

   \end{tabular}
 }
 
+% Notices / Admonitions
+%
 \newlength{\py@noticelength}
 
 \newcommand{\py@heavybox}{
   \fbox{\TheSbox}
 }
 
-% a 'note' is as plain as it gets:
+% Some are quite plain:
 \newcommand{\py@noticelabel@note}{Note:}
 \newcommand{\py@noticestart@note}{}
 \newcommand{\py@noticeend@note}{}
+\newcommand{\py@noticelabel@hint}{Hint:}
+\newcommand{\py@noticestart@hint}{}
+\newcommand{\py@noticeend@hint}{}
+\newcommand{\py@noticelabel@important}{Important:}
+\newcommand{\py@noticestart@important}{}
+\newcommand{\py@noticeend@important}{}
+\newcommand{\py@noticelabel@tip}{Tip:}
+\newcommand{\py@noticestart@tip}{}
+\newcommand{\py@noticeend@tip}{}
 
-% a 'warning' gets more visible distinction:
+% Others gets more visible distinction:
 \newcommand{\py@noticelabel@warning}{Warning:}
 \newcommand{\py@noticestart@warning}{\py@heavybox}
 \newcommand{\py@noticeend@warning}{\py@endheavybox}
+\newcommand{\py@noticelabel@caution}{Caution:}
+\newcommand{\py@noticestart@caution}{\py@heavybox}
+\newcommand{\py@noticeend@caution}{\py@endheavybox}
+\newcommand{\py@noticelabel@attention}{Attention:}
+\newcommand{\py@noticestart@attention}{\py@heavybox}
+\newcommand{\py@noticeend@attention}{\py@endheavybox}
+\newcommand{\py@noticelabel@danger}{Danger:}
+\newcommand{\py@noticestart@danger}{\py@heavybox}
+\newcommand{\py@noticeend@danger}{\py@endheavybox}
+\newcommand{\py@noticelabel@error}{Error:}
+\newcommand{\py@noticestart@error}{\py@heavybox}
+\newcommand{\py@noticeend@error}{\py@endheavybox}
+
 
 \newenvironment{notice}[1][note]{
   \def\py@noticetype{#1}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.