Makefile 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # Makefile for Sphinx documentation
  2. #
  3. PYVER =
  4. PYTHON = python$(PYVER)
  5. # You can set these variables from the command line.
  6. SPHINXOPTS =
  7. SPHINXBUILD = LANG=C sphinx-build
  8. PAPER =
  9. NEED_AUTOSUMMARY = $(shell $(PYTHON) -c 'import sphinx; print sphinx.__version__ < "0.7" and "1" or ""')
  10. # Internal variables.
  11. PAPEROPT_a4 = -D latex_paper_size=a4
  12. PAPEROPT_letter = -D latex_paper_size=letter
  13. ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
  14. .PHONY: help clean html web pickle htmlhelp latex changes linkcheck \
  15. dist dist-build
  16. #------------------------------------------------------------------------------
  17. help:
  18. @echo "Please use \`make <target>' where <target> is one of"
  19. @echo " html to make standalone HTML files"
  20. @echo " pickle to make pickle files (usable by e.g. sphinx-web)"
  21. @echo " htmlhelp to make HTML files and a HTML help project"
  22. @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
  23. @echo " changes to make an overview over all changed/added/deprecated items"
  24. @echo " linkcheck to check all external links for integrity"
  25. @echo " dist PYVER=... to make a distribution-ready tree"
  26. @echo " upload USER=... to upload results to docs.scipy.org"
  27. clean:
  28. -rm -rf build/* source/reference/generated
  29. #------------------------------------------------------------------------------
  30. # Automated generation of all documents
  31. #------------------------------------------------------------------------------
  32. # Build the current numpy version, and extract docs from it.
  33. # We have to be careful of some issues:
  34. #
  35. # - Everything must be done using the same Python version
  36. # - We must use eggs (otherwise they might override PYTHONPATH on import).
  37. # - Different versions of easy_install install to different directories (!)
  38. #
  39. INSTALL_DIR = $(CURDIR)/build/inst-dist/
  40. INSTALL_PPH = $(INSTALL_DIR)/lib/python$(PYVER)/site-packages:$(INSTALL_DIR)/local/lib/python$(PYVER)/site-packages:$(INSTALL_DIR)/lib/python$(PYVER)/dist-packages:$(INSTALL_DIR)/local/lib/python$(PYVER)/dist-packages
  41. DIST_VARS=SPHINXBUILD="LANG=C PYTHONPATH=$(INSTALL_PPH) python$(PYVER) `which sphinx-build`" PYTHON="PYTHONPATH=$(INSTALL_PPH) python$(PYVER)" SPHINXOPTS="$(SPHINXOPTS)"
  42. UPLOAD_TARGET = $(USER)@docs.scipy.org:/home/docserver/www-root/doc/numpy/
  43. upload:
  44. @test -e build/dist || { echo "make dist is required first"; exit 1; }
  45. @test output-is-fine -nt build/dist || { \
  46. echo "Review the output in build/dist, and do 'touch output-is-fine' before uploading."; exit 1; }
  47. rsync -r -z --delete-after -p \
  48. $(if $(shell test -f build/dist/numpy-ref.pdf && echo "y"),, \
  49. --exclude '**-ref.pdf' --exclude '**-user.pdf') \
  50. $(if $(shell test -f build/dist/numpy-chm.zip && echo "y"),, \
  51. --exclude '**-chm.zip') \
  52. build/dist/ $(UPLOAD_TARGET)
  53. dist:
  54. make $(DIST_VARS) real-dist
  55. real-dist: dist-build html
  56. test -d build/latex || make latex
  57. make -C build/latex all-pdf
  58. -test -d build/htmlhelp || make htmlhelp-build
  59. -rm -rf build/dist
  60. cp -r build/html build/dist
  61. perl -pi -e 's#^\s*(<li><a href=".*?">NumPy.*?Manual.*?&raquo;</li>)#<li><a href="/">Numpy and Scipy Documentation</a> &raquo;</li>#;' build/dist/*.html build/dist/*/*.html build/dist/*/*/*.html
  62. cd build/html && zip -9r ../dist/numpy-html.zip .
  63. cp build/latex/numpy-*.pdf build/dist
  64. -zip build/dist/numpy-chm.zip build/htmlhelp/numpy.chm
  65. cd build/dist && tar czf ../dist.tar.gz *
  66. chmod ug=rwX,o=rX -R build/dist
  67. find build/dist -type d -print0 | xargs -0r chmod g+s
  68. dist-build:
  69. rm -f ../dist/*.egg
  70. cd .. && $(PYTHON) setupegg.py bdist_egg
  71. install -d $(subst :, ,$(INSTALL_PPH))
  72. $(PYTHON) `which easy_install` --prefix=$(INSTALL_DIR) ../dist/*.egg
  73. #------------------------------------------------------------------------------
  74. # Basic Sphinx generation rules for different formats
  75. #------------------------------------------------------------------------------
  76. generate: build/generate-stamp
  77. build/generate-stamp: $(wildcard source/reference/*.rst)
  78. mkdir -p build
  79. ifeq ($(NEED_AUTOSUMMARY),1)
  80. $(PYTHON) \
  81. ./sphinxext/autosummary_generate.py source/reference/*.rst \
  82. -p dump.xml -o source/reference/generated
  83. endif
  84. touch build/generate-stamp
  85. html: generate
  86. mkdir -p build/html build/doctrees
  87. $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
  88. $(PYTHON) postprocess.py html build/html/*.html
  89. @echo
  90. @echo "Build finished. The HTML pages are in build/html."
  91. pickle: generate
  92. mkdir -p build/pickle build/doctrees
  93. $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
  94. @echo
  95. @echo "Build finished; now you can process the pickle files or run"
  96. @echo " sphinx-web build/pickle"
  97. @echo "to start the sphinx-web server."
  98. web: pickle
  99. htmlhelp: generate
  100. mkdir -p build/htmlhelp build/doctrees
  101. $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
  102. @echo
  103. @echo "Build finished; now you can run HTML Help Workshop with the" \
  104. ".hhp project file in build/htmlhelp."
  105. htmlhelp-build: htmlhelp build/htmlhelp/numpy.chm
  106. %.chm: %.hhp
  107. -hhc.exe $^
  108. qthelp: generate
  109. mkdir -p build/qthelp build/doctrees
  110. $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp
  111. latex: generate
  112. mkdir -p build/latex build/doctrees
  113. $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
  114. $(PYTHON) postprocess.py tex build/latex/*.tex
  115. perl -pi -e 's/\t(latex.*|pdflatex) (.*)/\t-$$1 -interaction batchmode $$2/' build/latex/Makefile
  116. @echo
  117. @echo "Build finished; the LaTeX files are in build/latex."
  118. @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
  119. "run these through (pdf)latex."
  120. coverage: build
  121. mkdir -p build/coverage build/doctrees
  122. $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) build/coverage
  123. @echo "Coverage finished; see c.txt and python.txt in build/coverage"
  124. changes: generate
  125. mkdir -p build/changes build/doctrees
  126. $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
  127. @echo
  128. @echo "The overview file is in build/changes."
  129. linkcheck: generate
  130. mkdir -p build/linkcheck build/doctrees
  131. $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
  132. @echo
  133. @echo "Link check complete; look for any errors in the above output " \
  134. "or in build/linkcheck/output.txt."