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

Commit

Permalink
Delete empty directories in $SAGE_DOC before running Sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Feb 4, 2016
1 parent 0455d14 commit cabdf45
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/sage_setup/docbuild/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ def excepthook(*exc_info):
"make doc-clean" first and try again.''')


def delete_empty_directories(root_dir):
"""
Delete all empty directories found under ``root_dir``
INPUT:
- ``root_dir`` -- string. A valid directory name.
"""
for dirpath, dirnames, filenames in os.walk(root_dir, topdown=False):
if not dirnames + filenames:
logger.warning('Deleting empty directory {0}'.format(dirpath))
os.rmdir(dirpath)


##########################################
# Parallel Building Ref Manual #
##########################################
Expand Down Expand Up @@ -1613,6 +1627,11 @@ def main():

ABORT_ON_ERROR = not options.keep_going

# Delete empty directories. This is needed in particular for empty
# directories due to "git checkout" which never deletes empty
# directories it leaves behind. See Trac #20010.
delete_empty_directories(SAGE_DOC)

# Set up Intersphinx cache
C = IntersphinxCache()

Expand Down

0 comments on commit cabdf45

Please sign in to comment.