@@ -22,20 +22,30 @@ ADD_DOWNLOAD_BUTTONS ="$\
2222help:
2323 @$( SPHINXBUILD) -M help " $( SOURCEDIR) " " $( BUILDDIR) " $( SPHINXOPTS) $( O)
2424
25- # 0. create the output folder and copy all Python source files over to it
26- # 1. find all Python demos and convert them to Jupyter notebooks
27- # 2. find all Jupyter notebooks and convert them into Sphinx rst files
28- # 3. find all rst files and add the file name as a label at the top
29- # 4. find all rst files and add the download links to the bottom
3025.PHONY: demos
3126demos:
27+ # 0. create the output folder and copy all Python source files over to it
3228 mkdir -p $( OUTFOLDER)
3329 cp -a $( DEMOFOLDER) /. $( OUTFOLDER)
3430
31+ # 1. find all Python demos and convert them to Jupyter notebooks
3532 find $( DEMOFOLDER) -name '*.py' -exec sh -c '$( JUPYTEXT) --to ipynb $$ 1 --output " $( OUTFOLDER) /$$ (basename $$ 1 .py).ipynb" ' sh {} \;
33+
34+ # 2. find all Jupyter notebooks and convert them into Sphinx rst files
3635 find $( OUTFOLDER) -name '*.ipynb' -exec $( NBCONVERT) {} --to rst --output-dir=$( OUTFOLDER) --execute --RegexRemovePreprocessor.patterns=" ^%" \;
36+
37+ # 3. find all rst files and add the file name as a label at the top
3738 find $( OUTFOLDER) -name '*.rst' -exec sh -c 'sed -i " 1s/^/.. _$$ (basename $$ 1 .rst):\n\n /" $$ 1' sh {} \;
3839
40+ # 4. find all rst files and replace major classes/methods with Sphinx hyperlinks
41+ find $( OUTFOLDER) -name '*.rst' -exec sh -c 'sed --in-place \
42+ -e " s/\`\` Circuit\`\` /:class:\` ~dwave.gate.circuit.Circuit\` /g" \
43+ -e " s/\`\` Circuit\.\(\w * \)\`\` /:meth:\` ~dwave.gate.circuit.Circuit.\1\` /g" \
44+ -e " s/\`\` operations\`\` /:mod:\` ~dwave.gate.operations\` /g" \
45+ -e " s/\`\` ops\.\(\w * \)\`\` /:class:\` ~dwave.gate.operations.operations.\1\` /g" \
46+ $$ 1' sh {} \; \
47+
48+ # 5. find all rst files and add the download links to the bottom
3949 find $( OUTFOLDER) -name '*.rst' -exec sh -c 'sed -i -e $( ADD_DOWNLOAD_BUTTONS) $$ 1' sh {} \;
4050
4151.PHONY: help Makefile
0 commit comments