diff --git a/src/doc/Makefile b/src/doc/Makefile index 2d433b3727c..98a3d138baf 100644 --- a/src/doc/Makefile +++ b/src/doc/Makefile @@ -42,7 +42,7 @@ doc-inventory-reference: doc-src $(eval BIBLIO = $(firstword $(DOCS))) $(eval OTHER_DOCS = $(wordlist 2, 100, $(DOCS))) $(MAKE) doc-inventory--$(subst /,-,$(BIBLIO)) - $(MAKE) SAGE_DOCBUILD_OPTS="$(SAGE_DOCBUILD_OPTS) --no-prune-empty-dirs" $(foreach doc, $(OTHER_DOCS), doc-inventory--$(subst /,-,$(doc))) + $(MAKE) $(foreach doc, $(OTHER_DOCS), doc-inventory--$(subst /,-,$(doc))) $(MAKE) SAGE_DOCBUILD_OPTS="$(SAGE_DOCBUILD_OPTS) --no-prune-empty-dirs" doc-inventory--reference_top endif @@ -63,7 +63,7 @@ doc-html-reference: doc-html-reference-sub doc-html-other: doc-html-reference $(eval DOCS = $(shell sage --docbuild --all-documents all)) @if [ -z "$(DOCS)" ]; then echo "Error: 'sage --docbuild --all-documents' failed"; exit 1; fi - $(MAKE) SAGE_DOCBUILD_OPTS="$(SAGE_DOCBUILD_OPTS) --no-prune-empty-dirs" $(foreach doc, $(wordlist 2, 100, $(DOCS)), doc-html--$(subst /,-,$(doc))) + $(MAKE) $(foreach doc, $(wordlist 2, 100, $(DOCS)), doc-html--$(subst /,-,$(doc))) doc-html: doc-html-reference doc-html-other diff --git a/src/sage_docbuild/__main__.py b/src/sage_docbuild/__main__.py index 844e1ebee17..a7b7b39880b 100644 --- a/src/sage_docbuild/__main__.py +++ b/src/sage_docbuild/__main__.py @@ -46,7 +46,7 @@ option: nitpicky) --check-nested check picklability of nested classes in DOCUMENT 'reference' --no-prune-empty-dirs - do not prune empty directories in the documentation sources + do not prune empty directories in the documentation source --use-cdns assume internet connection and use CDNs; in particular, use MathJax CDN -N, --no-colors do not color output; does not affect children @@ -325,7 +325,7 @@ def setup_parser(): help="check picklability of nested classes in DOCUMENT 'reference'") standard.add_argument("--no-prune-empty-dirs", dest="no_prune_empty_dirs", action="store_true", - help="do not prune empty directories in the documentation sources") + help="do not prune empty directories in the documentation source") standard.add_argument("--use-cdns", dest="use_cdns", default=False, action="store_true", help="assume internet connection and use CDNs; in particular, use MathJax CDN") @@ -508,22 +508,24 @@ def excepthook(*exc_info): build_options.ABORT_ON_ERROR = not args.keep_going + # Set up Intersphinx cache + _ = IntersphinxCache() + + builder = get_builder(name) + if not args.no_prune_empty_dirs: # Delete empty directories. This is needed in particular for empty # directories due to "git checkout" which never deletes empty # directories it leaves behind. See Issue #20010. # Issue #31948: This is not parallelization-safe; use the option # --no-prune-empty-dirs to turn it off - for dirpath, dirnames, filenames in os.walk(SAGE_DOC_SRC, topdown=False): + for dirpath, dirnames, filenames in os.walk(builder.dir, topdown=False): if not dirnames + filenames: logger.warning('Deleting empty directory {0}'.format(dirpath)) os.rmdir(dirpath) - # Set up Intersphinx cache - _ = IntersphinxCache() - - builder = getattr(get_builder(name), typ) - builder() + build = getattr(builder, typ) + build() if __name__ == '__main__':