Include documentation generator

libgit2 has a new documentation generator that generates API schema from
our headers, then produces reference documentation that is included into
the website directly.
This commit is contained in:
Edward Thomson
2024-11-25 10:12:29 +00:00
parent c6111ec06c
commit 89cc5ef8e8
8 changed files with 3132 additions and 49 deletions

60
.github/workflows/documentation.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
# Update the www.libgit2.org reference documentation
name: Generate Documentation
on:
push:
branches: [ main, maint/* ]
release:
workflow_dispatch:
permissions:
contents: read
jobs:
documentation:
name: "Generate documentation"
runs-on: "ubuntu-latest"
steps:
- name: Check out source repository
uses: actions/checkout@v4
with:
path: source
fetch-depth: 0
- name: Check out documentation repository
uses: actions/checkout@v4
with:
repository: libgit2/www.libgit2.org
path: www
fetch-depth: 0
ssh-key: ${{ secrets.DOCS_PUBLISH_KEY }}
- name: Prepare branches
run: |
for a in main $(git branch -r --list 'origin/maint/*' | sed -e "s/^ origin\///"); do
git branch --track "$a" "origin/$a"
done
working-directory: source
- name: Generate documentation
run: |
npm install
./generate ../.. ../../../www/docs
working-directory: source/script/api-docs
- name: Examine changes
run: |
if [ -n "$(git diff --name-only)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
id: check
working-directory: www
- name: Publish documentation
run: |
DATE=$(date +"%Y-%m-%d")
git config user.name 'Documentation Site Generator'
git config user.email 'libgit2@users.noreply.github.com'
git add .
git commit -m"Documentation update ${DATE}"
git push origin main
if: steps.check.outputs.changes == 'true'
working-directory: www

View File

@@ -245,52 +245,3 @@ jobs:
uses: test-summary/action@v2
with:
paths: 'test-results-*/*.xml'
# Generate documentation using docurium. We'll upload the documentation
# as a build artifact so that it can be reviewed as part of a pull
# request or in a forked build. For CI builds in the main repository's
# main branch, we'll push the gh-pages branch back up so that it is
# published to our documentation site.
documentation:
name: Generate documentation
if: success() || failure()
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
path: source
fetch-depth: 0
- name: Set up container
uses: ./source/.github/actions/download-or-build-container
with:
registry: ${{ env.docker-registry }}
config-path: ${{ env.docker-config-path }}
container: docurium
github_token: ${{ secrets.github_token }}
dockerfile: ${{ matrix.platform.container.dockerfile }}
- name: Generate documentation
working-directory: source
run: |
git config user.name 'Documentation Generation'
git config user.email 'libgit2@users.noreply.github.com'
git branch gh-pages origin/gh-pages
docker login https://${{ env.docker-registry }} -u ${{ github.actor }} -p ${{ github.token }}
docker run \
--rm \
-v "$(pwd):/home/libgit2" \
-w /home/libgit2 \
${{ env.docker-registry }}/${{ github.repository }}/docurium:latest \
cm doc api.docurium
git checkout gh-pages
zip --exclude .git/\* --exclude .gitignore --exclude .gitattributes -r api-documentation.zip .
- uses: actions/upload-artifact@v4
name: Upload artifact
with:
name: api-documentation
path: source/api-documentation.zip
- name: Push documentation branch
working-directory: source
run: git push origin gh-pages
if: github.event_name == 'push' && github.repository == 'libgit2/libgit2'