视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
build-pkgdown-site【文档与办公】Build and deploy a pkgdown documentation site for an R package to GitHub Pages. Covers _pkgdown.yml configuration, theming, article organization, reference index customization, and deployment methods. Use when creating a documentation site for a new or existing package, customizing layout or navigation, fixing 404 errors on a deployed site, or migrat…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
配發 R 包之 pkgdown 文站。
usethis::use_pkgdown()
此造 _pkgdown.yml 且加 pkgdown 至 .Rbuildignore。
得: _pkgdown.yml 存案根。.Rbuildignore 含 pkgdown 相條。
敗: 以 install.packages("pkgdown") 裝 pkgdown。若 _pkgdown.yml 已存→函更 .Rbuildignore 而不覆配。
_pkgdown.ymlurl: https://username.github.io/packagename/
development:
mode: release
template:
bootstrap: 5
bootswatch: flatly
navbar:
structure:
left: [intro, reference, articles, news]
right: [search, github]
components:
github:
icon: fa-github
href: https://github.com/username/packagename
reference:
- title: Core Functions
desc: Primary package functionality
contents:
- main_function
- helper_function
- title: Utilities
desc: Helper and utility functions
contents:
- starts_with("util_")
articles:
- title: Getting Started
contents:
- getting-started
- title: Advanced Usage
contents:
- advanced-features
- customization
要:設 development: mode: release。默 mode: auto 致 GitHub Pages 之 404,因附 /dev/ 於 URL。
得: _pkgdown.yml 含有效 YAML 附 url、template、navbar、reference、articles 段合包。
敗: 以網上 YAML 解器驗法。確 reference.contents 之諸函名合實導函。
pkgdown::build_site()
得: docs/ 目已造附全站含 index.html、函引頁、篇。
敗: 常題:pandoc 缺(於 .Renviron 設 RSTUDIO_PANDOC)、vignette 依缺(裝薦包)、例破(修或以 \dontrun{} 包)。
pkgdown::preview_site()
驗導、函引、篇、搜正。
得: 站於 localhost 開於瀏。諸導連行、函引頁渲、搜返結。
敗: 預覽不開→手開 docs/index.html。頁缺→察 devtools::document() 構前已行。
法 A:GitHub Actions(薦)
詳 setup-github-actions-ci 技之 pkgdown 流。
法 B:手枝發
# Build site
Rscript -e "pkgdown::build_site()"
# Create gh-pages branch if it doesn't exist
git checkout --orphan gh-pages
git rm -rf .
cp -r docs/* .
git add .
git commit -m "Deploy pkgdown site"
git push origin gh-pages
# Switch back to main
git checkout main
得: gh-pages 枝存於遠附站檔於根級。
敗: 推拒→確有庫書權。若用 GitHub Actions 發→略此步而從 setup-github-actions-ci。
gh-pages 枝、/ (root) 目得: 站於數分內於 https://username.github.io/packagename/ 可達。
敗: 站返 404→驗 Pages 源合發法(枝發需「Deploy from a branch」)。察 _pkgdown.yml 設 development: mode: release。
URL: https://username.github.io/packagename/, https://github.com/username/packagename
得: DESCRIPTION URL 欄含 pkgdown 站 URL 與 GitHub 庫 URL,逗分。
敗: R CMD check 警 URL 無效→先驗 pkgdown 站實發且可達而後加 URL。
_pkgdown.yml 設 development: mode: releasedevelopment: mode: auto(默)。改 mode: release。devtools::document()。vignette("name") 法,非檔徑。man/figures/logo.png 且於 _pkgdown.yml 引。_pkgdown.yml 之 url 欄正設。Rscript 或解為跨平包裝非原 R。察 which Rscript && Rscript --version。宜用原 R(如 Linux/WSL /usr/local/bin/Rscript)以穩。詳 Setting Up Your Environment。setup-github-actions-ci — 自動 pkgdown 發流write-roxygen-docs — 現於站之函文write-vignette — 現於站導之篇release-package-version — 發時觸站重構