Changeset 0e2d287 in sasview for docs


Ignore:
Timestamp:
Jun 13, 2017 9:48:11 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
9d566b2
Parents:
d9c1551
Message:

docs: lint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/sphinx-docs/build_sphinx.py

    r01f1e17 r0e2d287  
    2121from os import listdir 
    2222 
    23 platform = '.%s-%s'%(get_platform(),sys.version[:3]) 
     23platform = '.%s-%s'%(get_platform(), sys.version[:3]) 
    2424 
    2525CURRENT_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 
     
    4646SASMODELS_SOURCE_MODELS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "model") 
    4747SASMODELS_SOURCE_IMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "model", "img") 
    48 SASMODELS_SOURCE_AUTOIMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "_build", "html","_images") 
     48SASMODELS_SOURCE_AUTOIMG = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", "sasmodels", "doc", "_build", "html", "_images") 
    4949## Don't do assemble-in-place 
    5050## Assemble the docs in a temporary folder 
     
    7373def inplace_change(filename, old_string, new_string): 
    7474# Thanks to http://stackoverflow.com/questions/4128144/replace-string-within-file-contents 
    75         s=open(filename).read() 
    76         if old_string in s: 
    77                 print('Changing "{old_string}" to "{new_string}"'.format(**locals())) 
    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: 
    84                 print('No occurences of "{old_string}" found.'.format(**locals())) 
     75    s = open(filename).read() 
     76    if old_string in s: 
     77        print('Changing "{old_string}" to "{new_string}"'.format(**locals())) 
     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: 
     84        print('No occurences of "{old_string}" found.'.format(**locals())) 
    8585 
    8686def _remove_dir(dir_path): 
     
    109109    print("=== Copying Source toctrees ===") 
    110110    if os.path.exists(SASVIEW_TOC_SOURCE): 
    111        print("Found docs folder at", SASVIEW_TOC_SOURCE) 
    112        shutil.copytree(SASVIEW_TOC_SOURCE, SPHINX_SOURCE) 
     111        print("Found docs folder at", SASVIEW_TOC_SOURCE) 
     112        shutil.copytree(SASVIEW_TOC_SOURCE, SPHINX_SOURCE) 
    113113 
    114114def retrieve_user_docs(): 
     
    147147    print("=== Including Test Data Docs ===") 
    148148    if os.path.exists(SASVIEW_TEST): 
    149        print("Found docs folder at", SASVIEW_TEST) 
    150        shutil.copytree(SASVIEW_TEST, SPHINX_SOURCE_TEST) 
     149        print("Found docs folder at", SASVIEW_TEST) 
     150        shutil.copytree(SASVIEW_TEST, SPHINX_SOURCE_TEST) 
    151151 
    152152    print("=== And the Sasmodels Docs ===") 
    153153    # Make sure we have the relevant images for the new sasmodels documentation 
    154     # First(!) we'll make a local reference copy for SasView (/new-models will be cleaned each build) 
     154    # First(!) we'll make a local reference copy for SasView 
     155    # (/new-models will be cleaned each build) 
    155156    if os.path.exists(SASMODELS_SOURCE_IMG): 
    156157        print("Found img folder SASMODELS_SOURCE_IMG at", SASMODELS_SOURCE_IMG) 
     
    163164        print("Copying sasmodels model image files...") 
    164165        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) 
    168     else: 
    169         print("no source directory",SASMODELS_SOURCE_IMG,"was found") 
     166            fromhere = os.path.join(SASMODELS_SOURCE_IMG, files) 
     167            tohere = os.path.join(SASMODELS_DEST_IMG, files) 
     168            shutil.copy(fromhere, tohere) 
     169    else: 
     170        print("no source directory", SASMODELS_SOURCE_IMG, "was found") 
    170171 
    171172    if os.path.exists(SASMODELS_SOURCE_AUTOIMG): 
     
    177178        print("Copying sasmodels model auto-generated image files...") 
    178179        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) 
    182     else: 
    183         print("no source directory",SASMODELS_SOURCE_AUTOIMG ,"was found") 
     180            fromhere = os.path.join(SASMODELS_SOURCE_AUTOIMG, files) 
     181            tohere = os.path.join(SASMODELS_DEST_IMG, files) 
     182            shutil.copy(fromhere, tohere) 
     183    else: 
     184        print("no source directory", SASMODELS_SOURCE_AUTOIMG, "was found") 
    184185 
    185186    # And the rst prolog with the unit substitutions 
     
    191192            for files in os.listdir(SASMODELS_SOURCE_PROLOG): 
    192193                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) 
    196     else: 
    197         print("no source directory",SASMODELS_SOURCE_PROLOG, "was found") 
     194                    fromhere = os.path.join(SASMODELS_SOURCE_PROLOG, files) 
     195                    tohere = os.path.join(SASMODELS_DEST_PROLOG, files) 
     196                    shutil.copy(fromhere, tohere) 
     197    else: 
     198        print("no source directory", SASMODELS_SOURCE_PROLOG, "was found") 
    198199 
    199200    if os.path.exists(SASMODELS_SOURCE_GPU): 
     
    204205            for files in os.listdir(SASMODELS_SOURCE_GPU): 
    205206                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) 
    209     else: 
    210         print("no source directory",SASMODELS_SOURCE_GPU,"was found") 
     207                    fromhere = os.path.join(SASMODELS_SOURCE_GPU, files) 
     208                    tohere = os.path.join(SPHINX_SOURCE_USER, files) 
     209                    shutil.copy(fromhere, tohere) 
     210    else: 
     211        print("no source directory", SASMODELS_SOURCE_GPU, "was found") 
    211212 
    212213    if os.path.exists(SASMODELS_SOURCE_SESANS): 
     
    217218            for files in os.listdir(SASMODELS_SOURCE_SESANS): 
    218219                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) 
    222     else: 
    223         print("no source directory",SASMODELS_SOURCE_SESANS,"was found") 
     220                    fromhere = os.path.join(SASMODELS_SOURCE_SESANS, files) 
     221                    tohere = os.path.join(SPHINX_SOURCE_USER, files) 
     222                    shutil.copy(fromhere, tohere) 
     223    else: 
     224        print("no source directory", SASMODELS_SOURCE_SESANS, "was found") 
    224225 
    225226    if os.path.exists(SASMODELS_SOURCE_MAGNETISM): 
     
    230231            for files in os.listdir(SASMODELS_SOURCE_MAGNETISM): 
    231232                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) 
    235     else: 
    236         print("no source directory",SASMODELS_SOURCE_MAGNETISM,"was found") 
     233                    fromhere = os.path.join(SASMODELS_SOURCE_MAGNETISM, files) 
     234                    tohere = os.path.join(SASMODELS_DEST_REF_MODELS, files) 
     235                    shutil.copy(fromhere, tohere) 
     236    else: 
     237        print("no source directory", SASMODELS_SOURCE_MAGNETISM, "was found") 
    237238 
    238239    if os.path.exists(SASMODELS_SOURCE_MAGIMG): 
     
    244245        print("Copying sasmodels mag image files...") 
    245246        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) 
    249     else: 
    250         print("no source directory",SASMODELS_SOURCE_MAGIMG ,"was found") 
     247            fromhere = os.path.join(SASMODELS_SOURCE_MAGIMG, files) 
     248            tohere = os.path.join(SASMODELS_DEST_MAGIMG, files) 
     249            shutil.copy(fromhere, tohere) 
     250    else: 
     251        print("no source directory", SASMODELS_SOURCE_MAGIMG, "was found") 
    251252 
    252253    if os.path.exists(SASMODELS_SOURCE_SESANSIMG): 
     
    258259        print("Copying sasmodels sesans image files...") 
    259260        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) 
    263     else: 
    264         print("no source directory",SASMODELS_SOURCE_SESANSIMG ,"was found") 
     261            fromhere = os.path.join(SASMODELS_SOURCE_SESANSIMG, files) 
     262            tohere = os.path.join(SASMODELS_DEST_SESANSIMG, files) 
     263            shutil.copy(fromhere, tohere) 
     264    else: 
     265        print("no source directory", SASMODELS_SOURCE_SESANSIMG, "was found") 
    265266 
    266267    if os.path.exists(SASMODELS_SOURCE_REF_MODELS): 
     
    271272            for files in os.listdir(SASMODELS_SOURCE_REF_MODELS): 
    272273                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) 
     274                    fromhere = os.path.join(SASMODELS_SOURCE_REF_MODELS, files) 
     275                    tohere = os.path.join(SASMODELS_DEST_REF_MODELS, files) 
     276                    shutil.copy(fromhere, tohere) 
    276277            # But need to change the path to the model docs in the tocs 
    277278            for files in os.listdir(SASMODELS_DEST_REF_MODELS): 
     
    279280                if files.startswith("shape"): 
    280281                    print("Changing toc paths in", files) 
    281                     inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 
     282                    inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS, files), "../../model/", "models/") 
    282283                if files.startswith("sphere"): 
    283284                    print("Changing toc paths in", files) 
    284                     inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 
     285                    inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS, files), "../../model/", "models/") 
    285286                if files.startswith("custom"): 
    286287                    print("Changing toc paths in", files) 
    287                     inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 
     288                    inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS, files), "../../model/", "models/") 
    288289                if files.startswith("structure"): 
    289290                    print("Changing toc paths in", files) 
    290                     inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 
    291     else: 
    292         print("no source directory",SASMODELS_SOURCE_REF_MODELS," was found") 
     291                    inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS, files), "../../model/", "models/") 
     292    else: 
     293        print("no source directory", SASMODELS_SOURCE_REF_MODELS, " was found") 
    293294 
    294295    if os.path.exists(SASMODELS_SOURCE_MODELS): 
     
    299300            for files in os.listdir(SASMODELS_SOURCE_MODELS): 
    300301                if files.endswith(".rst"): 
    301                     fromhere=os.path.join(SASMODELS_SOURCE_MODELS,files) 
    302                     tohere=os.path.join(SASMODELS_DEST_MODELS,files) 
    303                     shutil.copy(fromhere,tohere) 
     302                    fromhere = os.path.join(SASMODELS_SOURCE_MODELS, files) 
     303                    tohere = os.path.join(SASMODELS_DEST_MODELS, files) 
     304                    shutil.copy(fromhere, tohere) 
    304305        else: 
    305306            print("Missing docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 
     
    311312            for files in os.listdir(SASMODELS_SOURCE_MODELS): 
    312313                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) 
     314                    fromhere = os.path.join(SASMODELS_SOURCE_MODELS, files) 
     315                    tohere = os.path.join(SASMODELS_DEST_MODELS, files) 
     316                    shutil.copy(fromhere, tohere) 
    316317            # No choice but to do this because model files are all coded for images in /models/img 
    317318            print("Copying image files for build...") 
    318319            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) 
    322     else: 
    323         print("no source directory",SASMODELS_SOURCE_MODELS,"was found.") 
     320                fromhere = os.path.join(SASMODELS_DEST_IMG, files) 
     321                tohere = os.path.join(SASMODELS_DEST_BUILDIMG, files) 
     322                shutil.copy(fromhere, tohere) 
     323    else: 
     324        print("no source directory", SASMODELS_SOURCE_MODELS, "was found.") 
    324325        print("!!!!NO MODEL DOCS WILL BE BUILT!!!!") 
    325326 
Note: See TracChangeset for help on using the changeset viewer.