Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit c6c309e

Browse files
committed
A bit cleaner symlink
1 parent 0a30a52 commit c6c309e

File tree

3 files changed

+23
-75
lines changed

3 files changed

+23
-75
lines changed
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
#! /usr/bin/env bash
22
cd $SAGE_ROOT/src/doc
33
$MAKE doc-html
4-
if [ ! -e $SAGE_LOCAL/share/doc/sage/html/en/web_pdf ] ; then
5-
ln -sr $SAGE_LOCAL/share/doc/sage/html/en/../.. $SAGE_LOCAL/share/doc/sage/html/en/web_pdf
6-
fi

src/doc/en/website/templates/index.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ <h2>
4141
<a class="biglink" href="tutorial/index.html">
4242
Tutorial
4343
</a>
44-
<a title="Download PDF" class="pdf" href="web_pdf/pdf/en/tutorial/SageTutorial.pdf">
44+
<a title="Download PDF" class="pdf" href="pdf/en/tutorial/SageTutorial.pdf">
4545
<img class="icon" src="_static/pdf.png"></img>
4646
</a>
4747
<br>
@@ -57,7 +57,7 @@ <h2>
5757
<a class="biglink" href="faq/index.html">
5858
FAQs
5959
</a>
60-
<a title="Download PDF" class="pdf" href="web_pdf/pdf/en/faq/faq.pdf">
60+
<a title="Download PDF" class="pdf" href="pdf/en/faq/faq.pdf">
6161
<img class="icon" src="_static/pdf.png"></img>
6262
</a>
6363
<br>
@@ -81,7 +81,7 @@ <h2>
8181
Thematic Tutorials
8282
</a>
8383
<a title="Download PDF" class="pdf"
84-
href="web_pdf/pdf/en/thematic_tutorials/thematic_tutorials.pdf">
84+
href="pdf/en/thematic_tutorials/thematic_tutorials.pdf">
8585
<img class="icon" src="_static/pdf.png"></img>
8686
</a>
8787
<br>
@@ -102,7 +102,7 @@ <h2>
102102
<a class="biglink" href="prep/index.html">
103103
PREP Tutorials
104104
</a>
105-
<a title="Download PDF" class="pdf" href="web_pdf/pdf/en/prep/prep_tutorials.pdf">
105+
<a title="Download PDF" class="pdf" href="pdf/en/prep/prep_tutorials.pdf">
106106
<img class="icon" src="_static/pdf.png"></img>
107107
</a>
108108
<br>
@@ -137,7 +137,7 @@ <h2>
137137
<a class="biglink" href="reference/index.html">
138138
Reference Manual
139139
</a>
140-
<a title="Link to PDF" class="pdf" href="web_pdf/pdf/en/reference/index.html">
140+
<a title="Link to PDF" class="pdf" href="pdf/en/reference/index.html">
141141
<img class="icon" src="_static/pdf.png"></img>
142142
</a>
143143
<br>
@@ -178,7 +178,7 @@ <h2>
178178
<a class="biglink" href="installation/index.html">
179179
Installation Guide
180180
</a>
181-
<a title="Download PDF" class="pdf" href="web_pdf/pdf/en/installation/installation.pdf">
181+
<a title="Download PDF" class="pdf" href="pdf/en/installation/installation.pdf">
182182
<img class="icon" src="_static/pdf.png"></img>
183183
</a>
184184
<br>
@@ -196,7 +196,7 @@ <h2>
196196
<a class="biglink" href="developer/index.html">
197197
Developer's Guide
198198
</a>
199-
<a title="Download PDF" class="pdf" href="web_pdf/pdf/en/developer/developer.pdf">
199+
<a title="Download PDF" class="pdf" href="pdf/en/developer/developer.pdf">
200200
<img class="icon" src="_static/pdf.png"></img>
201201
</a>
202202
<br>
@@ -231,7 +231,7 @@ <h2>
231231
<a class="biglink" href="a_tour_of_sage/index.html">
232232
A Tour of Sage
233233
</a>
234-
<a title="Download PDF" class="pdf" href="web_pdf/pdf/en/a_tour_of_sage/a_tour_of_sage.pdf">
234+
<a title="Download PDF" class="pdf" href="pdf/en/a_tour_of_sage/a_tour_of_sage.pdf">
235235
<img class="icon" src="_static/pdf.png"></img>
236236
</a>
237237
<br>
@@ -248,7 +248,7 @@ <h2>
248248
<a class="biglink" href="constructions/index.html">
249249
Constructions
250250
</a>
251-
<a title="Download PDF" class="pdf" href="web_pdf/pdf/en/constructions/constructions.pdf">
251+
<a title="Download PDF" class="pdf" href="pdf/en/constructions/constructions.pdf">
252252
<img class="icon" src="_static/pdf.png"></img>
253253
</a>
254254
<br>

