Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zseta authored Mar 11, 2024
2 parents 02030d9 + 9ef0b27 commit 04a5b13
Show file tree
Hide file tree
Showing 11 changed files with 558 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/docs-amplify-enhanced.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Docs / Amplify enhanced"

on: issue_comment

jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Amplify enhanced
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: scylladb/sphinx-scylladb-theme/.github/actions/amplify-enhanced@master
72 changes: 72 additions & 0 deletions .github/workflows/docs-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: "Docs / Publish"
# For more information,
# see https://sphinx-theme.scylladb.com/stable/deployment/production.html#available-workflows

on:
push:
branches:
- main
paths:
- "docs/**"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Set up env
run: make -C docs setupenv

- name: Build docs
run: make -C docs multiversion

- name: Build redirects
run: make -C docs redirects

- name: Tar folder
run: |
tar \
--dereference --hard-dereference \
--directory docs/_build/dirhtml/ \
-cvf ${{ runner.temp }}/artifact.tar \
.
- name: Upload artifact
uses: actions/upload-artifact@main
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: "1"

release:
# Add a dependency to the build job
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
contents: read # to read private repo

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
31 changes: 31 additions & 0 deletions .github/workflows/docs-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Docs / Build PR"
# For more information,
# see https://sphinx-theme.scylladb.com/stable/deployment/production.html#available-workflows

on:
pull_request:
branches:
- main
paths:
- "docs/**"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.7

- name: Set up env
run: make -C docs setupenv

- name: Build docs
run: make -C docs test
94 changes: 94 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Global variables
# You can set these variables from the command line.
POETRY = poetry
SPHINXOPTS = -j auto
SPHINXBUILD = $(POETRY) run sphinx-build
PAPER =
BUILDDIR = _build
SOURCEDIR = source

# Internal variables
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SOURCEDIR)
TESTSPHINXOPTS = $(ALLSPHINXOPTS) -W --keep-going

.PHONY: all
all: dirhtml

# Setup commands
.PHONY: setupenv
setupenv:
pip install -q poetry

.PHONY: setup
setup:
$(POETRY) install
$(POETRY) update

# Clean commands
.PHONY: pristine
pristine: clean
git clean -dfX

.PHONY: clean
clean:
rm -rf $(BUILDDIR)/*
rm -f poetry.lock

# Generate output commands
.PHONY: dirhtml
dirhtml: setup
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

.PHONY: singlehtml
singlehtml: setup
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

.PHONY: epub
epub: setup
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

.PHONY: epub3
epub3: setup
$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
@echo
@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."

.PHONY: multiversion
multiversion: setup
$(POETRY) run sphinx-multiversion source $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

.PHONY: redirects
redirects: setup
$(POETRY) run redirects-cli fromfile --yaml-file _utils/redirects.yaml --output-dir $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

# Preview commands
.PHONY: preview
preview: setup
$(POETRY) run sphinx-autobuild -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml --port 5500

.PHONY: multiversionpreview
multiversionpreview: multiversion
$(POETRY) run python -m http.server 5500 --directory $(BUILDDIR)/dirhtml

# Test commands
.PHONY: test
test: setup
$(SPHINXBUILD) -b dirhtml $(TESTSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

.PHONY: linkcheck
linkcheck: setup
$(SPHINXBUILD) -b linkcheck $(SOURCEDIR) $(BUILDDIR)/linkcheck
18 changes: 18 additions & 0 deletions docs/_utils/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Copy contents
mkdir gh-pages
cp -r ./docs/_build/dirhtml/. gh-pages

# Create gh-pages branch
cd gh-pages
git init
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout -b gh-pages

# Deploy
git add .
git commit -m "Publish docs" || true
git push origin gh-pages --force
8 changes: 8 additions & 0 deletions docs/_utils/redirects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### a dictionary of redirects
#old path: new path
#

# removing redirection html script files
# test: /


21 changes: 21 additions & 0 deletions docs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.poetry]
name = "sphinx-docs"
description = "ScyllaDB Documentation"
version = "0.1.0"
authors = ["ScyllaDB Documentation Contributors"]

[tool.poetry.dependencies]
python = "^3.9"
pyyaml = "6.0.1"
pygments = "2.15.1"
recommonmark = "0.7.1"
sphinx-scylladb-theme = "~1.6.1"
sphinx-autobuild = "2021.3.14"
Sphinx = "7.2.6"
sphinx-multiversion-scylla = "~0.3.1"
sphinx-sitemap = "2.5.1"
redirects_cli ="~0.1.3"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 04a5b13

Please sign in to comment.