gminick / sphinx-rst2pdf-builder
fork of sphinx
Direct rst to pdf builder using rst2pdf tool.
Clone this repository (size: 7.7 MB): HTTPS / SSH
$ hg clone http://bitbucket.org/gminick/sphinx-rst2pdf-builder/
| commit 1356: | 096b498b6429 |
| parent 1355: | 245d39005217 |
| branch: | default |
start TOC in a new page
8 months ago
Changed (Δ131 bytes):
raw changeset »
sphinx/builders/pdf.py (13 lines added, 9 lines removed)
Up to file-list sphinx/builders/pdf.py:
| … | … | @@ -97,6 +97,9 @@ class PDFBuilder(Builder): |
97 |
97 |
tree.append(index_nodes) |
98 |
98 |
|
99 |
99 |
# Generate Contents topic manually |
100 |
||
101 |
output='.. raw:: pdf\n\n PageBreak \n\n' |
|
102 |
pb=docutils.core.publish_doctree(output)[0] |
|
100 |
103 |
contents=nodes.topic(classes=['contents']) |
101 |
104 |
contents+=nodes.title('') |
102 |
105 |
contents[0]+=nodes.Text( langmod.labels['contents']) |
| … | … | @@ -104,21 +107,22 @@ class PDFBuilder(Builder): |
104 |
107 |
pending=nodes.topic() |
105 |
108 |
contents.append(pending) |
106 |
109 |
pending.details={} |
110 |
tree.insert(-2,pb) |
|
107 |
111 |
tree.insert(-2,contents) |
108 |
112 |
contTrans=PDFContents(tree) |
109 |
113 |
contTrans.startnode=pending |
110 |
114 |
contTrans.apply() |
111 |
115 |
|
112 |
116 |
|
113 |
#for pendingnode in tree.traverse(addnodes.pending_xref): |
|
114 |
## This needs work, need to keep track of all targets |
|
115 |
## so I don't replace and create hanging refs, which |
|
116 |
## crash |
|
117 |
#if pendingnode['reftarget'] in ['genindex']: |
|
118 |
#pendingnode.replace_self(nodes.reference(text=pendingnode.astext(), |
|
119 |
#refuri=pendingnode['reftarget'])) |
|
120 |
#else: |
|
121 |
|
|
117 |
for pendingnode in tree.traverse(addnodes.pending_xref): |
|
118 |
# This needs work, need to keep track of all targets |
|
119 |
# so I don't replace and create hanging refs, which |
|
120 |
# crash |
|
121 |
if pendingnode['reftarget'] in ['genindex']: |
|
122 |
pendingnode.replace_self(nodes.reference(text=pendingnode.astext(), |
|
123 |
refuri=pendingnode['reftarget'])) |
|
124 |
else: |
|
125 |
pass |
|
122 |
126 |
return tree |
123 |
127 |
|
124 |
128 |