src/sage_docbuild/__init__.py

Lines changed: 14 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,7 @@ class WebsiteBuilder(DocBuilder):
399399
def html(self):
400400
"""
401401
After we've finished building the website index page, we copy
402-
everything one directory up. Then we call
403-
:meth:`create_html_redirects`.
402+
everything one directory up.
404403
"""
405404
DocBuilder.html(self)
406405
html_output_dir = self._output_dir('html')
@@ -413,69 +412,21 @@ def html(self):
413412
else:
414413
shutil.copy2(src, dst)
415414

416-
def create_html_redirects(self):
415+
def pdf(self):
417416
"""
418-
Writes a number of small HTML files; these are files which used to
419-
contain the main content of the reference manual before splitting the
420-
manual into multiple documents. After the split, those files have
421-
moved, so in each old location, write a file which redirects to the new
422-
version. (This is so old URLs to pieces of the reference manual still
423-
open the correct files.)
417+
# Install in website_dir a symlink to the directory containing pdf
418+
# files. This symlink is necessary to access pdf documentation files
419+
# within Jupyter (see trac #33206).
424420
"""
425-
from sage.misc.superseded import deprecation
426-
deprecation(29993, "This method was created in trac #6495 for backward compatibility. Not necessary anymore.")
427-
428-
# The simple html template which will cause a redirect to the correct file.
429-
html_template = """<html><head>
430-
<meta HTTP-EQUIV="REFRESH" content="0; url=%s">
431-
</head><body></body></html>"""
432-
433-
reference_dir = os.path.abspath(os.path.join(self._output_dir('html'),
434-
'..', 'reference'))
435-
reference_builder = ReferenceBuilder('reference')
436-
refdir = os.path.join(SAGE_DOC_SRC, 'en', 'reference')
437-
for document in reference_builder.get_all_documents(refdir):
438-
# path is the directory above reference dir
439-
path = os.path.abspath(os.path.join(reference_dir, '..'))
440-
441-
# the name of the subdocument
442-
document_name = document.split('/')[1]
443-
444-
# the sage directory within a subdocument, for example
445-
# local/share/doc/sage/html/en/reference/algebras/sage
446-
sage_directory = os.path.join(path, document, 'sage')
447-
448-
# Walk through all of the files in the sage_directory
449-
for dirpath, dirnames, filenames in os.walk(sage_directory):
450-
# a string like reference/algebras/sage/algebras
451-
short_path = dirpath[len(path) + 1:]
452-
453-
# a string like sage/algebras
454-
shorter_path = os.path.join(*short_path.split(os.sep)[2:])
455-
456-
# make the shorter path directory
457-
try:
458-
os.makedirs(os.path.join(reference_dir, shorter_path))
459-
except OSError:
460-
pass
461-
462-
for filename in filenames:
463-
if not filename.endswith('html'):
464-
continue
465-
466-
# the name of the html file we are going to create
467-
redirect_filename = os.path.join(reference_dir, shorter_path, filename)
468-
469-
# the number of levels up we need to use in the relative url
470-
levels_up = len(shorter_path.split(os.sep))
471-
472-
# the relative url that we will redirect to
473-
redirect_url = "/".join(['..'] * levels_up + [document_name, shorter_path, filename])
474-
475-
# write the html file which performs the redirect
476-
with open(redirect_filename, 'w') as f:
477-
print(redirect_filename)
478-
f.write(html_template % redirect_url)
421+
super().pdf()
422+
423+
html_output_dir = self._output_dir('html')
424+
pdf_doc_dir = os.path.join(SAGE_DOC, 'pdf')
425+
426+
try:
427+
os.symlink(pdf_doc_dir, os.path.join(html_output_dir, 'pdf'))
428+
except FileExistsError:
429+
pass
479430

480431
def clean(self):
481432
"""

0 commit comments

Comments
 (0)