Anonymous avatar Anonymous committed 1725e92

Fix bug in sphinx.sty and the latexwriter for objects without a defined module.

Comments (0)

Files changed (2)

sphinx/latexwriter.py

         elif d.env in ('datadesc', 'classdesc*', 'excdesc', 'csimplemacrodesc'):
             t2 = "{%s}" % (d.name)
         elif d.env == 'methoddesc':
-            t2 = "[%s]{%s}{%s}" % (d.cls, d.name, d.params)
+            if d.cls:
+                t2 = "[%s]{%s}{%s}" % (d.cls, d.name, d.params)
+            else:
+                t2 = "{%s}{%s}" % (d.name, d.params)
         elif d.env == 'memberdesc':
-            t2 = "[%s]{%s}" % (d.cls, d.name)
+            if d.cls:
+                t2 = "[%s]{%s}" % (d.cls, d.name)
+            else:
+                t2 = "{%s}" % d.name
         elif d.env == 'cfuncdesc':
             t2 = "{%s}{%s}{%s}" % (d.type, d.name, d.params)
         elif d.env == 'cmemberdesc':

sphinx/texinputs/sphinx.sty

 \newcommand{\py@thismodule}{}
 \newcommand{\py@thismodulekey}{}
 \newcommand{\py@thismoduletype}{}
+\newcommand{\py@emptymodule}{}
 
 % Module index types
 \newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}
 % \begin{funcdesc}{name}{args}
 \newcommand{\funcline}[2]{%
   \funclineni{#1}{#2}%
-  \index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}}
+  \ifx\py@thismodule\py@emptymodule%
+  \index{#1@{\py@idxcode{#1()}}}%
+  \else%
+  \index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}%
+  \fi}
 \newenvironment{funcdesc}[2]{
   \begin{fulllineitems}
     \funcline{#1}{#2}
 % \begin{classdesc}{name}{constructor args}
 \newcommand{\classline}[2]{
   \py@sigline{\strong{class }\bfcode{#1}}{#2}%
-  \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}}
+  \ifx\py@thismodule\py@emptymodule%
+  \index{#1@{\py@idxcode{#1}} (class)}%
+  \else%
+  \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}%
+  \fi}
 \newenvironment{classdesc}[2]{
   % Using \renewcommand doesn't work for this, for unknown reasons:
   \global\def\py@thisclass{#1}
   \global\def\py@thisclass{#1}
   \begin{fulllineitems}
     \item[\strong{class }\code{\bfcode{#1}}%
-      \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
+      \ifx\py@thismodule\py@emptymodule%
+      \index{#1@{\py@idxcode{#1}} (class)}%
+      \else%
+      \index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}%
+      \fi]
 }{\end{fulllineitems}}
 
 % \begin{excclassdesc}{name}{constructor args}
   \global\def\py@thisclass{#1}
   \begin{fulllineitems}
     \py@sigline{\strong{exception }\bfcode{#1}}{#2}%
-    \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}
+    \ifx\py@thismodule\py@emptymodule%
+    \index{#1@{\py@idxcode{#1}} (exception)}%
+    \else%
+    \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}%
+    \fi
 }{\end{fulllineitems}}
 
 % There is no corresponding {excclassdesc*} environment.  To describe
 \newenvironment{excdesc}[1]{
   \begin{fulllineitems}
     \item[\strong{exception }\bfcode{#1}%
-          \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
+          \ifx\py@thismodule\py@emptymodule%
+          \index{#1@{\py@idxcode{#1}} (exception)}%
+          \else%
+          \index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}%
+          \fi]
 }{\end{fulllineitems}}
 
 % Module data or constants: ----------------------------------------------
 % \begin{datadesc}{name}
 \newcommand{\dataline}[1]{%
-  \datalineni{#1}\index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}}
+  \datalineni{#1}\ifx\py@thismodule\py@emptymodule%
+    \index{#1@{\py@idxcode{#1}} (data)}%
+    \else%
+    \index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}%
+    \fi}
 \newenvironment{datadesc}[1]{
   \begin{fulllineitems}
     \dataline{#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.