Skip to contents

A validator based on the pegboard::Lesson class cached with this_lesson() that will provide line reports for fenced divs, links, images, and heading structure. For details on the type of validators avaliable, see the pegboard article Validation of Lesson Elements

Usage

validate_lesson(path = ".", headings = FALSE, quiet = FALSE)

Arguments

path

the path to the lesson. Defaults ot the current directory

headings

If TRUE, headings will be checked and validated. Currently set to FALSE as we are re-investigating some false positives.

quiet

if TRUE, no messages will be issued, otherwise progress messages will be issued for each test

Value

a list with the results for each test as described in pegboard::Lesson

Details

Headings

We expect the headings to be semantic and informative. Details of the tests for headings can be found at pegboard::validate_headings()

Internal links and images should exist and images should have alt text. Details for these tests can be found at pegboard::validate_links()

Fenced Divs (callout blocks)

Callout Blocks should be one of the expected types. Details for this test can be found at pegboard::validate_divs()

Examples

tmp <- tempfile()
lsn <- create_lesson(tmp, open = FALSE)
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...
#>  No schedule set, using Rmd files in episodes/ directory.
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...

#> To remove this message, define your schedule in config.yaml or use `set_episodes()` to generate it.
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...

#> ────────────────────────────────────────────────────────────────────────
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...

#>  To save this configuration, use
#> 
#> set_episodes(path = path, order = ep, write = TRUE)
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...

#>  First episode created in /tmp/RtmpP9eYUD/file19326f152317/episodes/introduction.Rmd
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...

#>  Workflows up-to-date!
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...

#>  Consent to use package cache provided
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...

#> - The project is out-of-sync -- use `renv::status()` for details.
#> → Searching for and installing available dependencies
#> The following packages were discovered:
#> 
#> # ~/work/_temp/Library -------------------------------------------------------
#> - R6            2.5.1
#> - base64enc     0.1-3
#> - bslib         0.7.0
#> - cachem        1.1.0
#> - cli           3.6.3
#> - digest        0.6.36
#> - evaluate      0.24.0
#> - fastmap       1.2.0
#> - fontawesome   0.5.2
#> - fs            1.6.4
#> - glue          1.7.0
#> - highr         0.11
#> - htmltools     0.5.8.1
#> - jquerylib     0.1.4
#> - jsonlite      1.8.8
#> - knitr         1.48
#> - lifecycle     1.0.4
#> - memoise       2.0.1
#> - mime          0.12
#> - rappdirs      0.3.3
#> - rlang         1.1.4
#> - rmarkdown     2.27
#> - sass          0.4.9
#> - tinytex       0.52
#> - xfun          0.46
#> - yaml          2.3.10
#> 
#> They will be copied into the project library.
#> 
#> - Copying packages into the project library ... Done!
#> - Hydrated 26 packages in 0.21 seconds.
#> - Resolving missing dependencies ... 
#> # Installing packages --------------------------------------------------------
#> - The project is out-of-sync -- use `renv::status()` for details.
#> → Recording changes in lockfile
#> The following package(s) will be updated in the lockfile:
#> 
#> # GitHub ---------------------------------------------------------------------
#> - renv          [* -> rstudio/renv]
#> 
#> # https://packagemanager.posit.co/cran/__linux__/jammy/latest ----------------
#> - R6            [* -> 2.5.1]
#> - base64enc     [* -> 0.1-3]
#> - bslib         [* -> 0.7.0]
#> - cachem        [* -> 1.1.0]
#> - cli           [* -> 3.6.3]
#> - digest        [* -> 0.6.36]
#> - evaluate      [* -> 0.24.0]
#> - fastmap       [* -> 1.2.0]
#> - fontawesome   [* -> 0.5.2]
#> - fs            [* -> 1.6.4]
#> - glue          [* -> 1.7.0]
#> - highr         [* -> 0.11]
#> - htmltools     [* -> 0.5.8.1]
#> - jquerylib     [* -> 0.1.4]
#> - jsonlite      [* -> 1.8.8]
#> - knitr         [* -> 1.48]
#> - lifecycle     [* -> 1.0.4]
#> - memoise       [* -> 2.0.1]
#> - mime          [* -> 0.12]
#> - rappdirs      [* -> 0.3.3]
#> - rlang         [* -> 1.1.4]
#> - rmarkdown     [* -> 2.27]
#> - sass          [* -> 0.4.9]
#> - tinytex       [* -> 0.52]
#> - xfun          [* -> 0.46]
#> - yaml          [* -> 2.3.10]
#> 
#> The version of R recorded in the lockfile will be updated:
#> - R             [* -> 4.4.1]
#> 
#> - Lockfile written to "/tmp/RtmpP9eYUD/file19326f152317/renv/profiles/lesson-requirements/renv.lock".
#>  Lesson successfully created in /tmp/RtmpP9eYUD/file19326f152317
#> → Creating Lesson in /tmp/RtmpP9eYUD/file19326f152317...

