Comments (12)
Thanks! Looks good. Do you think we should merge the vignette on additional arguments with the available hooks vignette? I think there would be enough space here for one more column.
from precommit.
Actually I think we should not use a table anyways, I just unified two vignettes in #109.
from precommit.
Yes, I think we could do that. We should take as input:
- the precommit config file.
- some other file that describes all other attributes of the hooks, preferably in yaml too (I am not sure if pre-commit allows us to add new fields to the config file).
We could also try to add the information to the .pre-commit-hooks.yaml
file. If it does not produce errors at commit time or while other hooks are running, I think it might even preferred.
I am not sure if we prefer tables. We can also use the R package https://github.com/kiernann/gluedown to generate markdown in R chunks in the vignette and set output = "asis"
(if I remember the Rmarkdown options correctly).
I am open to PRs here.
The same is probably also possible with the argument vignette.
from precommit.
If all current formatting with links etc. is possible in tabular format, you are probably right that this would be better than the current bullets.
from precommit.
Here's what I have at the moment.
info <- yaml::read_yaml("/home/maelle/Documents/ropensci/precommit/.pre-commit-hooks.yaml")
info_df <- data.frame(
id = unlist(
lapply(
info, "[", "id"
)
),
description = unlist(
lapply(
info, "[", "description"
)
)
)
knitr::kable(info_df)
id | description |
---|---|
roxygenize | run roxygen2::roxygenize() |
use-tidy-description | run usethis::use_tidy_description() |
style-files | style files with styler |
no-browser-statement | check if a .R file contains a browser() statement |
parsable-R | check if a .R file is parsable |
readme-rmd-rendered | make sure README.Rmd hasn’t been edited more recently than README.md |
codemeta-description-updated | make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. |
spell-check | perform a spell check with spelling::spell_check_files() |
deps-in-desc | Check if dependencies that can be parsed from code are in DESCRIPTION. |
lintr | check if a .R file is lint free (using lintr) |
Created on 2020-01-08 by the reprex package (v0.3.0)
Are you saying more info could be added to the same YAML? It'd be great because it'd be more transparent than having info about each hook split in two places.
from precommit.
Yes, all info in one place sounds good. Is it possible to use html details tag in a table? If so it'd be a good way to keep the table compact at first glance.
from precommit.
I don't understand the question, sorry.
from precommit.
Look I've added a test below in the first cell. The column with arguments could have details tags so one would click to see arguments. I think the details
package could help.
id | description |
---|---|
argumentsblablabla |
run roxygen2::roxygenize() |
use-tidy-description | run usethis::use_tidy_description() |
style-files | style files with styler |
no-browser-statement | check if a .R file contains a browser() statement |
parsable-R | check if a .R file is parsable |
readme-rmd-rendered | make sure README.Rmd hasn’t been edited more recently than README.md |
codemeta-description-updated | make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. |
spell-check | perform a spell check with spelling::spell_check_files() |
deps-in-desc | Check if dependencies that can be parsed from code are in DESCRIPTION. |
lintr | check if a .R file is lint free (using lintr) |
from precommit.
That's pretty cool. I assume this would also work in the {pkgdown} html page? And can we easily generate the source code of the table programmatically?
from precommit.
I suppose so thanks to details
, but my problem is where the info would live (can you add any field to the YAML without breaking it for precommit purposes)?
from precommit.
We could create a .pre-commit-docs.yaml
and link via id:
- id: roxygenize
- id: use-tidy-description
- id: style-files
args:
- --style_pkg=<package name >, defaulting to styler
- --style_fun=<tidyverse_style>, defaulting to tidyverse_style
- id: no-browser-statement
- id: parsable-R
- id: readme-rmd-rendered
- id: codemeta-description-updated
- id: spell-check
- id: deps-in-desc
- id: lintr
An then do something like this:
library(magrittr)
library(rlang)
#>
#> Attaching package: 'rlang'
#> The following object is masked from 'package:magrittr':
#>
#> set_names
hooks <- yaml::read_yaml("~/git/precommit/.pre-commit-hooks.yaml")
details <- yaml::read_yaml("~/git/precommit/.pre-commit-docs.yaml")
hooks_df <- data.frame(
id = unlist(
lapply(
hooks, "[", "id"
)
),
description = unlist(
lapply(
hooks, "[", "description"
)
)
)
details_df <- purrr::map_dfr(details,
~ tibble::tibble(id = .x$id, args = paste0(" ", .x$args %||% ""))
) %>%
dplyr::group_by(.data$id) %>%
dplyr::summarize(args = paste0(.data$args, collapse = " "))
as_details <- function(args) {
purrr::map_if(
args, args != " ",
~details::details(.x, lang = NULL, output = "character") %>%
gsub("\\n", "", .)
)
}
details_df %>%
dplyr::full_join(hooks_df) %>%
dplyr::mutate(
args = as_details(.data$args),
description = paste0(
.data$description,
args
)
) %>% # View()
dplyr::select(-.data$args) %>%
knitr::kable(format = "markdown")
#> Joining, by = "id"
#> Warning: Column `id` joining character vector and factor, coercing into
#> character vector
id | description |
---|---|
codemeta-description-updated | make sure codemeta.json is in sync with DESCRIPTION |
deps-in-desc | Check if dependencies that can be parsed from code are in DESCRIPTION. |
lintr | check if a .R file is lint free (using lintr) |
no-browser-statement | check if a .R file contains a browser() statement |
parsable-R | check if a .R file is parsable |
readme-rmd-rendered | make sure README.Rmd hasn't been edited more recently than README.md |
roxygenize | run roxygen2::roxygenize() |
spell-check | perform a spell check with spelling::spell_check_files() |
style-files | style files with styler --style_pkg=, defaulting to styler --style_fun=<tidyverse_style>, defaulting to tidyverse_style |
use-tidy-description | run usethis::use_tidy_description() |
Created on 2020-01-15 by the reprex package (v0.3.0) |
from precommit.
Or details in a third column? It looks good in any case!
from precommit.
Related Issues (20)
- precommit environment cannot be set up HOT 26
- CI fails for miniconda on Windows HOT 1
- precommit deps-in-desc hook failing after upgrade to R 4.3.0 in renv locked package HOT 12
- Don't rely on any GitHub Packages due to credential issues
- Update codemeta.json if codemeta-description-updated fails HOT 2
- style_file crashes because of docopt when processing single files with spaces in the path HOT 13
- Package digest not available for package R.cache HOT 15
- Roxygenise Hook using language: system
- Problem installing git2r via pre-commit Github Action HOT 7
- Hook execution got much slower
- detect print statements
- `roxygenize` cannot find Bioconductor pkg dependency when setting environment HOT 8
- Make updating `inst/WORDLIST` optional HOT 1
- Roxygen hook does not work with manually running (and no staging) as well as in CI HOT 1
- Automate GitHub releases
- Submit to ropensci?
- grkstyle transformer styling error HOT 7
- Allow alternative spellcheck dictionary files HOT 9
- xfun-0.40 fails to build under Windows HOT 3
- Use frozen PPM snapshots
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from precommit.