Jane Wayne
Jane Wayne

Reputation: 8855

How do I include a subdirectory and its content to the Sphinx output/build directory?

I have the following directory structure for my Sphinx project.

I want to copy root/source/snippets to build/html/snippets as is; this directory has code snippet files.

I don't think .. include::, :download: and html_extra_path are what I need. Is there a way to do this using the build configuration? Or is the only way to modify the make build scripts.

I am using Python v2.7.13 and Sphinx v1.5.1.

Upvotes: 2

Views: 1413

Answers (2)

mr.adam
mr.adam

Reputation: 241

I just came across this question, and can answer for Sphinx 3.3 with Python 3.8.

All I had to do was put html_extra_path = ['extra'] into conf.py. Then I made docs/extra/snippets. Now snippets and all of its content are copied into _build/html/snippets.

Upvotes: 3

Steve Piercy
Steve Piercy

Reputation: 15035

Modifying the makefile is trivial. I took mine, added just two lines, and it worked for me.

html:
    mkdir -p $(BUILDDIR)/html $(BUILDDIR)/doctrees
    $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
    mkdir -p $(BUILDDIR)/html/snippets
    cp snippets/* $(BUILDDIR)/html/snippets

Otherwise, I haven't tried this, but maybe sphinxcontrib-rawfiles will copy files into the directory you want.

Upvotes: 0

Related Questions