Ticket #6495: trac_6495_ref_pdf_pieces.patch

File trac_6495_ref_pdf_pieces.patch, 2.0 KB (added by mpatel, 10 years ago)

Experimental.

  • doc/en/reference/conf.py

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1247129470 25200
    # Node ID 33db32ec281dbe48686ba860999359aa6cfc729b
    # Parent  c35d418b542c418eec2cf3a6225d20fcd9dee88d
    #6495, replace PDF ref manual with one for each non-auto-generated .rst file
    
    diff --git a/doc/en/reference/conf.py b/doc/en/reference/conf.py
    a b  
    1111# All configuration values have a default; values that are commented out
    1212# serve to show the default.
    1313
    14 import sys, os
     14import glob, os, sys
    1515sys.path.append(os.environ['SAGE_DOC'])
    1616from common.conf import *
    1717
    htmlhelp_basename = name 
    2828
    2929# Grouping the document tree into LaTeX files. List of tuples
    3030# (source start file, target name, title, author, document class [howto/manual]).
    31 latex_documents = [
    32   ('index', name + '.tex', u'Sage Reference Manual',
    33    u'The Sage Development Team', 'manual'),
    34 ]
     31#latex_documents = [
     32#  ('index', name + '.tex', u'Sage Reference Manual', u'The Sage Development Team', 'manual'),
     33#]
     34
     35latex_documents = []
     36
     37# Use the non-auto-generated .rst files to break the PDF reference
     38# manual into smaller pieces.
     39for rst_name in glob.glob('*.rst'):
     40    if rst_name != 'index.rst':
     41        rst_file = open(rst_name, 'r')
     42        rst_contents = rst_file.read()
     43        rst_file.close()
     44
     45        # Use the document's title, if possible.
     46        title = u''
     47        lines = rst_contents.splitlines()
     48        for i in xrange(len(lines)):
     49            one = lines[i]
     50            if one.startswith('==') and (i > 0):
     51                title = lines[i-1]
     52                break
     53
     54        # Otherwise, use the base filename.
     55        basename = rst_name[:-4]
     56        if title == u'':
     57            title = basename.capitalize()
     58        title = title.replace(u'`', u'$')
     59
     60        latex_documents.append((basename, basename + '.tex', title,
     61                                u'The Sage Development Team', 'manual'))
    3562
    3663#Ignore all .rst in the _sage subdirectory
    3764exclude_trees = exclude_trees + ['_sage']