Ticket #6495: trac_6495_fixes.patch

File trac_6495_fixes.patch, 3.9 KB (added by vbraun, 7 years ago)

Updated patch

  • doc/common/custom-sphinx-build.py

    # HG changeset patch
    # User Volker Braun <vbraun.name@gmail.com>
    # Date 1359808620 0
    # Node ID b8728b1a81b39f9c941884aef831656cd9cff523
    # Parent  f133a8a0f5f4f7ce57251fc51e27d72eb30331ae
    Hide useless warning and add the sat subdoc that was accidentally left out.
    
    diff --git a/doc/common/custom-sphinx-build.py b/doc/common/custom-sphinx-build.py
    a b  
    3838    )
    3939
    4040
     41if any('multidoc_first_pass=1' in arg for arg in sys.argv):
     42    useless_chatter += (
     43        re.compile('^None:[0-9]*: WARNING: citation not found: '),
     44        )
     45   
     46
     47
     48
    4149class SageSphinxLogger(object):
    4250    """
    4351    This implements the file object interface to serve as sys.stdout
     
    129137    def write(self, str):
    130138        try:
    131139            self._write(str)
    132         except:
     140        except StandardError:
    133141            import traceback
    134142            traceback.print_exc(file=self._stream)
    135143       
  • doc/common/multidocs.py

    diff --git a/doc/common/multidocs.py b/doc/common/multidocs.py
    a b  
    2020    - the javascript index;
    2121    - the citations.
    2222"""
    23 import cPickle, os, sys, shutil
     23import cPickle, os, sys, shutil, re, tempfile
    2424import sphinx
    2525from sphinx.util.console import bold
    2626
     
    7272            # needed by env.check_consistency (sphinx.environement, line 1734)
    7373            for ind in newalldoc:
    7474                # treat subdocument source as orphaned file and don't complain
    75                 env.metadata[ind] = {'orphan'}
     75                md = env.metadata.get(ind, set())
     76                md.add('orphan')
     77                env.metadata[ind] = md
    7678            # merge the citations
    7779            newcite = {}
    7880            for ind, (path, tag) in docenv.citations.iteritems():
     
    187189    ctx['pathto'] = sage_pathto
    188190
    189191
     192def citation_dir(app):
     193    citedir = re.sub('/doc/output/[^/]*/', '/doc/output/inventory/', app.outdir)
     194    if not os.path.isdir(citedir):
     195        os.makedirs(os.path.abspath(citedir))
     196    return citedir
     197
    190198def write_citations(app, citations):
    191199    """
    192     Pickle the citation in a file
     200    Pickle the citation in a file.
     201   
     202    Atomic except on Windows, where you need to upgrade to a real filesystem.
    193203    """
    194204    import cPickle
    195     file = open(os.path.join(app.outdir, CITE_FILENAME), 'wb')
    196     cPickle.dump(citations, file)
    197     file.close()
     205    outdir = citation_dir(app)
     206    fd, tmp = tempfile.mkstemp(dir=outdir)
     207    os.close(fd)
     208    with open(tmp, 'wb') as file:
     209        cPickle.dump(citations, file)
     210    citation  = os.path.join(outdir, CITE_FILENAME)
     211    try:
     212        os.rename(tmp, citation)
     213    except OSError:  # your OS sucks and cannot do atomic file replacement
     214        os.unlink(citation)
     215        os.rename(tmp, citation)
    198216    app.info("Saved pickle file: %s"%CITE_FILENAME)
    199217
    200218
     
    204222    references.
    205223    """
    206224    app.builder.info(bold('loading cross citations... '), nonl=1)
    207     filename = os.path.join(app.outdir, '..', CITE_FILENAME)
     225    filename = os.path.join(citation_dir(app), '..', CITE_FILENAME)
    208226    if not os.path.exists(filename):
    209227        return
    210228    import cPickle
    211229    file = open(filename, 'rb')
    212     try:
    213         cache = cPickle.load(file)
    214     except:
    215         app.warn("Cache file '%s' is corrupted; ignoring it..."% filename)
    216         return
    217     else:
    218         app.builder.info("done (%s citations)."%len(cache))
    219     finally:
    220         file.close()
     230    cache = cPickle.load(file)
     231    file.close()
     232    app.builder.info("done (%s citations)."%len(cache))
    221233    cite = env.citations
    222234    for ind, (path, tag) in cache.iteritems():
    223235        if ind not in cite: # don't override local citation
  • doc/en/reference/conf.py

    diff --git a/doc/en/reference/conf.py b/doc/en/reference/conf.py
    a b  
    115115    'rings',
    116116    'rings_numerical',
    117117    'rings_standard',
     118    'sat',
    118119    'schemes',
    119120    'semirings',
    120121    'stats',