source: sasview/docs/sphinx-docs/build_sphinx.py @ ca7c6bd

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since ca7c6bd was 01f1e17, checked in by ajj, 8 years ago

More fixes

  • Property mode set to 100755
File size: 18.0 KB
RevLine 
[9bf64f6]1#!/usr/bin/env python
[35bf493]2"""
3Functions for building sphinx docs.
4
5For more information on the invocation of sphinx see:
6http://sphinx-doc.org/invocation.html
7"""
[01f1e17]8from __future__ import print_function
9
[35bf493]10import subprocess
11import os
12import sys
13import fnmatch
14import shutil
[296f290]15import imp
[35bf493]16
[21bba86]17from glob import glob
[35bf493]18from distutils.dir_util import copy_tree
19from distutils.util import get_platform
[d2143ab]20from shutil import copy
[b7a2ebfd]21from os import listdir
[35bf493]22
23platform = '.%s-%s'%(get_platform(),sys.version[:3])
24
25CURRENT_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
26
[296f290]27run = imp.load_source('run', os.path.join(CURRENT_SCRIPT_DIR, '..', '..', 'run.py'))
28run.prepare()
29
[35bf493]30SASVIEW_SRC = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "src")
31SASVIEW_BUILD = os.path.abspath(os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "build", "lib"+platform))
32SASVIEW_DOCS = os.path.join(SASVIEW_BUILD, "doc")
[2fb09c4]33SASVIEW_TEST = os.path.join(SASVIEW_SRC, "..", "sasview", "test", "media")
[5dd7499]34SASVIEW_TOC_SOURCE = os.path.join(CURRENT_SCRIPT_DIR, "source")
[35bf493]35
[5802e7b]36# Need to slurp in the new sasmodels model definitions to replace the old model_functions.rst
37# We are currently here:
38#/sasview-local-trunk/docs/sphinx-docs/build_sphinx.py
[a728658]39SASMODELS_SOURCE_PROLOG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc")
[dd72190]40SASMODELS_SOURCE_GPU = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "ref", "gpu")
[578a11d]41SASMODELS_SOURCE_SESANS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "ref", "sesans")
[dd72190]42SASMODELS_SOURCE_SESANSIMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "ref", "sesans", "sesans_img")
[18a1f2b]43SASMODELS_SOURCE_MAGNETISM = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "ref", "magnetism")
[8096b446]44SASMODELS_SOURCE_MAGIMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "ref", "magnetism", "mag_img")
[bb0c836]45SASMODELS_SOURCE_REF_MODELS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "ref", "models")
[354524d]46SASMODELS_SOURCE_MODELS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "model")
47SASMODELS_SOURCE_IMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "model", "img")
[5420ef6]48SASMODELS_SOURCE_AUTOIMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "_build", "html","_images")
[5dd7499]49## Don't do assemble-in-place
50## Assemble the docs in a temporary folder
51SASMODELS_DEST_PROLOG = os.path.join(CURRENT_SCRIPT_DIR, "source-temp")
52SASMODELS_DEST_REF_MODELS = os.path.join(SASMODELS_DEST_PROLOG, "user")
53SASMODELS_DEST_MODELS = os.path.join(SASMODELS_DEST_PROLOG, "user", "models")
54SASMODELS_DEST_IMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "model-imgs", "new-models")
55SASMODELS_DEST_MAGIMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "mag_img")
[dd72190]56SASMODELS_DEST_SESANSIMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "sesans_img")
[5dd7499]57SASMODELS_DEST_BUILDIMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "models", "img")
[5802e7b]58
59
[35bf493]60SPHINX_BUILD = os.path.join(CURRENT_SCRIPT_DIR, "build")
[5dd7499]61SPHINX_SOURCE = os.path.join(CURRENT_SCRIPT_DIR, "source-temp")
[35bf493]62SPHINX_SOURCE_API = os.path.join(SPHINX_SOURCE, "dev", "api")
[ba31ed1]63SPHINX_SOURCE_GUIFRAME = os.path.join(SPHINX_SOURCE, "user", "sasgui", "guiframe")
[7168b8b]64SPHINX_SOURCE_MODELS = os.path.join(SPHINX_SOURCE, "user", "models")
[ba31ed1]65SPHINX_SOURCE_PERSPECTIVES = os.path.join(SPHINX_SOURCE, "user", "sasgui", "perspectives")
[2fb09c4]66SPHINX_SOURCE_TEST = os.path.join(SPHINX_SOURCE, "test")
[578a11d]67SPHINX_SOURCE_USER = os.path.join(SPHINX_SOURCE, "user")
[35bf493]68
[c22c5e3]69BUMPS_DOCS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..",
70                          "bumps", "doc", "guide")
71BUMPS_TARGET = os.path.join(SPHINX_SOURCE_PERSPECTIVES, "fitting")
72
[bb0c836]73def inplace_change(filename, old_string, new_string):
74# Thanks to http://stackoverflow.com/questions/4128144/replace-string-within-file-contents
75        s=open(filename).read()
76        if old_string in s:
[21bba86]77                print('Changing "{old_string}" to "{new_string}"'.format(**locals()))
[bb0c836]78                s=s.replace(old_string, new_string)
79                f=open(filename, 'w')
80                f.write(s)
81                f.flush()
82                f.close()
83        else:
[21bba86]84                print('No occurences of "{old_string}" found.'.format(**locals()))
[bb0c836]85
[35bf493]86def _remove_dir(dir_path):
87    """Removes the given directory."""
88    if os.path.isdir(dir_path):
[21bba86]89        print("Removing \"%s\"... " % dir_path)
[35bf493]90        shutil.rmtree(dir_path)
91
92def clean():
93    """
94    Clean the sphinx build directory.
95    """
[f4d571b]96    print("=== Cleaning Sphinx Build ===")
[35bf493]97    _remove_dir(SASVIEW_DOCS)
98    _remove_dir(SPHINX_BUILD)
[5dd7499]99    _remove_dir(SPHINX_SOURCE)
100    #_remove_dir(SPHINX_SOURCE_GUIFRAME)
101    #_remove_dir(SPHINX_SOURCE_MODELS)
102    #_remove_dir(SPHINX_SOURCE_PERSPECTIVES)
103    #_remove_dir(SPHINX_SOURCE_TEST)
[35bf493]104
[5dd7499]105def setup_source_temp():
106    """
107    Copy the source toctrees to new folder for assembling the sphinx-docs
108    """
[f4d571b]109    print("=== Copying Source toctrees ===")
[5dd7499]110    if os.path.exists(SASVIEW_TOC_SOURCE):
[f4d571b]111       print("Found docs folder at", SASVIEW_TOC_SOURCE)
[5dd7499]112       shutil.copytree(SASVIEW_TOC_SOURCE, SPHINX_SOURCE)
[354524d]113
[35bf493]114def retrieve_user_docs():
115    """
116    Copies across the contents of any media/ directories in src/, and puts them
117    in an appropriately named directory of docs/sphinx-docs/source/. For
118    example:
119
120        sas/../[MODULE]/media/dir/A.rst
121        sas/../[MODULE]/media/B.rst
122
123    gets copied to a new location:
124
125        docs/sphinx-docs/source/user/[MODULE]/dir/A.rst
126        docs/sphinx-docs/source/user/[MODULE]/B.rst
127
128    so that Sphinx may pick it up when generating the documentation.
129    """
[f4d571b]130    print("=== Retrieve User Docs ===")
[35bf493]131
132    # Copy documentation files from their "source" to their "destination".
133    for root, dirnames, _ in os.walk(SASVIEW_SRC):
134        for dirname in fnmatch.filter(dirnames, 'media'):
135
136            docs = os.path.abspath(os.path.join(root, dirname))
[f4d571b]137            print("Found docs folder at \"%s\"." % docs)
[35bf493]138
[f620870]139            dest_dir_part = os.path.dirname(os.path.relpath(docs, SASVIEW_SRC))
140            if os.sep in dest_dir_part:
141                dest_dir_part = dest_dir_part[dest_dir_part.index(os.sep) + 1:]
142            dest_dir = os.path.join(SPHINX_SOURCE, "user", dest_dir_part)
[35bf493]143
144            copy_tree(docs, dest_dir)
[8096b446]145
[2fb09c4]146    # Now pickup testdata_help.rst
[f4d571b]147    print("=== Including Test Data Docs ===")
[2fb09c4]148    if os.path.exists(SASVIEW_TEST):
[f4d571b]149       print("Found docs folder at", SASVIEW_TEST)
[8096b446]150       shutil.copytree(SASVIEW_TEST, SPHINX_SOURCE_TEST)
[354524d]151
[f4d571b]152    print("=== And the Sasmodels Docs ===")
[6a9c0e5a]153    # Make sure we have the relevant images for the new sasmodels documentation
[5420ef6]154    # First(!) we'll make a local reference copy for SasView (/new-models will be cleaned each build)
[b7a2ebfd]155    if os.path.exists(SASMODELS_SOURCE_IMG):
[f4d571b]156        print("Found img folder SASMODELS_SOURCE_IMG at", SASMODELS_SOURCE_IMG)
[6de5e10]157        if not os.path.exists(SASMODELS_DEST_IMG):
[f4d571b]158            print("Missing docs folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG)
[6de5e10]159            os.makedirs(SASMODELS_DEST_IMG)
[f4d571b]160            print("created SASMODELS_DEST_BUILDIMG at", SASMODELS_DEST_BUILDIMG)
161        else:
162            print("Found img folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG)
163        print("Copying sasmodels model image files...")
[6de5e10]164        for files in os.listdir(SASMODELS_SOURCE_IMG):
165            fromhere=os.path.join(SASMODELS_SOURCE_IMG,files)
166            tohere=os.path.join(SASMODELS_DEST_IMG,files)
167            shutil.copy(fromhere,tohere)
[f4d571b]168    else:
169        print("no source directory",SASMODELS_SOURCE_IMG,"was found")
[b7a2ebfd]170
[5420ef6]171    if os.path.exists(SASMODELS_SOURCE_AUTOIMG):
[f4d571b]172        print("Found img folder SASMODELS_SOURCE_AUTOIMG at", SASMODELS_SOURCE_AUTOIMG)
[6de5e10]173        if not os.path.exists(SASMODELS_DEST_IMG):
[f4d571b]174            print("Missing docs folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG)
[6de5e10]175            os.makedirs(SASMODELS_DEST_BUILDIMG)
[f4d571b]176            print("created SASMODELS_DEST_BUILDIMG at", SASMODELS_DEST_BUILDIMG)
177        print("Copying sasmodels model auto-generated image files...")
[6de5e10]178        for files in os.listdir(SASMODELS_SOURCE_AUTOIMG):
179            fromhere=os.path.join(SASMODELS_SOURCE_AUTOIMG,files)
180            tohere=os.path.join(SASMODELS_DEST_IMG,files)
181            shutil.copy(fromhere,tohere)
[f4d571b]182    else:
183        print("no source directory",SASMODELS_SOURCE_AUTOIMG ,"was found")
[8096b446]184
[a728658]185    # And the rst prolog with the unit substitutions
186    if os.path.exists(SASMODELS_SOURCE_PROLOG):
[f4d571b]187        print("Found prolog folder SASMODELS_SOURCE_PROLOG at", SASMODELS_SOURCE_PROLOG)
[a728658]188        if os.path.exists(SASMODELS_DEST_PROLOG):
[f4d571b]189            print("Found docs folder SASMODELS_DEST_PROLOG at", SASMODELS_DEST_PROLOG)
190            print("Copying sasmodels rst_prolog file...")
[a728658]191            for files in os.listdir(SASMODELS_SOURCE_PROLOG):
192                if files.startswith("rst"):
193                    fromhere=os.path.join(SASMODELS_SOURCE_PROLOG,files)
194                    tohere=os.path.join(SASMODELS_DEST_PROLOG,files)
195                    shutil.copy(fromhere,tohere)
[f4d571b]196    else:
[21bba86]197        print("no source directory",SASMODELS_SOURCE_PROLOG, "was found")
[a728658]198
[dd72190]199    if os.path.exists(SASMODELS_SOURCE_GPU):
[f4d571b]200        print("Found docs folder SASMODELS_SOURCE_GPU at", SASMODELS_SOURCE_GPU)
[dd72190]201        if os.path.exists(SPHINX_SOURCE_USER):
[f4d571b]202            print("Found docs folder SPHINX_SOURCE_USER at", SPHINX_SOURCE_USER)
203            print("Copying sasmodels gpu files...")
[dd72190]204            for files in os.listdir(SASMODELS_SOURCE_GPU):
205                if files.endswith(".rst"):
206                    fromhere=os.path.join(SASMODELS_SOURCE_GPU,files)
207                    tohere=os.path.join(SPHINX_SOURCE_USER,files)
208                    shutil.copy(fromhere,tohere)
[f4d571b]209    else:
[01f1e17]210        print("no source directory",SASMODELS_SOURCE_GPU,"was found")
[dd72190]211
[578a11d]212    if os.path.exists(SASMODELS_SOURCE_SESANS):
[f4d571b]213        print("Found docs folder SASMODELS_SOURCE_SESANS at", SASMODELS_SOURCE_SESANS)
[578a11d]214        if os.path.exists(SPHINX_SOURCE_USER):
[f4d571b]215            print("Found docs folder SPHINX_SOURCE_USER at", SPHINX_SOURCE_USER)
216            print("Copying sasmodels sesans files...")
[578a11d]217            for files in os.listdir(SASMODELS_SOURCE_SESANS):
218                if files.endswith(".rst"):
219                    fromhere=os.path.join(SASMODELS_SOURCE_SESANS,files)
220                    tohere=os.path.join(SPHINX_SOURCE_USER,files)
221                    shutil.copy(fromhere,tohere)
[f4d571b]222    else:
223        print("no source directory",SASMODELS_SOURCE_SESANS,"was found")
[578a11d]224
[18a1f2b]225    if os.path.exists(SASMODELS_SOURCE_MAGNETISM):
[f4d571b]226        print("Found docs folder SASMODELS_SOURCE_MAGNETISM at", SASMODELS_SOURCE_MAGNETISM)
[18a1f2b]227        if os.path.exists(SASMODELS_DEST_REF_MODELS):
[f4d571b]228            print("Found docs folder SASMODELS_DEST_REF_MODELS at", SASMODELS_DEST_REF_MODELS)
229            print("Copying sasmodels model toctree files...")
[18a1f2b]230            for files in os.listdir(SASMODELS_SOURCE_MAGNETISM):
231                if files.endswith(".rst"):
232                    fromhere=os.path.join(SASMODELS_SOURCE_MAGNETISM,files)
233                    tohere=os.path.join(SASMODELS_DEST_REF_MODELS,files)
234                    shutil.copy(fromhere,tohere)
[f4d571b]235    else:
236        print("no source directory",SASMODELS_SOURCE_MAGNETISM,"was found")
[18a1f2b]237
[8096b446]238    if os.path.exists(SASMODELS_SOURCE_MAGIMG):
[f4d571b]239        print("Found img folder SASMODELS_SOURCE_MAGIMG   at", SASMODELS_SOURCE_MAGIMG)
[8096b446]240        if not os.path.exists(SASMODELS_DEST_MAGIMG):
[f4d571b]241            print("Missing img folder SASMODELS_DEST_MAGIMG at", SASMODELS_DEST_MAGIMG)
[8096b446]242            os.makedirs(SASMODELS_DEST_MAGIMG)
[f4d571b]243            print("created SASMODELS_DEST_MAGIMG at", SASMODELS_DEST_MAGIMG)
244        print("Copying sasmodels mag image files...")
[8096b446]245        for files in os.listdir(SASMODELS_SOURCE_MAGIMG):
246            fromhere=os.path.join(SASMODELS_SOURCE_MAGIMG,files)
247            tohere=os.path.join(SASMODELS_DEST_MAGIMG,files)
248            shutil.copy(fromhere,tohere)
[f4d571b]249    else:
250        print("no source directory",SASMODELS_SOURCE_MAGIMG ,"was found")
[dd72190]251
252    if os.path.exists(SASMODELS_SOURCE_SESANSIMG):
[f4d571b]253        print("Found img folder SASMODELS_SOURCE_SESANSIMG at", SASMODELS_SOURCE_SESANSIMG)
[751f4bd]254        if not os.path.exists(SASMODELS_DEST_SESANSIMG):
[f4d571b]255            print("Missing img folder SASMODELS_DEST_SESANSIMG at", SASMODELS_DEST_SESANSIMG)
[dd72190]256            os.makedirs(SASMODELS_DEST_SESANSIMG)
[f4d571b]257            print("created SASMODELS_DEST_SESANSIMG at", SASMODELS_DEST_SESANSIMG)
258        print("Copying sasmodels sesans image files...")
[dd72190]259        for files in os.listdir(SASMODELS_SOURCE_SESANSIMG):
260            fromhere=os.path.join(SASMODELS_SOURCE_SESANSIMG,files)
261            tohere=os.path.join(SASMODELS_DEST_SESANSIMG,files)
262            shutil.copy(fromhere,tohere)
[f4d571b]263    else:
264        print("no source directory",SASMODELS_SOURCE_SESANSIMG ,"was found")
[8096b446]265
[bb0c836]266    if os.path.exists(SASMODELS_SOURCE_REF_MODELS):
[f4d571b]267        print("Found docs folder SASMODELS_SOURCE_REF_MODELS at", SASMODELS_SOURCE_REF_MODELS)
[bb0c836]268        if os.path.exists(SASMODELS_DEST_REF_MODELS):
[f4d571b]269            print("Found docs folder SASMODELS_DEST_REF_MODELS at", SASMODELS_DEST_REF_MODELS)
270            print("Copying sasmodels model toctree files...")
[bb0c836]271            for files in os.listdir(SASMODELS_SOURCE_REF_MODELS):
272                if files.endswith(".rst"):
273                    fromhere=os.path.join(SASMODELS_SOURCE_REF_MODELS,files)
274                    tohere=os.path.join(SASMODELS_DEST_REF_MODELS,files)
275                    shutil.copy(fromhere,tohere)
[115eb7e]276            # But need to change the path to the model docs in the tocs
277            for files in os.listdir(SASMODELS_DEST_REF_MODELS):
278        #        print files
279                if files.startswith("shape"):
[f4d571b]280                    print("Changing toc paths in", files)
[115eb7e]281                    inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/")
282                if files.startswith("sphere"):
[f4d571b]283                    print("Changing toc paths in", files)
[115eb7e]284                    inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/")
285                if files.startswith("custom"):
[f4d571b]286                    print("Changing toc paths in", files)
[115eb7e]287                    inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/")
288                if files.startswith("structure"):
[f4d571b]289                    print("Changing toc paths in", files)
[115eb7e]290                    inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/")
[f4d571b]291    else:
292        print("no source directory",SASMODELS_SOURCE_REF_MODELS," was found")
[a728658]293
[b7a2ebfd]294    if os.path.exists(SASMODELS_SOURCE_MODELS):
[f4d571b]295        print("Found docs folder SASMODELS_SOURCE_MODELS at", SASMODELS_SOURCE_MODELS)
[b7a2ebfd]296        if os.path.exists(SASMODELS_DEST_MODELS):
[f4d571b]297            print("Found docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS)
298            print("Copying sasmodels model files...")
[b7a2ebfd]299            for files in os.listdir(SASMODELS_SOURCE_MODELS):
[354524d]300                if files.endswith(".rst"):
[b7a2ebfd]301                    fromhere=os.path.join(SASMODELS_SOURCE_MODELS,files)
302                    tohere=os.path.join(SASMODELS_DEST_MODELS,files)
303                    shutil.copy(fromhere,tohere)
[5420ef6]304        else:
[f4d571b]305            print("Missing docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS)
[5420ef6]306            os.makedirs(SASMODELS_DEST_MODELS)
307            if not os.path.exists(SASMODELS_DEST_BUILDIMG):
308                os.makedirs(SASMODELS_DEST_BUILDIMG)
[f4d571b]309            print("Created docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS)
310            print("Copying model files for build...")
[5420ef6]311            for files in os.listdir(SASMODELS_SOURCE_MODELS):
312                if files.endswith(".rst"):
313                    fromhere=os.path.join(SASMODELS_SOURCE_MODELS,files)
314                    tohere=os.path.join(SASMODELS_DEST_MODELS,files)
315                    shutil.copy(fromhere,tohere)
316            # No choice but to do this because model files are all coded for images in /models/img
[f4d571b]317            print("Copying image files for build...")
[5420ef6]318            for files in os.listdir(SASMODELS_DEST_IMG):
319                fromhere=os.path.join(SASMODELS_DEST_IMG,files)
320                tohere=os.path.join(SASMODELS_DEST_BUILDIMG,files)
321                shutil.copy(fromhere,tohere)
[f4d571b]322    else:
323        print("no source directory",SASMODELS_SOURCE_MODELS,"was found.")
324        print("!!!!NO MODEL DOCS WILL BE BUILT!!!!")
[6a9c0e5a]325
[35bf493]326
[c22c5e3]327def retrieve_bumps_docs():
328    """
329    Copies select files from the bumps documentation into fitting perspective
330    """
331    if os.path.exists(BUMPS_DOCS):
[f4d571b]332        print("=== Retrieve BUMPS Docs ===")
[c22c5e3]333        filenames = [os.path.join(BUMPS_DOCS, "optimizer.rst")]
334        filenames += glob(os.path.join(BUMPS_DOCS, "dream-*.png"))
335        filenames += glob(os.path.join(BUMPS_DOCS, "fit-*.png"))
336        for f in filenames:
[f4d571b]337            print("Copying file", f)
[c22c5e3]338            shutil.copy(f, BUMPS_TARGET)
339    else:
[f4d571b]340        print("""
[01f1e17]341======= Error =======
342missing directory %s
[c22c5e3]343The documentation will not include the optimizer selection section.
344Checkout the bumps source tree and rebuild the docs.
[f4d571b]345""" % BUMPS_DOCS)
[c22c5e3]346
[35bf493]347def apidoc():
348    """
349    Runs sphinx-apidoc to generate .rst files from the docstrings in .py files
350    in the SasView build directory.
351    """
[f4d571b]352    print("=== Generate API Rest Files ===")
[35bf493]353
354    # Clean directory before generating a new version.
355    _remove_dir(SPHINX_SOURCE_API)
356
357    subprocess.call(["sphinx-apidoc",
358                     "-o", SPHINX_SOURCE_API, # Output dir.
359                     "-d", "8", # Max depth of TOC.
360                     SASVIEW_BUILD])
361
362def build():
363    """
364    Runs sphinx-build.  Reads in all .rst files and spits out the final html.
365    """
[f4d571b]366    print("=== Build HTML Docs from Rest Files ===")
[35bf493]367    subprocess.call(["sphinx-build",
368                     "-b", "html", # Builder name. TODO: accept as arg to setup.py.
369                     "-d", os.path.join(SPHINX_BUILD, "doctrees"),
370                     SPHINX_SOURCE,
371                     os.path.join(SPHINX_BUILD, "html")])
372
[f4d571b]373    print("=== Copy HTML Docs to Build Directory ===")
[35bf493]374    html = os.path.join(SPHINX_BUILD, "html")
375    copy_tree(html, SASVIEW_DOCS)
376
[c2ee2b1]377def rebuild():
[35bf493]378    clean()
[5dd7499]379    setup_source_temp()
[35bf493]380    retrieve_user_docs()
[c22c5e3]381    retrieve_bumps_docs()
[35bf493]382    apidoc()
383    build()
[c2ee2b1]384
[f4d571b]385    print("=== Done ===")
[c2ee2b1]386
387if __name__ == "__main__":
[9bf64f6]388    rebuild()
Note: See TracBrowser for help on using the repository browser.