From a73b2e56f8fb9d38183d9d56a1f37539f06c4f09 Mon Sep 17 00:00:00 2001 From: tdstein Date: Fri, 31 May 2024 10:24:07 -0400 Subject: [PATCH] ci: add docs site preview --- .github/workflows/ci.yaml | 14 -------------- .github/workflows/docs.yaml | 29 +++++++++++++++++++++++++++++ docs/Makefile | 28 +++++++++++++++++++--------- docs/_publish.yaml | 4 ++++ docs/_quarto.yml | 3 +++ docs/requirements-site.txt | 2 ++ requirements-dev.txt | 2 +- 7 files changed, 58 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/docs.yaml create mode 100644 docs/_publish.yaml create mode 100644 docs/requirements-site.txt diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6ea99819..10bd741d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,17 +50,3 @@ jobs: cache: 'pip' - run: make deps - run: make build - - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - check-latest: true - cache: 'pip' - - uses: quarto-dev/quarto-actions/setup@v2 - - run: make deps - - run: make dev - - run: make docs diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 00000000..ffb639ce --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,29 @@ +name: Documentation +on: + - pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + default: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + check-latest: true + cache: 'pip' + - uses: quarto-dev/quarto-actions/setup@v2 + - run: make deps + - run: make dev + - run: make docs + - uses: actions/setup-node@v4 + - run: npm install -g netlify + - run: netlify help + - uses: quarto-dev/quarto-actions/publish@v2 + with: + target: netlify + path: docs + render: false + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} diff --git a/docs/Makefile b/docs/Makefile index 05158648..03b3ae0c 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,24 +1,31 @@ .DEFAULT_GOAL := all # Command aliases -QUARTO=quarto -QUARTODOC=quartodoc +PIP ?= pip3 +QUARTO ?= quarto +QUARTODOC ?= quartodoc # Environment variables -CURRENT_YEAR := $(shell date +%Y) -VERSION := $(shell make -C ../ version) -export CURRENT_YEAR VERSION +CURRENT_YEAR ?= $(shell date +%Y) +VERSION ?= $(shell make -C ../ version) -.PHONY: clean build deps preview +.PHONY: all \ + api \ + build \ + clean \ + deps \ + preview all: deps api build -api: deps +api: $(QUARTODOC) build $(QUARTODOC) interlinks cp -r _extensions/ reference/_extensions # Required to render footer -build: api +build: + CURRENT_YEAR=$(CURRENT_YEAR) \ + VERSION=$(VERSION) \ $(QUARTO) render clean: @@ -26,8 +33,11 @@ clean: find . -type d -empty -delete deps: + $(PIP) install --upgrade pip -r requirements-site.txt $(QUARTO) add --no-prompt posit-dev/product-doc-theme@v4.0.2 $(QUARTO) add --no-prompt machow/quartodoc -preview: api +preview: + CURRENT_YEAR=$(CURRENT_YEAR) \ + VERSION=$(VERSION) \ $(QUARTO) preview diff --git a/docs/_publish.yaml b/docs/_publish.yaml new file mode 100644 index 00000000..eb299724 --- /dev/null +++ b/docs/_publish.yaml @@ -0,0 +1,4 @@ +- source: project + netlify: + - id: "5cea1f56-7935-4387-975a-18a7905d15ee" + url: "https://posit-sdk-py.netlify.app" diff --git a/docs/_quarto.yml b/docs/_quarto.yml index cb3cbaa6..48d41707 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -1,6 +1,9 @@ project: type: website +execute: + freeze: auto + website: title: "Posit SDK {{< env VERSION >}}" bread-crumbs: true diff --git a/docs/requirements-site.txt b/docs/requirements-site.txt new file mode 100644 index 00000000..65b22507 --- /dev/null +++ b/docs/requirements-site.txt @@ -0,0 +1,2 @@ + +quartodoc diff --git a/requirements-dev.txt b/requirements-dev.txt index 76259bb1..10ceed65 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,7 +5,7 @@ pandas pre-commit pyjson5 pytest -quartodoc +rsconnect responses ruff setuptools