77
77
\\ arguments{{
78
78
{item_text}
79
79
}}
80
+
81
+ \\ value{{{value_text}}}
82
+
80
83
"""
81
84
82
85
description_template = """Package: {package_name}
85
88
Description: {package_description}
86
89
Depends: R (>= 3.0.2){package_depends}
87
90
Imports: {package_imports}
88
- Suggests: {package_suggests}
89
- License: {package_license}
91
+ Suggests: {package_suggests}{package_rauthors}
92
+ License: {package_license}{package_copyright}
90
93
URL: {package_url}
91
94
BugReports: {package_issues}
92
95
Encoding: UTF-8
93
96
LazyData: true{vignette_builder}
94
97
KeepSource: true
95
- Author: {package_author_no_email}
96
- Maintainer: {maintainer}
97
98
"""
98
99
99
100
rbuild_ignore_string = r"""# ignore JS config files/folders
@@ -381,7 +382,12 @@ def write_help_file(name, props, description, prefix, rpkg_data):
381
382
default_argtext = ""
382
383
item_text = ""
383
384
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
+
384
389
prop_keys = list (props .keys ())
390
+ prop_keys_wc = list (props .keys ())
385
391
386
392
# Filter props to remove those we don't want to expose
387
393
for item in prop_keys [:]:
@@ -406,12 +412,12 @@ def write_help_file(name, props, description, prefix, rpkg_data):
406
412
if "**Example Usage**" in description :
407
413
description = description .split ("**Example Usage**" )[0 ].rstrip ()
408
414
409
- if any (key .endswith ("-*" ) for key in prop_keys ):
415
+ if any (key .endswith ("-*" ) for key in prop_keys_wc ):
410
416
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 ))
412
418
413
419
# 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
415
421
# textwrap.fill, starting from the beginning of the usage string
416
422
417
423
file_path = os .path .join ("man" , file_name )
@@ -421,9 +427,10 @@ def write_help_file(name, props, description, prefix, rpkg_data):
421
427
funcname = funcname ,
422
428
name = name ,
423
429
default_argtext = textwrap .fill (
424
- default_argtext , width = 80 , break_long_words = False
430
+ default_argtext , width = 60 , break_long_words = False
425
431
),
426
432
item_text = item_text ,
433
+ value_text = value_text ,
427
434
description = description .replace ("\n " , " " ),
428
435
)
429
436
)
@@ -552,6 +559,8 @@ def generate_rpkg(
552
559
# does not exist in package.json
553
560
554
561
package_name = snake_case_to_camel_case (project_shortname )
562
+ package_copyright = ""
563
+ package_rauthors = ""
555
564
lib_name = pkg_data .get ("name" )
556
565
557
566
if rpkg_data is not None :
@@ -563,22 +572,28 @@ def generate_rpkg(
563
572
package_description = rpkg_data .get (
564
573
"pkg_help_description" , pkg_data .get ("description" , "" )
565
574
)
575
+ if rpkg_data .get ("pkg_copyright" ):
576
+ package_copyright = "\n Copyright: {}" .format (rpkg_data .get (
577
+ "pkg_copyright" , "" ))
566
578
else :
567
579
# fall back to using description in package.json, if present
568
580
package_title = pkg_data .get ("description" , "" )
569
581
package_description = pkg_data .get ("description" , "" )
570
582
571
583
package_version = pkg_data .get ("version" , "0.0.1" )
572
584
573
- # remove leading and trailing commas
585
+ # remove leading and trailing commas, add space after comma if missing
574
586
if package_depends :
575
587
package_depends = ", " + package_depends .strip ("," ).lstrip ()
588
+ package_depends = re .sub (r"(,(?![ ]))" , ", " , package_depends )
576
589
577
590
if package_imports :
578
591
package_imports = package_imports .strip ("," ).lstrip ()
592
+ package_imports = re .sub (r"(,(?![ ]))" , ", " , package_imports )
579
593
580
594
if package_suggests :
581
595
package_suggests = package_suggests .strip ("," ).lstrip ()
596
+ package_suggests = re .sub (r"(,(?![ ]))" , ", " , package_suggests )
582
597
583
598
if "bugs" in pkg_data :
584
599
package_issues = pkg_data ["bugs" ].get ("url" , "" )
@@ -601,20 +616,35 @@ def generate_rpkg(
601
616
602
617
package_author = pkg_data .get ("author" )
603
618
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 ]
605
624
606
625
maintainer = pkg_data .get ("maintainer" , pkg_data .get ("author" ))
607
626
608
- if "<" not in package_author or "<" not in maintainer :
627
+ if "<" not in package_author :
609
628
print (
610
629
"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. " ,
614
633
file = sys .stderr ,
615
634
)
616
635
sys .exit (1 )
617
636
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
+
618
648
if not (os .path .isfile ("LICENSE" ) or os .path .isfile ("LICENSE.txt" )):
619
649
package_license = pkg_data .get ("license" , "" )
620
650
else :
@@ -636,7 +666,8 @@ def generate_rpkg(
636
666
if os .path .exists ("vignettes" ):
637
667
vignette_builder = "\n VignetteBuilder: knitr"
638
668
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 (", " )
640
671
else :
641
672
vignette_builder = ""
642
673
@@ -660,16 +691,15 @@ def generate_rpkg(
660
691
package_title = package_title ,
661
692
package_description = package_description ,
662
693
package_version = package_version ,
663
- package_author = package_author ,
694
+ package_rauthors = package_rauthors ,
664
695
package_depends = package_depends ,
665
696
package_imports = package_imports ,
666
697
package_suggests = package_suggests ,
667
698
package_license = package_license ,
699
+ package_copyright = package_copyright ,
668
700
package_url = package_url ,
669
701
package_issues = package_issues ,
670
702
vignette_builder = vignette_builder ,
671
- package_author_no_email = package_author_no_email ,
672
- maintainer = maintainer ,
673
703
)
674
704
675
705
with open ("DESCRIPTION" , "w+" ) as f3 :
0 commit comments