Marcio Mazza avatar Marcio Mazza committed 4ef9cc6

Make the 'bibliography TOC fix' specific to document class howto/manual (article/report)

Comments (0)

Files changed (3)

sphinx/texinputs/sphinx.sty

 }
 
 
-% Fix the index and bibliography environments to add an entry to the Table of
+% Fix the index environment to add an entry to the Table of
 % Contents; this is much nicer than just having to jump to the end of the book
 % and flip around, especially with multiple indexes.
 %
+% A similiar fix must be done to the bibliography environment, although
+% dependant on document class. In particular, the '\addcontentsline' command
+% should use 'chapter' for a report and 'section' for an article.
+% See sphinxmanual.cls and sphinxhowto.cls for specific fixes.
+%
 \let\py@OldTheindex=\theindex
 \renewcommand{\theindex}{
   \cleardoublepage
   \addcontentsline{toc}{chapter}{\indexname}
 }
 
-\let\py@OldThebibliography=\thebibliography
-\renewcommand{\thebibliography}[1]{
-  \cleardoublepage
-  \phantomsection
-  \py@OldThebibliography{1}
-  \addcontentsline{toc}{chapter}{\bibname}
-}
-
 % Include hyperref last.
 \RequirePackage[colorlinks,breaklinks,
                 linkcolor=InnerLinkColor,filecolor=OuterLinkColor,

sphinx/texinputs/sphinxhowto.cls

 \pagenumbering{arabic}		% ToC & chapters
 
 \thispagestyle{empty}
+
+% Fix the bibliography environment to add an entry to the Table of
+% Contents.
+% For an article document class this environment is a section,
+% so no page break before it.
+\let\py@OldThebibliography=\thebibliography
+\renewcommand{\thebibliography}[1]{
+  \phantomsection
+  \py@OldThebibliography{1}
+  \addcontentsline{toc}{section}{\bibname}
+}

sphinx/texinputs/sphinxmanual.cls

 %
 \renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}}
 \renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}}
+
+% Fix the bibliography environment to add an entry to the Table of
+% Contents.
+% For a report document class this environment is a chapter.
+\let\py@OldThebibliography=\thebibliography
+\renewcommand{\thebibliography}[1]{
+  \cleardoublepage
+  \phantomsection
+  \py@OldThebibliography{1}
+  \addcontentsline{toc}{chapter}{\bibname}
+}
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.