Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Fix citation dir with custom SAGE_DOC_OUTPUT
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Jan 26, 2016
1 parent 537d9d2 commit 1cebbc9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/sage_setup/docbuild/ext/multidocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import cPickle, os, sys, shutil, re, tempfile
import sphinx
from sphinx.util.console import bold
from sage.env import SAGE_DOC_OUTPUT
from sage.misc.misc import sage_makedirs


CITE_FILENAME = 'citations.pickle'
Expand Down Expand Up @@ -195,11 +197,22 @@ def sage_pathto(otheruri, *args, **opts):


def citation_dir(app):
citedir = re.sub('/doc/output/[^/]*/', '/doc/output/inventory/', app.outdir)
if not os.path.isdir(citedir):
os.makedirs(os.path.abspath(citedir))
# Split app.outdir in 3 parts: SAGE_DOC_OUTPUT/TYPE/TAIL where TYPE
# is a single directory and TAIL can contain multiple directories.
# The citation dir is then SAGE_DOC_OUTPUT/inventory/TAIL.
assert app.outdir.startswith(SAGE_DOC_OUTPUT)
rel = app.outdir[len(SAGE_DOC_OUTPUT):]
dirs = rel.split(os.sep)
# If SAGE_DOC_OUTPUT does not end with a slash, rel will start with
# a slash giving an empty dirs[0]. Remove this:
if not dirs[0]:
dirs.pop(0)
dirs = [SAGE_DOC_OUTPUT, "inventory"] + dirs[1:]
citedir = os.path.join(*dirs)
sage_makedirs(citedir)
return citedir


def write_citations(app, citations):
"""
Pickle the citation in a file.
Expand Down

0 comments on commit 1cebbc9

Please sign in to comment.