How to generate a reference for all non-exported functions with pkgdown?

pkgdown
#1

Besides the normal reference list of exported functions generated by pkgdown, how could I create another tab in my website with all remaining functions that are not exported? I am thinking this could be helpful for candidate contributors...

0 Likes

#2

I don't think this is feature already included in pkgdown. Also, non-exported functions are most often not documented, so no help page. The reference page would just be a list of non exported function ?

If so, you could with current version built an article showing all the non exported functions in your package
Here is an example on how to get all names of non exported functions

# load the package you want to extract function from
package_to_analyze <- "pkgdown"
library(package_to_analyze, character.only = T)
# get only exported function using the loaded package env name
exported_funs <- unclass(lsf.str(paste0("package:", package_to_analyze), all.names = TRUE))
# get all functions inside the package using asNamespace
all_funs <- unclass(lsf.str(envir = asNamespace(package_to_analyze), all.names = T))
# get only non exported funs
setdiff(all_funs, exported_funs)
#>   [1] "[.tag"                            
#>   [2] "a"                                
#>   [3] "add_github_links"                 
#>   [4] "add_slug"                         
#>   [5] "all_sign"                         
#>   [6] "article_index"                    
#>   [7] "article_index_local"              
#>   [8] "article_index_remote"             
#>   [9] "as_data"                          
#>  [10] "as_data.NULL"                     
#>  [11] "as_data.tag_arguments"            
#>  [12] "as_data.tag_description"          
#>  [13] "as_data.tag_details"              
#>  [14] "as_data.tag_examples"             
#>  [15] "as_data.tag_format"               
#>  [16] "as_data.tag_item"                 
#>  [17] "as_data.tag_note"                 
#>  [18] "as_data.tag_references"           
#>  [19] "as_data.tag_section"              
#>  [20] "as_data.tag_seealso"              
#>  [21] "as_data.tag_source"               
#>  [22] "as_data.tag_usage"                
#>  [23] "as_data.tag_value"                
#>  [24] "as_html"                          
#>  [25] "as_html.character"                
#>  [26] "as_html.COMMENT"                  
#>  [27] "as_html.LIST"                     
#>  [28] "as_html.NULL"                     
#>  [29] "as_html.RCODE"                    
#>  [30] "as_html.Rd"                       
#>  [31] "as_html.tag"                      
#>  [32] "as_html.tag_acronym"              
#>  [33] "as_html.tag_bold"                 
#>  [34] "as_html.tag_cite"                 
#>  [35] "as_html.tag_code"                 
#>  [36] "as_html.tag_command"              
#>  [37] "as_html.tag_concept"              
#>  [38] "as_html.tag_cr"                   
#>  [39] "as_html.tag_deqn"                 
#>  [40] "as_html.tag_describe"             
#>  [41] "as_html.tag_dfn"                  
#>  [42] "as_html.tag_dontrun"              
#>  [43] "as_html.tag_dontshow"             
#>  [44] "as_html.tag_donttest"             
#>  [45] "as_html.tag_dots"                 
#>  [46] "as_html.tag_dQuote"               
#>  [47] "as_html.tag_email"                
#>  [48] "as_html.tag_emph"                 
#>  [49] "as_html.tag_enc"                  
#>  [50] "as_html.tag_enumerate"            
#>  [51] "as_html.tag_env"                  
#>  [52] "as_html.tag_eqn"                  
#>  [53] "as_html.tag_figure"               
#>  [54] "as_html.tag_file"                 
#>  [55] "as_html.tag_href"                 
#>  [56] "as_html.tag_if"                   
#>  [57] "as_html.tag_ifelse"               
#>  [58] "as_html.tag_item"                 
#>  [59] "as_html.tag_itemize"              
#>  [60] "as_html.tag_kbd"                  
#>  [61] "as_html.tag_ldots"                
#>  [62] "as_html.tag_link"                 
#>  [63] "as_html.tag_linkS4class"          
#>  [64] "as_html.tag_method"               
#>  [65] "as_html.tag_newcommand"           
#>  [66] "as_html.tag_option"               
#>  [67] "as_html.tag_out"                  
#>  [68] "as_html.tag_pkg"                  
#>  [69] "as_html.tag_preformatted"         
#>  [70] "as_html.tag_R"                    
#>  [71] "as_html.tag_renewcommand"         
#>  [72] "as_html.tag_S3method"             
#>  [73] "as_html.tag_S4method"             
#>  [74] "as_html.tag_samp"                 
#>  [75] "as_html.tag_Sexpr"                
#>  [76] "as_html.tag_sQuote"               
#>  [77] "as_html.tag_strong"               
#>  [78] "as_html.tag_subsection"           
#>  [79] "as_html.tag_tab"                  
#>  [80] "as_html.tag_tabular"              
#>  [81] "as_html.tag_testonly"             
#>  [82] "as_html.tag_url"                  
#>  [83] "as_html.tag_var"                  
#>  [84] "as_html.tag_verb"                 
#>  [85] "as_html.TEXT"                     
#>  [86] "as_html.USERMACRO"                
#>  [87] "as_html.VERB"                     
#>  [88] "author_desc"                      
#>  [89] "author_list"                      
#>  [90] "author_name"                      
#>  [91] "autolink_license"                 
#>  [92] "badges_extract"                   
#>  [93] "badges_extract_text"              
#>  [94] "bib_paths"                        
#>  [95] "bst_paths"                        
#>  [96] "build_articles_index"             
#>  [97] "build_authors"                    
#>  [98] "build_citation_authors"           
#>  [99] "build_cname"                      
#> [100] "build_docsearch_json"             
#> [101] "build_home_index"                 
#> [102] "build_home_license"               
#> [103] "build_home_md"                    
#> [104] "build_logo"                       
#> [105] "build_news_multi"                 
#> [106] "build_news_single"                
#> [107] "build_reference_topic"            
#> [108] "build_rmarkdown_format"           
#> [109] "build_site_external"              
#> [110] "build_site_local"                 
#> [111] "build_site_meta"                  
#> [112] "build_sitemap"                    
#> [113] "cat_line"                         
#> [114] "check_made_by"                    
#> [115] "cname_url"                        
#> [116] "construct_commit_message"         
#> [117] "context_get"                      
#> [118] "context_set"                      
#> [119] "context_set_scoped"               
#> [120] "copy_asset_dir"                   
#> [121] "copy_assets"                      
#> [122] "copy_favicons"                    
#> [123] "create_meta"                      
#> [124] "data_articles_index"              
#> [125] "data_articles_index_section"      
#> [126] "data_author_info"                 
#> [127] "data_authors"                     
#> [128] "data_citations"                   
#> [129] "data_home"                        
#> [130] "data_home_sidebar"                
#> [131] "data_home_sidebar_authors"        
#> [132] "data_home_sidebar_citation"       
#> [133] "data_home_sidebar_license"        
#> [134] "data_home_sidebar_links"          
#> [135] "data_navbar"                      
#> [136] "data_news"                        
#> [137] "data_open_graph"                  
#> [138] "data_reference_index"             
#> [139] "data_reference_index_section"     
#> [140] "data_reference_topic"             
#> [141] "default_articles_index"           
#> [142] "default_reference_index"          
#> [143] "defer"                            
#> [144] "deploy_local"                     
#> [145] "dev_mode"                         
#> [146] "devtools_loaded"                  
#> [147] "devtools_meta"                    
#> [148] "digest_plot"                      
#> [149] "dir_copy_to"                      
#> [150] "dir_depth"                        
#> [151] "dont_index"                       
#> [152] "drop_leading_newline"             
#> [153] "dst_path"                         
#> [154] "escape_html"                      
#> [155] "extract_package_attach"           
#> [156] "extract_package_attach_"          
#> [157] "extract_source"                   
#> [158] "extract_tag"                      
#> [159] "extract_title"                    
#> [160] "fetch_yaml"                       
#> [161] "fig_name"                         
#> [162] "fig_opts_chunk"                   
#> [163] "fig_save"                         
#> [164] "fig_save_default"                 
#> [165] "file_copy_to"                     
#> [166] "file_digest"                      
#> [167] "file_equal"                       
#> [168] "find_article"                     
#> [169] "find_icon"                        
#> [170] "find_icons"                       
#> [171] "find_logo"                        
#> [172] "find_qualifier"                   
#> [173] "find_rdname"                      
#> [174] "find_rdname_attached"             
#> [175] "find_rdname_local"                
#> [176] "find_reexport_source"             
#> [177] "find_reexport_source_from_imports"
#> [178] "find_template"                    
#> [179] "find_tutorials"                   
#> [180] "flatten_para"                     
#> [181] "flatten_text"                     
#> [182] "format_author_name"               
#> [183] "format_example_chunk"             
#> [184] "fun_info"                         
#> [185] "fun_name"                         
#> [186] "git"                              
#> [187] "github_clone"                     
#> [188] "github_push"                      
#> [189] "github_source"                    
#> [190] "github_source_links"              
#> [191] "github_url_rx"                    
#> [192] "has_citation"                     
#> [193] "has_favicons"                     
#> [194] "has_internet"                     
#> [195] "has_news"                         
#> [196] "highlight_text"                   
#> [197] "href_article"                     
#> [198] "href_expr"                        
#> [199] "href_expr_"                       
#> [200] "href_string"                      
#> [201] "href_tokens"                      
#> [202] "href_topic"                       
#> [203] "href_topic_local"                 
#> [204] "href_topic_remote"                
#> [205] "invert_index"                     
#> [206] "is_dev"                           
#> [207] "is_infix"                         
#> [208] "is_internal"                      
#> [209] "is_low_change"                    
#> [210] "is_newline"                       
#> [211] "is_non_pkgdown_site"              
#> [212] "is_pkgdown"                       
#> [213] "is_prefix"                        
#> [214] "is_syntactic"                     
#> [215] "is_testing"                       
#> [216] "label_lines"                      
#> [217] "label_output"                     
#> [218] "licenses_db"                      
#> [219] "link_url"                         
#> [220] "linkify"                          
#> [221] "made_by_pkgdown"                  
#> [222] "make_slug"                        
#> [223] "markdown"                         
#> [224] "markdown_text"                    
#> [225] "match_env"                        
#> [226] "match_eval"                       
#> [227] "match_fun"                        
#> [228] "menu"                             
#> [229] "menu_icon"                        
#> [230] "menu_link"                        
#> [231] "menu_links"                       
#> [232] "menu_spacer"                      
#> [233] "menu_text"                        
#> [234] "merge_low_plot"                   
#> [235] "meta_development"                 
#> [236] "meta_figures"                     
#> [237] "method_usage"                     
#> [238] "navbar_components"                
#> [239] "navbar_news"                      
#> [240] "navbar_structure"                 
#> [241] "orcid_link"                       
#> [242] "out_of_date"                      
#> [243] "package_rd"                       
#> [244] "package_topics"                   
#> [245] "package_tutorials"                
#> [246] "package_vignettes"                
#> [247] "parse_descriptions"               
#> [248] "parse_github_link"                
#> [249] "parse_items"                      
#> [250] "parse_opts"                       
#> [251] "parse_section"                    
#> [252] "parse_usage"                      
#> [253] "path_abs"                         
#> [254] "path_first_existing"              
#> [255] "path_package_pkgdown"             
#> [256] "path_pkgdown"                     
#> [257] "pkg_authors"                      
#> [258] "pkg_github_url"                   
#> [259] "pkg_timeline"                     
#> [260] "pkgdown_detective"                
#> [261] "pkgdown_renderer"                 
#> [262] "prepend_class"                    
#> [263] "print.print_yaml"                 
#> [264] "print.Rd"                         
#> [265] "print.tag"                        
#> [266] "print_yaml"                       
#> [267] "rd_file"                          
#> [268] "rd_text"                          
#> [269] "read_citation"                    
#> [270] "read_desc"                        
#> [271] "read_file"                        
#> [272] "read_lines"                       
#> [273] "read_meta"                        
#> [274] "readLines"                        
#> [275] "register_attached_packages"       
#> [276] "remote_metadata"                  
#> [277] "remote_package_article_url"       
#> [278] "remote_package_reference_url"     
#> [279] "remote_urls"                      
#> [280] "remove_name"                      
#> [281] "render_index"                     
#> [282] "render_md"                        
#> [283] "render_navbar_links"              
#> [284] "render_rmarkdown"                 
#> [285] "render_template"                  
#> [286] "replay_html"                      
#> [287] "replay_html.character"            
#> [288] "replay_html.error"                
#> [289] "replay_html.list"                 
#> [290] "replay_html.message"              
#> [291] "replay_html.NULL"                 
#> [292] "replay_html.recordedplot"         
#> [293] "replay_html.source"               
#> [294] "replay_html.value"                
#> [295] "replay_html.warning"              
#> [296] "repo_link"                        
#> [297] "rmarkdown_template"               
#> [298] "rstudio_save_all"                 
#> [299] "rule"                             
#> [300] "same_contents"                    
#> [301] "scoped_file_context"              
#> [302] "scoped_in_pkgdown"                
#> [303] "scoped_package_context"           
#> [304] "section_init"                     
#> [305] "select_topics"                    
#> [306] "select_vignettes"                 
#> [307] "set_class"                        
#> [308] "set_classes"                      
#> [309] "set_contains"                     
#> [310] "set_pkgdown_env"                  
#> [311] "short_name"                       
#> [312] "sidebar_section"                  
#> [313] "skip_if_no_pandoc"                
#> [314] "split_at_linebreaks"              
#> [315] "src_path"                         
#> [316] "stop_bad_tag"                     
#> [317] "str_person"                       
#> [318] "str_trim"                         
#> [319] "strip_html_tags"                  
#> [320] "tag"                              
#> [321] "tag_insert"                       
#> [322] "tag_wrapper"                      
#> [323] "template_path"                    
#> [324] "tex_paths"                        
#> [325] "topic_funs"                       
#> [326] "topic_index"                      
#> [327] "topic_index_installed"            
#> [328] "topic_index_local"                
#> [329] "topic_must"                       
#> [330] "trim_ws_nodes"                    
#> [331] "tutorial_info"                    
#> [332] "tweak_anchors"                    
#> [333] "tweak_code"                       
#> [334] "tweak_code_nodeset"               
#> [335] "tweak_homepage_html"              
#> [336] "tweak_md_links"                   
#> [337] "tweak_news_heading"               
#> [338] "tweak_pre_node"                   
#> [339] "tweak_rmarkdown_html"             
#> [340] "tweak_tables"                     
#> [341] "up_path"                          
#> [342] "update_html"                      
#> [343] "url_node"                         
#> [344] "usage_code"                       
#> [345] "usage_code.COMMENT"               
#> [346] "usage_code.NULL"                  
#> [347] "usage_code.RCODE"                 
#> [348] "usage_code.Rd"                    
#> [349] "usage_code.tag"                   
#> [350] "usage_code.tag_dots"              
#> [351] "usage_code.tag_method"            
#> [352] "usage_code.tag_S3method"          
#> [353] "usage_code.tag_S4method"          
#> [354] "usage_code.tag_usage"             
#> [355] "usage_code.TEXT"                  
#> [356] "usage_code.VERB"                  
#> [357] "usage_type"                       
#> [358] "with_device"                      
#> [359] "with_dir"                         
#> [360] "write_if_different"               
#> [361] "write_lines"                      
#> [362] "write_yaml"                       
#> [363] "writeLines"                       
#> [364] "yaml_list"
detach(paste0("package:", package_to_analyze), character.only = TRUE)

Created on 2019-04-20 by the reprex package (v0.2.1.9000)

You can then continue filtering to not keep method for example, and work on how to build a web page to present those results (using rmarkdown, html, ...

It is just to give ideas.

0 Likes

#3

Thanks! I'll give that a try!

0 Likes

closed #4

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes