Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress pkgdown's theme dependencies from examples and article content #1997

Merged
merged 7 commits into from
Jan 7, 2022

Conversation

gadenbuie
Copy link
Contributor

This PR resolves problems like the one seen in #1929 where adding htmltools objects (htmlwidgets, etc.) in reference examples or in articles could result in multiple versions of jQuery or multiple Bootstrap JS/CSS files being loaded on the page.

Rather than modifying pkgdown_print(), the approach here to follow the lead from htmltools::suppressDependencies() and to create empty deps for jQuery and Bootstrap with versions 9999 that are either added to the dependencies returned by the examples or provided to the extra_dependencies argument of the html_document() format that is used for articles.

Note that asis articles are left as-is — if required, authors can still use suppressDependencies("jquery", "bootstrap") in the articles source.

Because this is done at a higher level than I initially anticipated, duplicated dependencies are dropped silently. But this matches how dependencies are resolved among htmlwidgets in the same .Rmd file with competing dependencies, so I think that's acceptable behavior.

@hadley
Copy link
Member

hadley commented Jan 6, 2022

Would this approach also work for #1798? (And hence reduce the hackiness)

@gadenbuie
Copy link
Contributor Author

Yeah, I think it would! You'd like to suppress the anchor sections javascript for both Bootstrap versions, correct?

@hadley
Copy link
Member

hadley commented Jan 6, 2022

@gadenbuie correct

@hadley hadley merged commit f85cfa2 into r-lib:main Jan 7, 2022
@hadley
Copy link
Member

hadley commented Jan 7, 2022

Thank you!

@gadenbuie gadenbuie deleted the ignore-pkgdown-deps-in-rmd branch January 7, 2022 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants