diff --git a/DocsDocumenter/action.yml b/DocsDocumenter/action.yml index aee989f..7123422 100644 --- a/DocsDocumenter/action.yml +++ b/DocsDocumenter/action.yml @@ -54,6 +54,10 @@ inputs: description: 'Whether to deploy the docs to the gh-pages branch' required: false default: 'true' + use-vitepress: + description: 'Whether to use DocumenterVitepress.deploydocs() instead of Documenter.deploydocs() for deployment. Requires DocumenterVitepress to be listed in the docs Project.toml.' + required: false + default: 'false' post-preview-comment: description: 'Whether to post a pull request preview comment after deployment' required: false @@ -112,6 +116,14 @@ runs: - name: Build docs shell: bash run: julia --project=${{ inputs.doc-path }} ${{ inputs.doc-make-path }} + # `DocumenterVitepress`'s writer calls `Documenter.deploy_folder(...)` + # at build time to decide the `bases` it writes to `build/bases.txt`. + # `deploy_folder` requires `GITHUB_TOKEN` to be present to recognise + # a CI build; without it the writer falls back to `all_ok=false`, + # `subfolder=""`, and the later deploy step finds an empty bases list + # and skips. Expose the token so PR-preview deploys work end-to-end. + env: + GITHUB_TOKEN: ${{ github.token }} # We want to use the same version of DocsNav. In principle we would like # to write `uses: TuringLang/actions/DocsNav@${{ github.action_ref }}`, @@ -142,8 +154,14 @@ runs: # Must pass `root` when `deploydocs()` is run from outside make.jl file # Also, `root` must be an absolute path (hence the call to `pwd()`) run: | - using Documenter - deploydocs(; root=pwd(), repo="github.com/${{ github.repository }}.git", dirname="${{ inputs.dirname }}", tag_prefix="${{ inputs.tag_prefix }}", push_preview=true) + use_vitepress = "${{ inputs.use-vitepress }}" == "true" + if use_vitepress + using DocumenterVitepress + DocumenterVitepress.deploydocs(; root=pwd(), repo="github.com/${{ github.repository }}.git", dirname="${{ inputs.dirname }}", tag_prefix="${{ inputs.tag_prefix }}", push_preview=true) + else + using Documenter + deploydocs(; root=pwd(), repo="github.com/${{ github.repository }}.git", dirname="${{ inputs.dirname }}", tag_prefix="${{ inputs.tag_prefix }}", push_preview=true) + end env: GITHUB_TOKEN: ${{ github.token }} JULIA_DEBUG: Documenter diff --git a/DocsNav/scripts/TuringNavbar.html b/DocsNav/scripts/TuringNavbar.html index fd9fca4..ccaea92 100644 --- a/DocsNav/scripts/TuringNavbar.html +++ b/DocsNav/scripts/TuringNavbar.html @@ -22,6 +22,41 @@ } /* End of Documenter.jl Tweaks */ + /* DocumenterVitepress integration: + Vitepress's default theme already exposes `--vp-layout-top-height` as + the hook for adding banner-style chrome above its own nav. Every + layout-sensitive component (`.VPNav` `top`, `.VPContent` `margin`, + `.VPSidebar` `top`, `.VPLocalNav` `padding-top`, `.VPDocAside` `top` + and TOC `padding-top`) is already authored to add this variable to + its own offset, so binding it to the TuringLang navbar height makes + Vitepress reflow itself correctly with zero further intervention. + (`:has(.VPNavBar)` scopes this to Vitepress builds; Documenter HTML + sites are untouched.) */ + html:has(.VPNavBar) { + --vp-layout-top-height: var(--navbar-height); + } + + /* When the rendered site is Vitepress (detected by .VPNavBar being in the + DOM), adopt Vitepress's design tokens so the TuringLang navbar tracks + the active theme (light/dark, brand colour, body font) and reads as one + piece of chrome with the Vitepress nav below it — rather than a stacked + second header with its own colour and typography. */ + html:has(.VPNavBar) { + --primary-bg: var(--vp-c-bg); + --heading-color: var(--vp-c-text-1); + --item-color: var(--vp-c-text-2); + --icon-color: var(--vp-c-text-1); + --hover-color: var(--vp-c-brand-1); + --shadow-color: var(--vp-c-divider); + --dropdown-hover-bg: var(--vp-c-default-soft); + --font-family: var(--vp-font-family-base); + } + html:has(.VPNavBar) .ext-navigation { + box-shadow: none; + border-bottom: 1px solid var(--vp-c-divider); + } + /* End of DocumenterVitepress Tweaks */ + /* Color and Font Variables */ :root { --heading-color: #6c757d; diff --git a/README.md b/README.md index 2b45fa0..7a6b30c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ If your `docs/make.jl` file contains a call to `deploydocs()`, it is not a big d | `julia-version` | Julia version to use | `'1'` | | `exclude-paths` | JSON array of filepath patterns to exclude from navbar insertion | `"[]"` | | `deploy` | Whether to deploy to the `gh-pages` branch or not | `true` | +| `use-vitepress` | Use `DocumenterVitepress.deploydocs()` instead of `Documenter.deploydocs()`. Requires `DocumenterVitepress` in the docs `Project.toml`. | `false` | | `post-preview-comment` | Whether to post the sticky pull request preview comment after deployment | `true` | ### Outputs