7777\\ arguments{{
7878{item_text}
7979}}
80+
81+ \\ value{{{value_text}}}
82+
8083"""
8184
8285description_template = """Package: {package_name}
8588Description: {package_description}
8689Depends: R (>= 3.0.2){package_depends}
8790Imports: {package_imports}
88- Suggests: {package_suggests}
89- License: {package_license}
91+ Suggests: {package_suggests}{package_rauthors}
92+ License: {package_license}{package_copyright}
9093URL: {package_url}
9194BugReports: {package_issues}
9295Encoding: UTF-8
9396LazyData: true{vignette_builder}
9497KeepSource: true
95- Author: {package_author_no_email}
96- Maintainer: {maintainer}
9798"""
9899
99100rbuild_ignore_string = r"""# ignore JS config files/folders
@@ -381,7 +382,12 @@ def write_help_file(name, props, description, prefix, rpkg_data):
381382 default_argtext = ""
382383 item_text = ""
383384
385+ # the return value of all Dash components should be the same,
386+ # in an abstract sense -- they produce a list
387+ value_text = "named list of JSON elements corresponding to React.js properties and their values" # noqa:E501
388+
384389 prop_keys = list (props .keys ())
390+ prop_keys_wc = list (props .keys ())
385391
386392 # Filter props to remove those we don't want to expose
387393 for item in prop_keys [:]:
@@ -406,12 +412,12 @@ def write_help_file(name, props, description, prefix, rpkg_data):
406412 if "**Example Usage**" in description :
407413 description = description .split ("**Example Usage**" )[0 ].rstrip ()
408414
409- if any (key .endswith ("-*" ) for key in prop_keys ):
415+ if any (key .endswith ("-*" ) for key in prop_keys_wc ):
410416 default_argtext += ", ..."
411- item_text += wildcard_help_template .format (get_wildcards_r (prop_keys ))
417+ item_text += wildcard_help_template .format (get_wildcards_r (prop_keys_wc ))
412418
413419 # in R, the online help viewer does not properly wrap lines for
414- # the usage string -- we will hard wrap at 80 characters using
420+ # the usage string -- we will hard wrap at 60 characters using
415421 # textwrap.fill, starting from the beginning of the usage string
416422
417423 file_path = os .path .join ("man" , file_name )
@@ -421,9 +427,10 @@ def write_help_file(name, props, description, prefix, rpkg_data):
421427 funcname = funcname ,
422428 name = name ,
423429 default_argtext = textwrap .fill (
424- default_argtext , width = 80 , break_long_words = False
430+ default_argtext , width = 60 , break_long_words = False
425431 ),
426432 item_text = item_text ,
433+ value_text = value_text ,
427434 description = description .replace ("\n " , " " ),
428435 )
429436 )
@@ -552,6 +559,8 @@ def generate_rpkg(
552559 # does not exist in package.json
553560
554561 package_name = snake_case_to_camel_case (project_shortname )
562+ package_copyright = ""
563+ package_rauthors = ""
555564 lib_name = pkg_data .get ("name" )
556565
557566 if rpkg_data is not None :
@@ -563,22 +572,28 @@ def generate_rpkg(
563572 package_description = rpkg_data .get (
564573 "pkg_help_description" , pkg_data .get ("description" , "" )
565574 )
575+ if rpkg_data .get ("pkg_copyright" ):
576+ package_copyright = "\n Copyright: {}" .format (rpkg_data .get (
577+ "pkg_copyright" , "" ))
566578 else :
567579 # fall back to using description in package.json, if present
568580 package_title = pkg_data .get ("description" , "" )
569581 package_description = pkg_data .get ("description" , "" )
570582
571583 package_version = pkg_data .get ("version" , "0.0.1" )
572584
573- # remove leading and trailing commas
585+ # remove leading and trailing commas, add space after comma if missing
574586 if package_depends :
575587 package_depends = ", " + package_depends .strip ("," ).lstrip ()
588+ package_depends = re .sub (r"(,(?![ ]))" , ", " , package_depends )
576589
577590 if package_imports :
578591 package_imports = package_imports .strip ("," ).lstrip ()
592+ package_imports = re .sub (r"(,(?![ ]))" , ", " , package_imports )
579593
580594 if package_suggests :
581595 package_suggests = package_suggests .strip ("," ).lstrip ()
596+ package_suggests = re .sub (r"(,(?![ ]))" , ", " , package_suggests )
582597
583598 if "bugs" in pkg_data :
584599 package_issues = pkg_data ["bugs" ].get ("url" , "" )
@@ -601,20 +616,35 @@ def generate_rpkg(
601616
602617 package_author = pkg_data .get ("author" )
603618
604- package_author_no_email = package_author .split (" <" )[0 ] + " [aut]"
619+ package_author_name = package_author .split (" <" )[0 ]
620+ package_author_email = package_author .split (" <" )[1 ][:- 1 ]
621+
622+ package_author_fn = package_author_name .split (" " )[0 ]
623+ package_author_ln = package_author_name .rsplit (" " , 2 )[- 1 ]
605624
606625 maintainer = pkg_data .get ("maintainer" , pkg_data .get ("author" ))
607626
608- if "<" not in package_author or "<" not in maintainer :
627+ if "<" not in package_author :
609628 print (
610629 "Error, aborting R package generation: "
611- "R packages require a properly formatted author or "
612- "maintainer field or installation will fail. Please include "
613- "an email address enclosed within < > brackets in package.json. " ,
630+ "R packages require a properly formatted author field "
631+ "or installation will fail. Please include an email "
632+ "address enclosed within < > brackets in package.json. " ,
614633 file = sys .stderr ,
615634 )
616635 sys .exit (1 )
617636
637+ if rpkg_data is not None :
638+ if rpkg_data .get ("pkg_authors" ):
639+ package_rauthors = '\n Authors@R: {}' .format (rpkg_data .get (
640+ "pkg_authors" , "" ))
641+ else :
642+ package_rauthors = '\n Authors@R: person("{}", "{}", role = c("aut", "cre"), email = "{}")' .format (
643+ package_author_fn ,
644+ package_author_ln ,
645+ package_author_email
646+ )
647+
618648 if not (os .path .isfile ("LICENSE" ) or os .path .isfile ("LICENSE.txt" )):
619649 package_license = pkg_data .get ("license" , "" )
620650 else :
@@ -636,7 +666,8 @@ def generate_rpkg(
636666 if os .path .exists ("vignettes" ):
637667 vignette_builder = "\n VignetteBuilder: knitr"
638668 if "knitr" not in package_suggests and "rmarkdown" not in package_suggests :
639- package_suggests += ", knitr, rmarkdown" .lstrip (", " )
669+ package_suggests += ", knitr, rmarkdown"
670+ package_suggests = package_suggests .lstrip (", " )
640671 else :
641672 vignette_builder = ""
642673
@@ -660,16 +691,15 @@ def generate_rpkg(
660691 package_title = package_title ,
661692 package_description = package_description ,
662693 package_version = package_version ,
663- package_author = package_author ,
694+ package_rauthors = package_rauthors ,
664695 package_depends = package_depends ,
665696 package_imports = package_imports ,
666697 package_suggests = package_suggests ,
667698 package_license = package_license ,
699+ package_copyright = package_copyright ,
668700 package_url = package_url ,
669701 package_issues = package_issues ,
670702 vignette_builder = vignette_builder ,
671- package_author_no_email = package_author_no_email ,
672- maintainer = maintainer ,
673703 )
674704
675705 with open ("DESCRIPTION" , "w+" ) as f3 :
0 commit comments