@@ -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