Skip to content

Commit

Permalink
Merge branch 'collapse-args' of https://github.com/etiennebacher/altdoc
Browse files Browse the repository at this point in the history
… into collapse-args
  • Loading branch information
etiennebacher committed Feb 26, 2025
2 parents 9f073e4 + 19980c4 commit 7aa7c63
Show file tree
Hide file tree
Showing 79 changed files with 2,487 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
^.lintr$
man-roxygen
^inst/NEWS\.Rd$


# flir files
^flir$
5 changes: 5 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:

name: R-CMD-check

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true


jobs:
R-CMD-check:
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/altdoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:

name: altdoc

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
altdoc:
runs-on: ubuntu-latest
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/flir.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: flir

jobs:
flir:
runs-on: macOS-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: flir-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2

- name: Install flir
run: install.packages("flir", repos = c("https://etiennebacher.r-universe.dev/", getOption("repos")))
shell: Rscript {0}

- name: Run flir
run: flir::lint()
shell: Rscript {0}
env:
FLIR_ERROR_ON_LINT: true
4 changes: 4 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:

name: test-coverage

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
test-coverage:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: altdoc
Title: Package Documentation Websites with 'Quarto', 'Docsify', 'Docute', or 'MkDocs'
Version: 0.5.0
Version: 0.5.0.9000
Authors@R:
c(person(given = "Etienne",
family = "Bacher",
Expand Down
1 change: 1 addition & 0 deletions R/import_man.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
close(connection)
},
warning = function(w) {
# flir-ignore
is_404 <<- grepl("404", w)
}
)
Expand Down
1 change: 0 additions & 1 deletion R/import_readme.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
enc2utf8("{{< include README.md >}}"),
fs::path_join(c(tar_dir, "index.md"))
)
fs::file_copy(fs::path_join(c(src_dir, "README.md")), tar_dir)
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/render_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ render_docs <- function(
# Delete everything in `_quarto/` besides `_freeze/`
if (fs::dir_exists(docs_dir)) {
docs_files <- fs::dir_ls(docs_dir)
if (freeze == TRUE) {
if (isTRUE(freeze)) {
docs_files <- Filter(
function(f) basename(f) != "_freeze",
docs_files
Expand Down
4 changes: 2 additions & 2 deletions R/settings_docute.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

if (length(fn_vignettes) > 0) {
tmp <- sprintf("{title: '%s', link: '%s'}", titles, fn_vignettes)
tmp <- paste(tmp, collapse = ", ")
tmp <- toString(tmp)
sidebar <- paste(sidebar, collapse = "\n")
if (isTRUE(grepl("\\$ALTDOC_VIGNETTE_BLOCK", sidebar))) {
sidebar <- gsub("\\$ALTDOC_VIGNETTE_BLOCK", "%s", sidebar)
Expand All @@ -86,7 +86,7 @@
)
titles <- fs::path_ext_remove(basename(fn_man))
tmp <- sprintf("{title: '%s', link: '%s'}", titles, fn_man)
tmp <- paste(tmp, collapse = ", ")
tmp <- toString(tmp)
sidebar <- paste(sidebar, collapse = "\n")
if (isTRUE(grepl("\\$ALTDOC_MAN_BLOCK", sidebar))) {
sidebar <- gsub("\\$ALTDOC_MAN_BLOCK", "%s", sidebar)
Expand Down
3 changes: 1 addition & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
)

if (length(.gh_urls) == 0) {
return("")
return(NULL)
}

.gh_url <- .gh_urls[grep("github.com", .gh_urls)]
Expand All @@ -58,7 +58,6 @@
.gh_url <- gsub("#.*", "", .gh_url)
.gh_url <- unique(.gh_url)

if (length(.gh_url) == 0) .gh_url <- ""
return(.gh_url)
}

Expand Down
Binary file added flir/cache_file_state.rds
Binary file not shown.
53 changes: 53 additions & 0 deletions flir/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
keep:
- any_duplicated
- any_is_na
- class_equals
- condition_message
- double_assignment
- duplicate_argument
- empty_assignment
- equal_assignment
- equals_na
- expect_comparison
- expect_identical
- expect_length
- expect_named
- expect_not
- expect_null
- expect_true_false
- expect_type
- for_loop_index
- function_return
- implicit_assignment
- is_numeric
- length_levels
- length_test
- lengths
- library_call
- list_comparison
- literal_coercion
- matrix_apply
- missing_argument
- nested_ifelse
- numeric_leading_zero
- outer_negation
- package_hooks
- paste
- redundant_equals
- redundant_ifelse
- rep_len
- right_assignment
- sample_int
- semicolon
- seq
- sort
- stopifnot_all
- T_and_F_symbol
- undesirable_function
- undesirable_operator
- unnecessary_nesting
- which_grepl

exclude:
- todo_comment
- unreachable_code
97 changes: 97 additions & 0 deletions flir/rules/builtin/T_and_F_symbol.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
id: true_false_symbol
language: r
severity: warning
rule:
pattern: T
kind: identifier
not:
any:
- precedes:
any:
- pattern: <-
- pattern: =
- regex: ^~$
- follows:
any:
- pattern: $
- regex: ^~$
- inside:
any:
- kind: parameter
- kind: call
- kind: binary_operator
follows:
regex: ^~$
stopBy: end
stopBy:
kind:
argument
fix: TRUE
message: Use TRUE instead of the symbol T.

---

id: true_false_symbol-2
language: r
severity: warning
rule:
pattern: F
kind: identifier
not:
any:
- precedes:
any:
- pattern: <-
- pattern: =
- regex: ^~$
- follows:
any:
- pattern: $
- regex: ^~$
- inside:
any:
- kind: parameter
- kind: call
- kind: binary_operator
follows:
regex: ^~$
stopBy: end
stopBy:
kind:
argument
fix: FALSE
message: Use FALSE instead of the symbol F.

---

id: true_false_symbol-3
language: r
severity: warning
rule:
pattern: T
kind: identifier
precedes:
any:
- pattern: <-
- pattern: =
not:
inside:
kind: argument
message: Don't use T as a variable name, as it can break code relying on T being TRUE.

---

id: true_false_symbol-4
language: r
severity: warning
rule:
pattern: F
kind: identifier
precedes:
any:
- pattern: <-
- pattern: =
not:
inside:
kind: argument
message: Don't use F as a variable name, as it can break code relying on F being FALSE.
13 changes: 13 additions & 0 deletions flir/rules/builtin/absolute_path.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# id: absolute_path-1
# language: r
# severity: warning
# rule:
# kind: string_content
# any:
# - regex: '^~[[:alpha:]]'
# - regex: '^~/[[:alpha:]]'
# - regex: '^[[:alpha:]]:'
# - regex: '^(/|~)$'
# - regex: '^/[[:alpha:]]'
# - regex: '^\\'
# message: Do not use absolute paths.
Loading

0 comments on commit 7aa7c63

Please sign in to comment.