diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index c6ba17b..1596829 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -68,6 +68,29 @@ jobs: # We also remove the surplus entry for the classes with spaces sed -i 's/\w\+\.[a-zA-Z_ ]\+<\/a><\/code>//g' docs/reference/index.html + - name: Remove question marks from auto-linked references + run: | + # The only way to auto-link R6 objects is by prepending af `?` to the code block + # For specific functions in an R6 class, it is possible to prepend the parent class `?parent$function()` + + # Here we filter out these prepended blocks to generate a cleaner documentation. + + # Fixing "?R6class" + # The links to the internal R6 classes have the following format when generated by pkgdown: + # ?FeatureHandler + # We remove the question mark to make the link cleaner + # regex: \?(\w+)<\/a> + find docs -type f -exec sed -i 's/\?\(\w\+\)<\/a>/\2<\/a>/g' {} + + + # Fixing "?R6class$function()" + # pkgdown does not generate links for this type of reference, so we need to create the link fully manually + # The code has the following format when generated by pkgdown + # ?DiseasystoreBase$available_observables + # We need to manually create the link to the function + # regex: \?(\w+)\$()(\w+\(\))<\/code> + # Target: get_feature() + find docs -type f -exec sed -i 's/\?\(\w\+\)\$\(\w\+\(\)\)<\/code>/\2<\/code><\/a>/g' {} + + - name: Upload artifact uses: actions/upload-artifact@v4 with: diff --git a/workflows/README.md b/workflows/README.md index 7b74f2f..cd6bbf5 100644 --- a/workflows/README.md +++ b/workflows/README.md @@ -119,10 +119,16 @@ If this generate changes the `.Rd` files, it will commit the updated documentati #### Trigger Pushes or pull requests to the main branch if there are changes to any file in the `R/`, `man/` or `vignette/` folders. -Special triggering on creation of a `release` +Special triggering on creation of a `release`. #### Function -Generates the `pkgdown` documentation for your package +Generates the `pkgdown` documentation for your package. + +> [!IMPORTANT] +> This workflow runs additional formatting of the pkgdown documentation. +> Specifically, it adds auto-linking to R6 object +> - `?MyR6Class` is rendered without the `?` and links to `MyR6Class`. +> - `?MyR6Class$method()` is rendered as `method()` and links to the method of `MyR6Class` #### Outcome The output of `pkgdown` is stored as an artifact on github.