Ticket #13245: trac_13245-clone-docbuild.patch

File trac_13245-clone-docbuild.patch, 5.8 KB (added by jhpalmieri, 7 years ago)

scripts repo

  • sage-clone

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1342134577 18000
    # Node ID 3865ec06200dd74a56671f4680e0a17b1d726f8d
    # Parent  19bf31ab952e50d062d3e28766f0475c187928aa
    Command-line option "-N" for sage --clone: don't rebuild docs.
    Use this option during the clone in "sage --combinat install".
    
    diff --git a/sage-clone b/sage-clone
    a b os.chdir(os.path.join(SAGE_ROOT, "devel" 
    88
    99def usage():
    1010    print "\n\n"
    11     print "sage -clone <new_branch> [-r rev]"
     11    print "sage -clone <new_branch> [-r rev] [--nodoc|-N]"
     12    print "'-r rev' means to include the specified changeset when cloning"
     13    print "'--nodoc' (or '-N') means: do not rebuild the documentation"
     14    print "after cloning."
    1215    sys.exit(1)
    1316
    1417if len(sys.argv) == 1:
    1518    usage()
    1619
    17 if sys.argv[1] == '-r':
    18     if len(sys.argv) < 4:
    19         usage()
    20     sys.argv = [sys.argv[0], sys.argv[3], sys.argv[1], sys.argv[2]]
     20branch = ''
     21rev = False
     22build_docs = True
     23args = []
     24for opt in sys.argv:
     25    if rev: # if previous argument was '-r', save this argument as the changeset.
     26        args.append('-r %' % opt)
     27        rev = False
     28        continue
     29    if opt == '-r' or opt == '--rev':
     30        rev = True
     31        continue
     32    if opt == '-N' or opt == '--nodoc':
     33        build_docs = False
     34        continue
     35    if not opt.startswith('-'):
     36        branch = 'sage-%s' % opt
     37        continue
     38    args.append(opt)
    2139
    22 branch = 'sage-%s'%sys.argv[1]
     40# if rev is True, then the command ended with '-r'.
     41if rev or len(branch) == 0:
     42    usage()
    2343
    2444if os.path.isdir(branch):
    2545    print "Sage library branch %s already exists so I can't clone to it."%branch
    if not os.path.isdir('sage'): 
    3050    sys.exit(1)
    3151
    3252print "Now cloning the current Sage library branch..."
    33 cmd = 'hg clone %s sage %s '%(' '.join(sys.argv[2:]), branch)
     53cmd = ' '.join(['hg', 'clone'] + args + ['sage', branch])
    3454print cmd
    3555if os.system(cmd):
    3656    print "Error cloning"
    print "Copying over documentation output 
    89109copy_dtree('sage/doc/output', branch + '/doc/output')
    90110
    91111print "Building " + branch + "..."
    92 cmd = 'sage -b %s'%sys.argv[1]
     112cmd = 'sage -b %s'% branch[5:]
    93113print cmd
    94114if os.system(cmd):
    95115    print "Error building Sage"
    git = true 
    103123""")
    104124HGRC.close()         
    105125
    106 try:
    107     index = open(os.path.join(SAGE_ROOT, "devel/sage/doc/output/html/en/reference/index.html"))
    108     if index.read().find("mathjax") != -1:
    109         mathjax = " --mathjax"
    110     else:
    111         mathjax = ""
    112     print ""
    113     print "After cloning, if you change any Sage library files and want to rebuild"
    114     print "the html version of the reference manual, use the command"
    115     print "    sage -docbuild%s reference html" % mathjax
    116     print "(after running 'sage -b')."
    117     print ""
    118     print "Note: if *before* cloning, you have changed any Sage library files"
    119     print "without rebuilding the reference manual, then after cloning, you"
    120     print "will need to touch those files again if you want the changes"
    121     print "to be incorporated into the reference manual."
    122     print ""
    123     print "Updating modification times for the documentation..."
    124     cmd = 'sage -docbuild%s --update-mtimes reference html' % mathjax
    125     print cmd
    126     proc = subprocess.Popen([cmd], shell=True)
    127     if proc.wait():
    128         print ""
    129         print "Warning: Error updating modification times. (The clone will"
    130         print "work fine, but building the reference manual may take longer"
    131         print "than it should.)"
    132         print ""
    133 except IOError:
    134     pass
     126if build_docs:
     127    try:
     128        index = open(os.path.join(SAGE_ROOT, "devel/sage/doc/output/html/en/reference/index.html"))
     129        if index.read().find("mathjax") != -1:
     130            mathjax = " --mathjax"
     131        else:
     132            mathjax = ""
     133        print """
     134After cloning, if you change any Sage library files and want to rebuild
     135the html version of the reference manual, use the command
     136
     137    sage -docbuild%s reference html
     138
     139(after running 'sage -b').
     140
     141Note: if *before* cloning, you have changed any Sage library files
     142without rebuilding the reference manual, then after cloning, you
     143will need to touch those files again if you want the changes
     144to be incorporated into the reference manual.
     145
     146Updating modification times for the documentation...""" % mathjax
     147        cmd = 'sage -docbuild%s --update-mtimes reference html' % mathjax
     148        print cmd
     149        proc = subprocess.Popen([cmd], shell=True)
     150        if proc.wait():
     151            print """
     152Warning: Error updating modification times. (The clone will
     153work fine, but building the reference manual may take longer
     154than it should.)
     155"""
     156    except IOError:
     157        pass
     158else: # don't build documentation
     159        print """
     160If you want to rebuild the html version of the reference manual,
     161use the command
     162
     163    sage -docbuild -j reference html
     164
     165(and if after cloning you have changed any Sage library files, run
     166'sage -b' before executing this command).
     167
     168Note: if *before* cloning, you have changed any Sage library files
     169without rebuilding the reference manual, then after cloning, you
     170will need to touch those files again if you want the changes
     171to be incorporated into the reference manual.
     172"""
    135173
    136174print "*** WARNING ***"
    137175print "If you are cloning a previous revision or have uncommitted changes to"
  • sage-combinat

    diff --git a/sage-combinat b/sage-combinat
    a b elif args[0] == "install": 
    402402    else:
    403403        info("Creating sage-%s branch:"%branch)
    404404        system(sage+" -b main") # This makes sure we are cloning the main branch!!!
    405         system(sage+" -clone %s"%branch)
     405        system(sage+" -clone %s -N"%branch) # "-N" means don't rebuild the documentation
    406406        info("Done")
    407407    assert(os.path.exists(sage_combinat_hg))
    408408    assert(not os.path.exists(sage_combinat_patch_queue))