Changeset f4d571b in sasview
- Timestamp:
- Apr 11, 2017 5:38:17 AM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 21bba86
- Parents:
- 6c7e4cc1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/sphinx-docs/build_sphinx.py
r115eb7e rf4d571b 56 56 57 57 #if os.path.exists(SASMODELS_SOURCE_PROLOG): 58 # print "Found models prolog folder at 58 # print "Found models prolog folder at", SASMODELS_SOURCE_PROLOG 59 59 #if os.path.exists(SASMODELS_SOURCE_REF_MODELS): 60 # print "Found models ref folder at 60 # print "Found models ref folder at", SASMODELS_SOURCE_REF_MODELS 61 61 #if os.path.exists(SASMODELS_SOURCE_MODELS): 62 # print "Found models folder at 62 # print "Found models folder at", SASMODELS_SOURCE_MODELS 63 63 #if os.path.exists(SASMODELS_SOURCE_IMG): 64 # print "Found img folder at 64 # print "Found img folder at", SASMODELS_SOURCE_IMG 65 65 #if os.path.exists(SASMODELS_DEST_REF_MODELS): 66 # print "Found models ref folder at 66 # print "Found models ref folder at", SASMODELS_DEST_REF_MODELS 67 67 #if os.path.exists(SASMODELS_DEST_MODELS): 68 # print "Found models folder at 68 # print "Found models folder at", SASMODELS_DEST_MODELS 69 69 #if os.path.exists(SASMODELS_DEST_IMG): 70 # print "Found img folder at 70 # print "Found img folder at", SASMODELS_DEST_IMG 71 71 #sys.exit() 72 72 … … 107 107 Clean the sphinx build directory. 108 108 """ 109 print "=== Cleaning Sphinx Build ==="109 print("=== Cleaning Sphinx Build ===") 110 110 _remove_dir(SASVIEW_DOCS) 111 111 _remove_dir(SPHINX_BUILD) … … 120 120 Copy the source toctrees to new folder for assembling the sphinx-docs 121 121 """ 122 print "=== Copying Source toctrees ==="122 print("=== Copying Source toctrees ===") 123 123 if os.path.exists(SASVIEW_TOC_SOURCE): 124 print "Found docs folder at ", SASVIEW_TOC_SOURCE124 print("Found docs folder at", SASVIEW_TOC_SOURCE) 125 125 shutil.copytree(SASVIEW_TOC_SOURCE, SPHINX_SOURCE) 126 126 … … 141 141 so that Sphinx may pick it up when generating the documentation. 142 142 """ 143 print "=== Retrieve User Docs ==="143 print("=== Retrieve User Docs ===") 144 144 145 145 # Copy documentation files from their "source" to their "destination". … … 148 148 149 149 docs = os.path.abspath(os.path.join(root, dirname)) 150 print "Found docs folder at \"%s\"." % docs150 print("Found docs folder at \"%s\"." % docs) 151 151 152 152 dest_dir_part = os.path.dirname(os.path.relpath(docs, SASVIEW_SRC)) … … 158 158 159 159 # Now pickup testdata_help.rst 160 # print os.path.abspath(SASVIEW_TEST) 161 # print os.path.abspath(SPHINX_SOURCE_TEST) 162 print "=== Including Test Data Docs ===" 160 print("=== Including Test Data Docs ===") 163 161 if os.path.exists(SASVIEW_TEST): 164 print "Found docs folder at ", SASVIEW_TEST162 print("Found docs folder at", SASVIEW_TEST) 165 163 shutil.copytree(SASVIEW_TEST, SPHINX_SOURCE_TEST) 166 164 167 print "=== And the Sasmodels Docs ==="165 print("=== And the Sasmodels Docs ===") 168 166 # Make sure we have the relevant images for the new sasmodels documentation 169 167 # First(!) we'll make a local reference copy for SasView (/new-models will be cleaned each build) 170 168 if os.path.exists(SASMODELS_SOURCE_IMG): 171 print "Found img folder SASMODELS_SOURCE_IMG at ", SASMODELS_SOURCE_IMG169 print("Found img folder SASMODELS_SOURCE_IMG at", SASMODELS_SOURCE_IMG) 172 170 if not os.path.exists(SASMODELS_DEST_IMG): 173 print "Missing docs folder SASMODELS_DEST_IMG at ", SASMODELS_DEST_IMG171 print("Missing docs folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 174 172 os.makedirs(SASMODELS_DEST_IMG) 175 print "created SASMODELS_DEST_BUILDIMG at ", SASMODELS_DEST_BUILDIMG 176 else: print "Found img folder SASMODELS_DEST_IMG at ", SASMODELS_DEST_IMG 177 print "Copying sasmodels model image files..." 173 print("created SASMODELS_DEST_BUILDIMG at", SASMODELS_DEST_BUILDIMG) 174 else: 175 print("Found img folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 176 print("Copying sasmodels model image files...") 178 177 for files in os.listdir(SASMODELS_SOURCE_IMG): 179 178 fromhere=os.path.join(SASMODELS_SOURCE_IMG,files) 180 179 tohere=os.path.join(SASMODELS_DEST_IMG,files) 181 180 shutil.copy(fromhere,tohere) 182 else: print "cannot find SASMODELS_SOURCE_IMG", SASMODELS_SOURCE_IMG 181 else: 182 print("no source directory",SASMODELS_SOURCE_IMG,"was found") 183 183 184 184 if os.path.exists(SASMODELS_SOURCE_AUTOIMG): 185 print "Found img folder SASMODELS_SOURCE_AUTOIMG at ", SASMODELS_SOURCE_AUTOIMG185 print("Found img folder SASMODELS_SOURCE_AUTOIMG at", SASMODELS_SOURCE_AUTOIMG) 186 186 if not os.path.exists(SASMODELS_DEST_IMG): 187 print "Missing docs folder SASMODELS_DEST_IMG at ", SASMODELS_DEST_IMG187 print("Missing docs folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 188 188 os.makedirs(SASMODELS_DEST_BUILDIMG) 189 print "created SASMODELS_DEST_BUILDIMG at ", SASMODELS_DEST_BUILDIMG190 print "Copying sasmodels model auto-generated image files..."189 print("created SASMODELS_DEST_BUILDIMG at", SASMODELS_DEST_BUILDIMG) 190 print("Copying sasmodels model auto-generated image files...") 191 191 for files in os.listdir(SASMODELS_SOURCE_AUTOIMG): 192 192 fromhere=os.path.join(SASMODELS_SOURCE_AUTOIMG,files) 193 193 tohere=os.path.join(SASMODELS_DEST_IMG,files) 194 194 shutil.copy(fromhere,tohere) 195 else: print "no source directory",SASMODELS_SOURCE_AUTOIMG ,"was found" 195 else: 196 print("no source directory",SASMODELS_SOURCE_AUTOIMG ,"was found") 196 197 197 198 # And the rst prolog with the unit substitutions 198 199 if os.path.exists(SASMODELS_SOURCE_PROLOG): 199 print "Found prolog folder SASMODELS_SOURCE_PROLOG at ", SASMODELS_SOURCE_PROLOG200 print("Found prolog folder SASMODELS_SOURCE_PROLOG at", SASMODELS_SOURCE_PROLOG) 200 201 if os.path.exists(SASMODELS_DEST_PROLOG): 201 print "Found docs folder SASMODELS_DEST_PROLOG at ", SASMODELS_DEST_PROLOG202 print "Copying sasmodels rst_prolog file..."202 print("Found docs folder SASMODELS_DEST_PROLOG at", SASMODELS_DEST_PROLOG) 203 print("Copying sasmodels rst_prolog file...") 203 204 for files in os.listdir(SASMODELS_SOURCE_PROLOG): 204 205 if files.startswith("rst"): … … 206 207 tohere=os.path.join(SASMODELS_DEST_PROLOG,files) 207 208 shutil.copy(fromhere,tohere) 208 else: print "no source directory",SASMODELS_SOURCE_PROLOG, "was found" 209 else: 210 print "no source directory",SASMODELS_SOURCE_PROLOG, "was found" 209 211 210 212 if os.path.exists(SASMODELS_SOURCE_GPU): 211 print "Found docs folder SASMODELS_SOURCE_GPU at ", SASMODELS_SOURCE_GPU213 print("Found docs folder SASMODELS_SOURCE_GPU at", SASMODELS_SOURCE_GPU) 212 214 if os.path.exists(SPHINX_SOURCE_USER): 213 print "Found docs folder SPHINX_SOURCE_USER at ", SPHINX_SOURCE_USER214 print "Copying sasmodels gpu files..."215 print("Found docs folder SPHINX_SOURCE_USER at", SPHINX_SOURCE_USER) 216 print("Copying sasmodels gpu files...") 215 217 for files in os.listdir(SASMODELS_SOURCE_GPU): 216 218 if files.endswith(".rst"): … … 218 220 tohere=os.path.join(SPHINX_SOURCE_USER,files) 219 221 shutil.copy(fromhere,tohere) 220 else: print "no source directory",SASMODELS_SOURCE_GPU," was found" 222 else: 223 print "no source directory",SASMODELS_SOURCE_GPU,"was found" 221 224 222 225 if os.path.exists(SASMODELS_SOURCE_SESANS): 223 print "Found docs folder SASMODELS_SOURCE_SESANS at ", SASMODELS_SOURCE_SESANS226 print("Found docs folder SASMODELS_SOURCE_SESANS at", SASMODELS_SOURCE_SESANS) 224 227 if os.path.exists(SPHINX_SOURCE_USER): 225 print "Found docs folder SPHINX_SOURCE_USER at ", SPHINX_SOURCE_USER226 print "Copying sasmodels sesans files..."228 print("Found docs folder SPHINX_SOURCE_USER at", SPHINX_SOURCE_USER) 229 print("Copying sasmodels sesans files...") 227 230 for files in os.listdir(SASMODELS_SOURCE_SESANS): 228 231 if files.endswith(".rst"): … … 230 233 tohere=os.path.join(SPHINX_SOURCE_USER,files) 231 234 shutil.copy(fromhere,tohere) 232 else: print "no source directory",SASMODELS_SOURCE_SESANS," was found" 235 else: 236 print("no source directory",SASMODELS_SOURCE_SESANS,"was found") 233 237 234 238 if os.path.exists(SASMODELS_SOURCE_MAGNETISM): 235 print "Found docs folder SASMODELS_SOURCE_MAGNETISM at ", SASMODELS_SOURCE_MAGNETISM239 print("Found docs folder SASMODELS_SOURCE_MAGNETISM at", SASMODELS_SOURCE_MAGNETISM) 236 240 if os.path.exists(SASMODELS_DEST_REF_MODELS): 237 print "Found docs folder SASMODELS_DEST_REF_MODELS at ", SASMODELS_DEST_REF_MODELS238 print "Copying sasmodels model toctree files..."241 print("Found docs folder SASMODELS_DEST_REF_MODELS at", SASMODELS_DEST_REF_MODELS) 242 print("Copying sasmodels model toctree files...") 239 243 for files in os.listdir(SASMODELS_SOURCE_MAGNETISM): 240 244 if files.endswith(".rst"): … … 242 246 tohere=os.path.join(SASMODELS_DEST_REF_MODELS,files) 243 247 shutil.copy(fromhere,tohere) 244 else: print "no source directory",SASMODELS_SOURCE_MAGNETISM," was found" 248 else: 249 print("no source directory",SASMODELS_SOURCE_MAGNETISM,"was found") 245 250 246 251 if os.path.exists(SASMODELS_SOURCE_MAGIMG): 247 print "Found img folder SASMODELS_SOURCE_MAGIMG at ", SASMODELS_SOURCE_MAGIMG252 print("Found img folder SASMODELS_SOURCE_MAGIMG at", SASMODELS_SOURCE_MAGIMG) 248 253 if not os.path.exists(SASMODELS_DEST_MAGIMG): 249 print "Missing img folder SASMODELS_DEST_MAGIMG at ", SASMODELS_DEST_MAGIMG254 print("Missing img folder SASMODELS_DEST_MAGIMG at", SASMODELS_DEST_MAGIMG) 250 255 os.makedirs(SASMODELS_DEST_MAGIMG) 251 print "created SASMODELS_DEST_MAGIMG at ", SASMODELS_DEST_MAGIMG252 print "Copying sasmodels mag image files..."256 print("created SASMODELS_DEST_MAGIMG at", SASMODELS_DEST_MAGIMG) 257 print("Copying sasmodels mag image files...") 253 258 for files in os.listdir(SASMODELS_SOURCE_MAGIMG): 254 259 fromhere=os.path.join(SASMODELS_SOURCE_MAGIMG,files) 255 260 tohere=os.path.join(SASMODELS_DEST_MAGIMG,files) 256 261 shutil.copy(fromhere,tohere) 257 else: print "no source directory",SASMODELS_SOURCE_MAGIMG ,"was found" 262 else: 263 print("no source directory",SASMODELS_SOURCE_MAGIMG ,"was found") 258 264 259 265 if os.path.exists(SASMODELS_SOURCE_SESANSIMG): 260 print "Found img folder SASMODELS_SOURCE_SESANSIMG at ", SASMODELS_SOURCE_SESANSIMG266 print("Found img folder SASMODELS_SOURCE_SESANSIMG at", SASMODELS_SOURCE_SESANSIMG) 261 267 if not os.path.exists(SASMODELS_DEST_SESANSIMG): 262 print "Missing img folder SASMODELS_DEST_SESANSIMG at ", SASMODELS_DEST_SESANSIMG268 print("Missing img folder SASMODELS_DEST_SESANSIMG at", SASMODELS_DEST_SESANSIMG) 263 269 os.makedirs(SASMODELS_DEST_SESANSIMG) 264 print "created SASMODELS_DEST_SESANSIMG at ", SASMODELS_DEST_SESANSIMG265 print "Copying sasmodels sesans image files..."270 print("created SASMODELS_DEST_SESANSIMG at", SASMODELS_DEST_SESANSIMG) 271 print("Copying sasmodels sesans image files...") 266 272 for files in os.listdir(SASMODELS_SOURCE_SESANSIMG): 267 273 fromhere=os.path.join(SASMODELS_SOURCE_SESANSIMG,files) 268 274 tohere=os.path.join(SASMODELS_DEST_SESANSIMG,files) 269 275 shutil.copy(fromhere,tohere) 270 else: print "no source directory",SASMODELS_SOURCE_SESANSIMG ,"was found" 276 else: 277 print("no source directory",SASMODELS_SOURCE_SESANSIMG ,"was found") 271 278 272 279 if os.path.exists(SASMODELS_SOURCE_REF_MODELS): 273 print "Found docs folder SASMODELS_SOURCE_REF_MODELS at ", SASMODELS_SOURCE_REF_MODELS280 print("Found docs folder SASMODELS_SOURCE_REF_MODELS at", SASMODELS_SOURCE_REF_MODELS) 274 281 if os.path.exists(SASMODELS_DEST_REF_MODELS): 275 print "Found docs folder SASMODELS_DEST_REF_MODELS at ", SASMODELS_DEST_REF_MODELS276 print "Copying sasmodels model toctree files..."282 print("Found docs folder SASMODELS_DEST_REF_MODELS at", SASMODELS_DEST_REF_MODELS) 283 print("Copying sasmodels model toctree files...") 277 284 for files in os.listdir(SASMODELS_SOURCE_REF_MODELS): 278 285 if files.endswith(".rst"): … … 284 291 # print files 285 292 if files.startswith("shape"): 286 print "Changing toc paths in", files293 print("Changing toc paths in", files) 287 294 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 288 295 if files.startswith("sphere"): 289 print "Changing toc paths in", files296 print("Changing toc paths in", files) 290 297 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 291 298 if files.startswith("custom"): 292 print "Changing toc paths in", files299 print("Changing toc paths in", files) 293 300 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 294 301 if files.startswith("structure"): 295 print "Changing toc paths in", files302 print("Changing toc paths in", files) 296 303 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 297 else: print "no source directory",SASMODELS_SOURCE_REF_MODELS," was found" 304 else: 305 print("no source directory",SASMODELS_SOURCE_REF_MODELS," was found") 298 306 299 307 if os.path.exists(SASMODELS_SOURCE_MODELS): 300 print "Found docs folder SASMODELS_SOURCE_MODELS at ", SASMODELS_SOURCE_MODELS308 print("Found docs folder SASMODELS_SOURCE_MODELS at", SASMODELS_SOURCE_MODELS) 301 309 if os.path.exists(SASMODELS_DEST_MODELS): 302 print "Found docs folder SASMODELS_DEST_MODELS at ", SASMODELS_DEST_MODELS303 print "Copying sasmodels model files..."310 print("Found docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 311 print("Copying sasmodels model files...") 304 312 for files in os.listdir(SASMODELS_SOURCE_MODELS): 305 313 if files.endswith(".rst"): … … 308 316 shutil.copy(fromhere,tohere) 309 317 else: 310 print "Missing docs folder SASMODELS_DEST_MODELS at ", SASMODELS_DEST_MODELS318 print("Missing docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 311 319 os.makedirs(SASMODELS_DEST_MODELS) 312 320 if not os.path.exists(SASMODELS_DEST_BUILDIMG): 313 321 os.makedirs(SASMODELS_DEST_BUILDIMG) 314 print "Created docs folder SASMODELS_DEST_MODELS at ", SASMODELS_DEST_MODELS315 print "Copying model files for build..."322 print("Created docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 323 print("Copying model files for build...") 316 324 for files in os.listdir(SASMODELS_SOURCE_MODELS): 317 325 if files.endswith(".rst"): … … 320 328 shutil.copy(fromhere,tohere) 321 329 # No choice but to do this because model files are all coded for images in /models/img 322 print "Copying image files for build..."330 print("Copying image files for build...") 323 331 for files in os.listdir(SASMODELS_DEST_IMG): 324 332 fromhere=os.path.join(SASMODELS_DEST_IMG,files) 325 333 tohere=os.path.join(SASMODELS_DEST_BUILDIMG,files) 326 334 shutil.copy(fromhere,tohere) 327 else: print "no source directory",SASMODELS_SOURCE_MODELS," was found.\n !!!!NO MODEL DOCS WILL BE BUILT!!!!" 335 else: 336 print("no source directory",SASMODELS_SOURCE_MODELS,"was found.") 337 print("!!!!NO MODEL DOCS WILL BE BUILT!!!!") 328 338 329 339 … … 333 343 """ 334 344 if os.path.exists(BUMPS_DOCS): 335 print "=== Retrieve BUMPS Docs ==="345 print("=== Retrieve BUMPS Docs ===") 336 346 filenames = [os.path.join(BUMPS_DOCS, "optimizer.rst")] 337 347 filenames += glob(os.path.join(BUMPS_DOCS, "dream-*.png")) 338 348 filenames += glob(os.path.join(BUMPS_DOCS, "fit-*.png")) 339 349 for f in filenames: 340 print "Copying file", f350 print("Copying file", f) 341 351 shutil.copy(f, BUMPS_TARGET) 342 352 else: 343 print 353 print(""" 344 354 *** Error *** missing directory %s 345 355 The documentation will not include the optimizer selection section. … … 347 357 348 358 349 """ % BUMPS_DOCS 359 """ % BUMPS_DOCS) 350 360 351 361 def apidoc(): … … 354 364 in the SasView build directory. 355 365 """ 356 print "=== Generate API Rest Files ==="366 print("=== Generate API Rest Files ===") 357 367 358 368 # Clean directory before generating a new version. … … 368 378 Runs sphinx-build. Reads in all .rst files and spits out the final html. 369 379 """ 370 print "=== Build HTML Docs from Rest Files ==="380 print("=== Build HTML Docs from Rest Files ===") 371 381 subprocess.call(["sphinx-build", 372 382 "-b", "html", # Builder name. TODO: accept as arg to setup.py. … … 375 385 os.path.join(SPHINX_BUILD, "html")]) 376 386 377 print "=== Copy HTML Docs to Build Directory ==="387 print("=== Copy HTML Docs to Build Directory ===") 378 388 html = os.path.join(SPHINX_BUILD, "html") 379 389 copy_tree(html, SASVIEW_DOCS) … … 387 397 build() 388 398 389 print "=== Done ==="399 print("=== Done ===") 390 400 391 401 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.