question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building the docs creates temporary files

See original GitHub issue

MCVE

Apologies if this has already been noted, but I can’t find an open issue. When I create the docs from scratch, I see a couple temporary files and directories that appear to have been created by accident. If this is a legitimate issue, I’m happy to put together a PR.

Here is an MCVE:

(xarray-docs) gwg:doc gwg$ make clean
rm -rf _build/*
rm -rf generated/*
rm -rf auto_gallery/
(xarray-docs) gwg:doc gwg$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
(xarray-docs) gwg:doc gwg$ make html
sphinx-build -b html -d _build/doctrees   . _build/html'

...

Build finished. The HTML pages are in _build/html.
(xarray-docs) gwg:doc gwg$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	example-no-leap.nc
	foo.zarr/
	manipulated-example-data.nc
	path/

nothing added to commit but untracked files present (use "git add" to track)

Expected Output

I would expect no files to be created by make html in the doc directory.

Problem Description

It’s not clear this will happen and may result in some people (me!) accidentally committing these files with git commit -A.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gwgundersencommented, Aug 27, 2019

After doing some more research, I can’t find an ipythonic way of doing this—even have a question with a bounty on StackOverflow. However, here are some options. My vote is for using the Makefile:

Remove via Makefile

It’s not ideal, but it ensures the files get removed immediately after they get created or upon clean. Near the top of the file, put something like

...
TMP_FILES = example-no-leap.nc foo.zarr/ manipulated-example-data.nc path/
...

Then the clean and html commands are

.PHONY: clean
clean:
	rm -rf $(BUILDDIR)/*
	rm -rf generated/*
	rm -rf auto_gallery/
	rm -rf $(TMP_FILES)

.PHONY: html
html:
	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
	rm -rf $(TMP_FILES)
	@echo
	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

Remove via more documentation

As @DocOtak points out, some of the documentation already cleans up after itself. Personally, I dislike this as it’s not clear to the reader why these extra snippets exist.

Remove via .gitignore

Easy to do, but I dislike this as it leaves a bunch of temporary junk in my working directory. I’d rather have it cleaned up somehow.

Remove by writing to and ignoring temp directory

Every ipython directive that creates a file should place that file in tmp/ directory. Then we .gitignore this. This is a bit cleaner than the other .gitignore option. This is my second choice.

Remove using tempdir utilities

I dislike this for the same reason I dislike “Remove via more documentation”: it clutters the documentation with utility snippets/code that are opaque to the reader.


Happy to create a PR for any of these, but does anyone have any preferences or a better way of doing this?

0reactions
gwgundersencommented, Aug 27, 2019

Thanks for the explanation, @DocOtak. I didn’t initially understand :suppress:, but I now agree that a cleaning block with :suppress: is straightforward. It also follows the current pattern in the docs—I noticed this other places once I knew what to look for.

Read more comments on GitHub >

github_iconTop Results From Across the Web

tempfile — Generate temporary files and directories — Python ...
This module creates temporary files and directories. It works on all supported platforms. TemporaryFile , NamedTemporaryFile , TemporaryDirectory , and ...
Read more >
Creating and Using a Temporary File - Win32 apps
The application retrieves a temporary file path and file name by using the GetTempPath and GetTempFileName functions, and then uses CreateFile ...
Read more >
Managing temporary files - CloudBees Documentation
During the build process, temporary files are created, then deleted automatically when a build completes. To maintain optimum efficiency, it is important to ......
Read more >
How to stop Word from creating temporary files in the same ...
According to: Description of how Word creates temporary files, the location where Microsoft Word, or any part of the Office suite, ...
Read more >
tempfile - Rust - Docs.rs
Use the tempdir() function for temporary directories. Design. This crate provides several approaches to creating temporary files and directories. tempfile() ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found