validate_lesson(lsn, headings = TRUE)
#> ── Validating Headings ─────────────────────────────────────────────────
#> ── Heading structure ───────────────────────────────────────────────────
#> # Episode: <EPISODE> 
#> └─# Contributing  (must be level 2) (first level heading)
#>   ├─## Contributor Agreement 
#>   ├─## How to Contribute 
#>   ├─## Where to Contribute 
#>   ├─## What to Contribute 
#>   ├─## What Not to Contribute 
#>   ├─## Using GitHub 
#>   └─## Other Resources 
#> ────────────────────────────────────────────────────────────────────────
#> ! There were errors in 1/23 headings
#> ◌ First heading must be level 2
#> ◌ Level 1 headings are not allowed
#> <https://webaim.org/techniques/semanticstructure/#headings>
#> 
#> ::warning file=CONTRIBUTING.md,line=1:: (must be level 2) (first level heading)
#> ── Validating Fenced Divs ──────────────────────────────────────────────
#> ── Validating Internal Links and Images ────────────────────────────────
#> ! There were errors in 13/37 links
#> ◌ Links must use HTTPS <https://https.cio.gov/everything/>
#> ◌ Some linked internal files do not exist <https://carpentries.github.io/sandpaper/articles/include-child-documents.html#workspace-consideration>
#> 
#> ::warning file=CONTRIBUTING.md,line=3:: [needs HTTPS]: [Software Carpentry](http://software-carpentry.org/)
#> ::warning file=CONTRIBUTING.md,line=3:: [needs HTTPS]: [Data Carpentry](http://datacarpentry.org/)
#> ::warning file=CONTRIBUTING.md,line=17:: [needs HTTPS]: [Software Carpentry](http://software-carpentry.org/)
#> ::warning file=CONTRIBUTING.md,line=17:: [needs HTTPS]: [Data Carpentry](http://datacarpentry.org/)
#> ::warning file=CONTRIBUTING.md,line=18:: [missing file]: [code of conduct](CONDUCT.md)
#> ::warning file=CONTRIBUTING.md,line=29:: [needs HTTPS]: [GitHub](http://github.com)
#> ::warning file=CONTRIBUTING.md,line=34:: [needs HTTPS]: [GitHub](http://github.com)
#> ::warning file=CONTRIBUTING.md,line=114:: [needs HTTPS]: [Software Carpentry](http://software-carpentry.org/)
#> ::warning file=CONTRIBUTING.md,line=114:: [needs HTTPS]: [Data Carpentry](http://datacarpentry.org/)
#> ::warning file=CONTRIBUTING.md,line=115:: [needs HTTPS]: [discussion mailing list](http://lists.software-carpentry.org/listinfo/discuss)
#> ::warning file=LICENSE.md,line=28:: [needs HTTPS]: [http://software-carpentry.org/](http://software-carpentry.org/)
#> ::warning file=LICENSE.md,line=76:: [needs HTTPS]: [Community Initiatives](http://communityin.org/)
#> ::warning file=learners/setup.md,line=10:: [missing file]: [data zip file](data/data.zip)