Changes in docs/sphinx-docs/build_sphinx.py [6e546f8:df72475] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/sphinx-docs/build_sphinx.py
r6e546f8 rdf72475 10 10 import subprocess 11 11 import os 12 from os.path import join as joinpath, abspath, dirname, isdir, exists, relpath 12 13 import sys 13 14 import fnmatch … … 25 26 platform = '.%s-%s'%(get_platform(),sys.version[:3]) 26 27 27 CURRENT_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 28 29 run = imp.load_source('run', os.path.join(CURRENT_SCRIPT_DIR, '..', '..', 'run.py')) 28 # sphinx paths 29 SPHINX_ROOT = dirname(abspath(__file__)) 30 SPHINX_BUILD = joinpath(SPHINX_ROOT, "build") 31 SPHINX_SOURCE = joinpath(SPHINX_ROOT, "source-temp") 32 SPHINX_PERSPECTIVES = joinpath(SPHINX_SOURCE, "user", "sasgui", "perspectives") 33 34 # sasview paths 35 SASVIEW_ROOT = joinpath(SPHINX_ROOT, '..', '..') 36 SASVIEW_DOCS = joinpath(SPHINX_ROOT, "source") 37 SASVIEW_BUILD = abspath(joinpath(SASVIEW_ROOT, "build", "lib"+platform)) 38 SASVIEW_MEDIA_SOURCE = joinpath(SASVIEW_ROOT, "src", "sas") 39 SASVIEW_DOC_TARGET = joinpath(SASVIEW_BUILD, "doc") 40 SASVIEW_API_TARGET = joinpath(SPHINX_SOURCE, "dev", "sasview-api") 41 42 # sasmodels paths 43 SASMODELS_ROOT = joinpath(SASVIEW_ROOT, "..", "sasmodels") 44 SASMODELS_DOCS = joinpath(SASMODELS_ROOT, "doc") 45 SASMODELS_BUILD = joinpath(SASMODELS_ROOT, "build", "lib") 46 SASMODELS_MODEL_SOURCE = joinpath(SASMODELS_DOCS, "model") 47 SASMODELS_MODEL_TARGET = joinpath(SPHINX_SOURCE, "user", "models") 48 #SASMODELS_API_SOURCE = joinpath(SASMODELS_DOCS, "api") 49 SASMODELS_API_TARGET = joinpath(SPHINX_SOURCE, "dev", "sasmodels-api") 50 SASMODELS_DEV_SOURCE = joinpath(SASMODELS_DOCS, "developer") 51 SASMODELS_DEV_TARGET = joinpath(SPHINX_SOURCE, "dev", "sasmodels-dev") 52 SASMODELS_GUIDE_SOURCE = joinpath(SASMODELS_DOCS, "guide") 53 SASMODELS_GUIDE_TARGET = joinpath(SPHINX_PERSPECTIVES, "fitting") 54 SASMODELS_GUIDE_EXCLUDE = [ 55 "index.rst", "install.rst", "intro.rst", 56 ] 57 58 # bumps paths 59 BUMPS_DOCS = joinpath(SASVIEW_ROOT, "..", "bumps", "doc") 60 BUMPS_SOURCE = joinpath(BUMPS_DOCS, "guide") 61 BUMPS_TARGET = joinpath(SPHINX_PERSPECTIVES, "fitting") 62 63 run = imp.load_source('run', joinpath(SASVIEW_ROOT, 'run.py')) 30 64 run.prepare() 31 32 SASVIEW_SRC = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "src")33 SASVIEW_BUILD = os.path.abspath(os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "build", "lib"+platform))34 SASVIEW_DOCS = os.path.join(SASVIEW_BUILD, "doc")35 SASVIEW_TEST = os.path.join(SASVIEW_SRC, "..", "sasview", "test", "media")36 SASVIEW_TOC_SOURCE = os.path.join(CURRENT_SCRIPT_DIR, "source")37 38 # Need to slurp in the new sasmodels model definitions to replace the old model_functions.rst39 # We are currently here:40 #/sasview-local-trunk/docs/sphinx-docs/build_sphinx.py41 SASMODELS_SOURCE_PROLOG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc")42 SASMODELS_SOURCE_GPU = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "guide", "gpu")43 SASMODELS_SOURCE_SESANS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "guide", "sesans")44 SASMODELS_SOURCE_SESANSIMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "guide", "sesans", "sesans_img")45 SASMODELS_SOURCE_MAGNETISM = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "guide", "magnetism")46 SASMODELS_SOURCE_MAGIMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "guide", "magnetism", "mag_img")47 SASMODELS_SOURCE_REF_MODELS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "guide", "models")48 SASMODELS_SOURCE_MODELS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "model")49 SASMODELS_SOURCE_IMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "model", "img")50 SASMODELS_SOURCE_AUTOIMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "_build", "html","_images")51 ## Don't do assemble-in-place52 ## Assemble the docs in a temporary folder53 SASMODELS_DEST_PROLOG = os.path.join(CURRENT_SCRIPT_DIR, "source-temp")54 SASMODELS_DEST_REF_MODELS = os.path.join(SASMODELS_DEST_PROLOG, "user")55 SASMODELS_DEST_MODELS = os.path.join(SASMODELS_DEST_PROLOG, "user", "models")56 SASMODELS_DEST_IMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "model-imgs", "new-models")57 SASMODELS_DEST_MAGIMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "mag_img")58 SASMODELS_DEST_SESANSIMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "sesans_img")59 SASMODELS_DEST_BUILDIMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "models", "img")60 61 62 SPHINX_BUILD = os.path.join(CURRENT_SCRIPT_DIR, "build")63 SPHINX_SOURCE = os.path.join(CURRENT_SCRIPT_DIR, "source-temp")64 SPHINX_SOURCE_API = os.path.join(SPHINX_SOURCE, "dev", "api")65 SPHINX_SOURCE_GUIFRAME = os.path.join(SPHINX_SOURCE, "user", "sasgui", "guiframe")66 SPHINX_SOURCE_MODELS = os.path.join(SPHINX_SOURCE, "user", "models")67 SPHINX_SOURCE_PERSPECTIVES = os.path.join(SPHINX_SOURCE, "user", "sasgui", "perspectives")68 SPHINX_SOURCE_TEST = os.path.join(SPHINX_SOURCE, "test")69 SPHINX_SOURCE_USER = os.path.join(SPHINX_SOURCE, "user")70 71 BUMPS_DOCS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..",72 "bumps", "doc", "guide")73 BUMPS_TARGET = os.path.join(SPHINX_SOURCE_PERSPECTIVES, "fitting")74 65 75 66 def inplace_change(filename, old_string, new_string): … … 88 79 def _remove_dir(dir_path): 89 80 """Removes the given directory.""" 90 if os.path.isdir(dir_path):81 if isdir(dir_path): 91 82 print("Removing \"%s\"... " % dir_path) 92 83 shutil.rmtree(dir_path) … … 97 88 """ 98 89 print("=== Cleaning Sphinx Build ===") 99 _remove_dir(SASVIEW_DOC S)90 _remove_dir(SASVIEW_DOC_TARGET) 100 91 _remove_dir(SPHINX_BUILD) 101 92 _remove_dir(SPHINX_SOURCE) 102 #_remove_dir(SPHINX_SOURCE_GUIFRAME)103 #_remove_dir(SPHINX_SOURCE_MODELS)104 #_remove_dir(SPHINX_SOURCE_PERSPECTIVES)105 #_remove_dir(SPHINX_SOURCE_TEST)106 93 107 94 def setup_source_temp(): … … 110 97 """ 111 98 print("=== Copying Source toctrees ===") 112 if os.path.exists(SASVIEW_TOC_SOURCE): 113 print("Found docs folder at", SASVIEW_TOC_SOURCE) 114 shutil.copytree(SASVIEW_TOC_SOURCE, SPHINX_SOURCE) 99 shutil.copytree(SASVIEW_DOCS, SPHINX_SOURCE) 115 100 116 101 def retrieve_user_docs(): … … 132 117 print("=== Retrieve User Docs ===") 133 118 134 # Copy documentation files from their "source" to their "destination". 135 for root, dirnames, _ in os.walk(SASVIEW_SRC): 136 for dirname in fnmatch.filter(dirnames, 'media'): 137 138 docs = os.path.abspath(os.path.join(root, dirname)) 139 print("Found docs folder at \"%s\"." % docs) 140 141 dest_dir_part = os.path.dirname(os.path.relpath(docs, SASVIEW_SRC)) 142 if os.sep in dest_dir_part: 143 dest_dir_part = dest_dir_part[dest_dir_part.index(os.sep) + 1:] 144 dest_dir = os.path.join(SPHINX_SOURCE, "user", dest_dir_part) 145 146 copy_tree(docs, dest_dir) 147 148 # Now pickup testdata_help.rst 149 print("=== Including Test Data Docs ===") 150 if os.path.exists(SASVIEW_TEST): 151 print("Found docs folder at", SASVIEW_TEST) 152 shutil.copytree(SASVIEW_TEST, SPHINX_SOURCE_TEST) 153 154 print("=== And the Sasmodels Docs ===") 155 # Make sure we have the relevant images for the new sasmodels documentation 156 # First(!) we'll make a local reference copy for SasView (/new-models will be cleaned each build) 157 if os.path.exists(SASMODELS_SOURCE_IMG): 158 print("Found img folder SASMODELS_SOURCE_IMG at", SASMODELS_SOURCE_IMG) 159 if not os.path.exists(SASMODELS_DEST_IMG): 160 print("Missing docs folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 161 os.makedirs(SASMODELS_DEST_IMG) 162 print("created SASMODELS_DEST_BUILDIMG at", SASMODELS_DEST_BUILDIMG) 163 else: 164 print("Found img folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 165 print("Copying sasmodels model image files...") 166 for files in os.listdir(SASMODELS_SOURCE_IMG): 167 fromhere=os.path.join(SASMODELS_SOURCE_IMG,files) 168 tohere=os.path.join(SASMODELS_DEST_IMG,files) 169 shutil.copy(fromhere,tohere) 170 else: 171 print("no source directory",SASMODELS_SOURCE_IMG,"was found") 172 173 if os.path.exists(SASMODELS_SOURCE_AUTOIMG): 174 print("Found img folder SASMODELS_SOURCE_AUTOIMG at", SASMODELS_SOURCE_AUTOIMG) 175 if not os.path.exists(SASMODELS_DEST_IMG): 176 print("Missing docs folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 177 os.makedirs(SASMODELS_DEST_BUILDIMG) 178 print("created SASMODELS_DEST_BUILDIMG at", SASMODELS_DEST_BUILDIMG) 179 print("Copying sasmodels model auto-generated image files...") 180 for files in os.listdir(SASMODELS_SOURCE_AUTOIMG): 181 fromhere=os.path.join(SASMODELS_SOURCE_AUTOIMG,files) 182 tohere=os.path.join(SASMODELS_DEST_IMG,files) 183 shutil.copy(fromhere,tohere) 184 else: 185 print("no source directory",SASMODELS_SOURCE_AUTOIMG ,"was found") 186 187 # And the rst prolog with the unit substitutions 188 if os.path.exists(SASMODELS_SOURCE_PROLOG): 189 print("Found prolog folder SASMODELS_SOURCE_PROLOG at", SASMODELS_SOURCE_PROLOG) 190 if os.path.exists(SASMODELS_DEST_PROLOG): 191 print("Found docs folder SASMODELS_DEST_PROLOG at", SASMODELS_DEST_PROLOG) 192 print("Copying sasmodels rst_prolog file...") 193 for files in os.listdir(SASMODELS_SOURCE_PROLOG): 194 if files.startswith("rst"): 195 fromhere=os.path.join(SASMODELS_SOURCE_PROLOG,files) 196 tohere=os.path.join(SASMODELS_DEST_PROLOG,files) 197 shutil.copy(fromhere,tohere) 198 else: 199 print("no source directory",SASMODELS_SOURCE_PROLOG, "was found") 200 201 if os.path.exists(SASMODELS_SOURCE_GPU): 202 print("Found docs folder SASMODELS_SOURCE_GPU at", SASMODELS_SOURCE_GPU) 203 if os.path.exists(SPHINX_SOURCE_USER): 204 print("Found docs folder SPHINX_SOURCE_USER at", SPHINX_SOURCE_USER) 205 print("Copying sasmodels gpu files...") 206 for files in os.listdir(SASMODELS_SOURCE_GPU): 207 if files.endswith(".rst"): 208 fromhere=os.path.join(SASMODELS_SOURCE_GPU,files) 209 tohere=os.path.join(SPHINX_SOURCE_USER,files) 210 shutil.copy(fromhere,tohere) 211 else: 212 print("no source directory",SASMODELS_SOURCE_GPU,"was found") 213 214 if os.path.exists(SASMODELS_SOURCE_SESANS): 215 print("Found docs folder SASMODELS_SOURCE_SESANS at", SASMODELS_SOURCE_SESANS) 216 if os.path.exists(SPHINX_SOURCE_USER): 217 print("Found docs folder SPHINX_SOURCE_USER at", SPHINX_SOURCE_USER) 218 print("Copying sasmodels sesans files...") 219 for files in os.listdir(SASMODELS_SOURCE_SESANS): 220 if files.endswith(".rst"): 221 fromhere=os.path.join(SASMODELS_SOURCE_SESANS,files) 222 tohere=os.path.join(SPHINX_SOURCE_USER,files) 223 shutil.copy(fromhere,tohere) 224 else: 225 print("no source directory",SASMODELS_SOURCE_SESANS,"was found") 226 227 if os.path.exists(SASMODELS_SOURCE_MAGNETISM): 228 print("Found docs folder SASMODELS_SOURCE_MAGNETISM at", SASMODELS_SOURCE_MAGNETISM) 229 if os.path.exists(SASMODELS_DEST_REF_MODELS): 230 print("Found docs folder SASMODELS_DEST_REF_MODELS at", SASMODELS_DEST_REF_MODELS) 231 print("Copying sasmodels model toctree files...") 232 for files in os.listdir(SASMODELS_SOURCE_MAGNETISM): 233 if files.endswith(".rst"): 234 fromhere=os.path.join(SASMODELS_SOURCE_MAGNETISM,files) 235 tohere=os.path.join(SASMODELS_DEST_REF_MODELS,files) 236 shutil.copy(fromhere,tohere) 237 else: 238 print("no source directory",SASMODELS_SOURCE_MAGNETISM,"was found") 239 240 if os.path.exists(SASMODELS_SOURCE_MAGIMG): 241 print("Found img folder SASMODELS_SOURCE_MAGIMG at", SASMODELS_SOURCE_MAGIMG) 242 if not os.path.exists(SASMODELS_DEST_MAGIMG): 243 print("Missing img folder SASMODELS_DEST_MAGIMG at", SASMODELS_DEST_MAGIMG) 244 os.makedirs(SASMODELS_DEST_MAGIMG) 245 print("created SASMODELS_DEST_MAGIMG at", SASMODELS_DEST_MAGIMG) 246 print("Copying sasmodels mag image files...") 247 for files in os.listdir(SASMODELS_SOURCE_MAGIMG): 248 fromhere=os.path.join(SASMODELS_SOURCE_MAGIMG,files) 249 tohere=os.path.join(SASMODELS_DEST_MAGIMG,files) 250 shutil.copy(fromhere,tohere) 251 else: 252 print("no source directory",SASMODELS_SOURCE_MAGIMG ,"was found") 253 254 if os.path.exists(SASMODELS_SOURCE_SESANSIMG): 255 print("Found img folder SASMODELS_SOURCE_SESANSIMG at", SASMODELS_SOURCE_SESANSIMG) 256 if not os.path.exists(SASMODELS_DEST_SESANSIMG): 257 print("Missing img folder SASMODELS_DEST_SESANSIMG at", SASMODELS_DEST_SESANSIMG) 258 os.makedirs(SASMODELS_DEST_SESANSIMG) 259 print("created SASMODELS_DEST_SESANSIMG at", SASMODELS_DEST_SESANSIMG) 260 print("Copying sasmodels sesans image files...") 261 for files in os.listdir(SASMODELS_SOURCE_SESANSIMG): 262 fromhere=os.path.join(SASMODELS_SOURCE_SESANSIMG,files) 263 tohere=os.path.join(SASMODELS_DEST_SESANSIMG,files) 264 shutil.copy(fromhere,tohere) 265 else: 266 print("no source directory",SASMODELS_SOURCE_SESANSIMG ,"was found") 267 268 if os.path.exists(SASMODELS_SOURCE_REF_MODELS): 269 print("Found docs folder SASMODELS_SOURCE_REF_MODELS at", SASMODELS_SOURCE_REF_MODELS) 270 if os.path.exists(SASMODELS_DEST_REF_MODELS): 271 print("Found docs folder SASMODELS_DEST_REF_MODELS at", SASMODELS_DEST_REF_MODELS) 272 print("Copying sasmodels model toctree files...") 273 for files in os.listdir(SASMODELS_SOURCE_REF_MODELS): 274 if files.endswith(".rst"): 275 fromhere=os.path.join(SASMODELS_SOURCE_REF_MODELS,files) 276 tohere=os.path.join(SASMODELS_DEST_REF_MODELS,files) 277 shutil.copy(fromhere,tohere) 278 # But need to change the path to the model docs in the tocs 279 for files in os.listdir(SASMODELS_DEST_REF_MODELS): 280 # print files 281 if files.startswith("shape"): 282 print("Changing toc paths in", files) 283 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 284 if files.startswith("sphere"): 285 print("Changing toc paths in", files) 286 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 287 if files.startswith("custom"): 288 print("Changing toc paths in", files) 289 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 290 if files.startswith("structure"): 291 print("Changing toc paths in", files) 292 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 293 else: 294 print("no source directory",SASMODELS_SOURCE_REF_MODELS," was found") 295 296 if os.path.exists(SASMODELS_SOURCE_MODELS): 297 print("Found docs folder SASMODELS_SOURCE_MODELS at", SASMODELS_SOURCE_MODELS) 298 if os.path.exists(SASMODELS_DEST_MODELS): 299 print("Found docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 300 print("Copying sasmodels model files...") 301 for files in os.listdir(SASMODELS_SOURCE_MODELS): 302 if files.endswith(".rst"): 303 fromhere=os.path.join(SASMODELS_SOURCE_MODELS,files) 304 tohere=os.path.join(SASMODELS_DEST_MODELS,files) 305 shutil.copy(fromhere,tohere) 306 else: 307 print("Missing docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 308 os.makedirs(SASMODELS_DEST_MODELS) 309 if not os.path.exists(SASMODELS_DEST_BUILDIMG): 310 os.makedirs(SASMODELS_DEST_BUILDIMG) 311 print("Created docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 312 print("Copying model files for build...") 313 for files in os.listdir(SASMODELS_SOURCE_MODELS): 314 if files.endswith(".rst"): 315 fromhere=os.path.join(SASMODELS_SOURCE_MODELS,files) 316 tohere=os.path.join(SASMODELS_DEST_MODELS,files) 317 shutil.copy(fromhere,tohere) 318 # No choice but to do this because model files are all coded for images in /models/img 319 print("Copying image files for build...") 320 for files in os.listdir(SASMODELS_DEST_IMG): 321 fromhere=os.path.join(SASMODELS_DEST_IMG,files) 322 tohere=os.path.join(SASMODELS_DEST_BUILDIMG,files) 323 shutil.copy(fromhere,tohere) 324 else: 325 print("no source directory",SASMODELS_SOURCE_MODELS,"was found.") 326 print("!!!!NO MODEL DOCS WILL BE BUILT!!!!") 119 # Copy documentation files from sas/.../media to the sphinx directory 120 for root, dirs, _ in os.walk(SASVIEW_MEDIA_SOURCE): 121 if 'media' in dirs: 122 source_dir = abspath(joinpath(root, "media")) 123 relative = dirname(relpath(source_dir, SASVIEW_MEDIA_SOURCE)) 124 dest_dir = joinpath(SPHINX_SOURCE, "user", relative) 125 126 print("Found sasview docs folder at \"%s\"." % relative) 127 copy_tree(source_dir, dest_dir) 128 129 print("=== Sasmodels Docs ===") 130 shutil.copy(joinpath(SASMODELS_DOCS, "rst_prolog"), SPHINX_SOURCE) 131 copy_tree(SASMODELS_MODEL_SOURCE, SASMODELS_MODEL_TARGET) 132 #copy_tree(SASMODELS_API_SOURCE, SASMODELS_API_TARGET) 133 copy_tree(SASMODELS_DEV_SOURCE, SASMODELS_DEV_TARGET) 134 copy_tree(SASMODELS_GUIDE_SOURCE, SASMODELS_GUIDE_TARGET) 135 for filename in SASMODELS_GUIDE_EXCLUDE: 136 os.unlink(joinpath(SASMODELS_GUIDE_TARGET, filename)) 137 138 # Model category files reference the model as ../../model/name.rst. Since 139 # we are rearranging the tree, we need to update each of these links. 140 catdir = joinpath(SASMODELS_GUIDE_TARGET, "models") 141 for filename in os.listdir(catdir): 142 inplace_change(joinpath(catdir, filename), "../../model/", "/user/models/") 143 327 144 328 145 def retrieve_bumps_docs(): … … 330 147 Copies select files from the bumps documentation into fitting perspective 331 148 """ 332 if os.path.exists(BUMPS_DOCS):149 if exists(BUMPS_SOURCE): 333 150 print("=== Retrieve BUMPS Docs ===") 334 filenames = [ os.path.join(BUMPS_DOCS, "optimizer.rst")]335 filenames += glob( os.path.join(BUMPS_DOCS, "dream-*.png"))336 filenames += glob( os.path.join(BUMPS_DOCS, "fit-*.png"))151 filenames = [joinpath(BUMPS_SOURCE, "optimizer.rst")] 152 filenames += glob(joinpath(BUMPS_SOURCE, "dream-*.png")) 153 filenames += glob(joinpath(BUMPS_SOURCE, "fit-*.png")) 337 154 for f in filenames: 338 155 print("Copying file", f) … … 354 171 355 172 # Clean directory before generating a new version. 356 _remove_dir(SPHINX_SOURCE_API)173 #_remove_dir(SASVIEW_API_TARGET) 357 174 358 175 subprocess.call(["sphinx-apidoc", 359 "-o", S PHINX_SOURCE_API, # Output dir.176 "-o", SASVIEW_API_TARGET, # Output dir. 360 177 "-d", "8", # Max depth of TOC. 178 "-H", "SasView", # Package header 361 179 SASVIEW_BUILD]) 180 181 subprocess.call(["sphinx-apidoc", 182 "-o", SASMODELS_API_TARGET, # Output dir. 183 "-d", "8", # Max depth of TOC. 184 "-H", "sasmodels", # Package header 185 SASMODELS_BUILD, 186 joinpath(SASMODELS_BUILD, "sasmodels", "models"), # exclude 187 ]) 362 188 363 189 def build_pdf(): … … 368 194 subprocess.call(["sphinx-build", 369 195 "-b", "latex", # Builder name. TODO: accept as arg to setup.py. 370 "-d", os.path.join(SPHINX_BUILD, "doctrees"),196 "-d", joinpath(SPHINX_BUILD, "doctrees"), 371 197 SPHINX_SOURCE, 372 os.path.join(SPHINX_BUILD, "latex")])373 374 LATEXDIR = os.path.join(SPHINX_BUILD, "latex")198 joinpath(SPHINX_BUILD, "latex")]) 199 200 LATEXDIR = joinpath(SPHINX_BUILD, "latex") 375 201 #TODO: Does it need to be done so many time? 376 202 def pdflatex(): … … 384 210 385 211 print("=== Copy PDF to HTML Directory ===") 386 source = os.path.join(LATEXDIR, "SasView.pdf")387 target = os.path.join(SASVIEW_DOCS, "SasView.pdf")212 source = joinpath(LATEXDIR, "SasView.pdf") 213 target = joinpath(SASVIEW_DOC_TARGET, "SasView.pdf") 388 214 shutil.copyfile(source, target) 389 215 … … 395 221 subprocess.call(["sphinx-build", 396 222 "-b", "html", # Builder name. TODO: accept as arg to setup.py. 397 "-d", os.path.join(SPHINX_BUILD, "doctrees"),223 "-d", joinpath(SPHINX_BUILD, "doctrees"), 398 224 SPHINX_SOURCE, 399 os.path.join(SPHINX_BUILD, "html")])225 joinpath(SPHINX_BUILD, "html")]) 400 226 401 227 print("=== Copy HTML Docs to Build Directory ===") 402 html = os.path.join(SPHINX_BUILD, "html")403 copy_tree(html, SASVIEW_DOC S)228 html = joinpath(SPHINX_BUILD, "html") 229 copy_tree(html, SASVIEW_DOC_TARGET) 404 230 405 231 def fetch_katex(version, destination="_static"): … … 408 234 url = "https://github.com/Khan/KaTeX/releases/download/%s/katex.zip" % version 409 235 cache_path = "katex_%s.zip" % version 410 if not os.path.exists(cache_path):236 if not exists(cache_path): 411 237 try: 412 238 fd_in = urllib2.urlopen(url) … … 420 246 def convert_katex(): 421 247 print("=== Preprocess HTML, converting latex to html ===") 422 subprocess.call(["node", "convertKaTex.js", SASVIEW_DOC S])248 subprocess.call(["node", "convertKaTex.js", SASVIEW_DOC_TARGET]) 423 249 424 250 def convert_mathjax(): 425 251 print("=== Preprocess HTML, converting latex to html ===") 426 subprocess.call(["node", "convertMathJax.js", SASVIEW_DOC S])252 subprocess.call(["node", "convertMathJax.js", SASVIEW_DOC_TARGET]) 427 253 428 254 def fetch_mathjax():
Note: See TracChangeset
for help on using the changeset viewer.