@@ -356,9 +356,12 @@ def addcourse(
356356)
357357@click .option ("--clone" , default = None , help = "clone the given repo before building" )
358358@click .option ("--ptx" , is_flag = True , help = "Build a PreTeXt book" )
359+ @click .option (
360+ "--gen" , is_flag = True , help = "Build PreTeXt generated assets (a one time thing)"
361+ )
359362@click .option ("--manifest" , default = "runestone-manifest.xml" , help = "Manifest file" )
360363@pass_config
361- def build (config , course , clone , ptx , manifest ):
364+ def build (config , course , clone , ptx , gen , manifest ):
362365 """Build the book for an existing course"""
363366 os .chdir (findProjectRoot ()) # change to a known location
364367 eng = create_engine (config .dburl )
@@ -400,6 +403,10 @@ def build(config, course, clone, ptx, manifest):
400403 ElementInclude .include (
401404 root , base_url = main_file
402405 ) # include all xi:include parts
406+ if gen :
407+ res = subprocess .call ("pretext generate web" )
408+ if res != 0 :
409+ click .echo ("Failed to build" )
403410 # build the book
404411 res = subprocess .call ("pretext build runestone" , shell = True )
405412 if res != 0 :
@@ -438,7 +445,7 @@ def build(config, course, clone, ptx, manifest):
438445 try :
439446 if os .path .exists ("pavement.py" ):
440447 sys .path .insert (0 , os .getcwd ())
441- from pavement import options , dest
448+ from pavement import options , dest , project_name
442449 else :
443450 click .echo (
444451 "I can't find a pavement.py file in {} you need that to build" .format (
@@ -451,7 +458,7 @@ def build(config, course, clone, ptx, manifest):
451458 print (e )
452459 exit (1 )
453460
454- if options . project_name != course :
461+ if project_name != course :
455462 click .echo (
456463 "Error: {} and {} do not match. Your course name needs to match the project_name in pavement.py" .format (
457464 course , project_name
@@ -501,8 +508,12 @@ def check_project_ptx():
501508 sys .exit (1 )
502509
503510
504- def extract_docinfo (tree , string ):
511+ def extract_docinfo (tree , string , attr = None ):
505512 el = tree .find (f"./{ string } " )
513+ if attr is not None and el is not None :
514+ print (f"{ el .attrib [attr ]= } " )
515+ return el .attrib [attr ].strip ()
516+
506517 if el is not None :
507518 # using method="text" will strip the outer tag as well as any html tags in the value
508519 return ET .tostring (el , encoding = "unicode" , method = "text" ).strip ()
@@ -515,7 +526,7 @@ def update_library(config: Config, mpath, course):
515526 eng = create_engine (config .dburl )
516527 title = extract_docinfo (docinfo , "title" )
517528 subtitle = extract_docinfo (docinfo , "subtitle" )
518- description = extract_docinfo (docinfo , "description " )
529+ description = extract_docinfo (docinfo , "blurb " )
519530 shelf = extract_docinfo (docinfo , "shelf" )
520531 click .echo (f"{ title } : { subtitle } " )
521532 res = eng .execute (f"select * from library where basecourse = '{ course } '" )
@@ -531,7 +542,7 @@ def update_library(config: Config, mpath, course):
531542 title = '{ title } ',
532543 subtitle = '{ subtitle } ',
533544 description = '{ description } ',
534- shelf_section = '{ shelf } '
545+ shelf = '{ shelf } '
535546 where basecourse = '{ course } '
536547 """
537548 )
0 commit comments