Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef2a968

Browse files
committed
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.
1 parent c6111ec commit ef2a968

File tree

8 files changed

+3134
-49
lines changed

8 files changed

+3134
-49
lines changed

.github/workflows/documentation.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Update the www.libgit2.org reference documentation
2+
name: Generate Documentation
3+
4+
on:
5+
push:
6+
branches: [ main, maint/* ]
7+
pull_request:
8+
branches: [ main ]
9+
release:
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
documentation:
17+
name: "Generate documentation"
18+
runs-on: "ubuntu-latest"
19+
steps:
20+
- name: Check out source repository
21+
uses: actions/checkout@v4
22+
with:
23+
path: source
24+
fetch-depth: 0
25+
- name: Check out documentation repository
26+
uses: actions/checkout@v4
27+
with:
28+
repository: libgit2/www.libgit2.org
29+
path: www
30+
fetch-depth: 0
31+
ssh-key: ${{ secrets.DOCS_PUBLISH_KEY }}
32+
- name: Prepare branches
33+
run: |
34+
for a in main $(git branch -r --list 'origin/maint/*' | sed -e "s/^ origin\///"); do
35+
git branch --track "$a" "origin/$a"
36+
done
37+
working-directory: source
38+
- name: Generate documentation
39+
run: |
40+
npm install
41+
./generate ../.. ../../../www/docs
42+
working-directory: source/script/api-docs
43+
- name: Examine changes
44+
run: |
45+
if [ -n "$(git diff --name-only)" ]; then
46+
echo "changes=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "changes=false" >> $GITHUB_OUTPUT
49+
fi
50+
id: check
51+
working-directory: www
52+
- name: Publish documentation
53+
run: |
54+
DATE=$(date +"%Y-%m-%d")
55+
56+
git config user.name 'Documentation Site Generator'
57+
git config user.email '[email protected]'
58+
git add .
59+
git commit -m"Documentation update ${DATE}"
60+
git push origin main
61+
if: steps.check.outputs.changes == 'true'
62+
working-directory: www

.github/workflows/main.yml

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -245,52 +245,3 @@ jobs:
245245
uses: test-summary/action@v2
246246
with:
247247
paths: 'test-results-*/*.xml'
248-
249-
250-
# Generate documentation using docurium. We'll upload the documentation
251-
# as a build artifact so that it can be reviewed as part of a pull
252-
# request or in a forked build. For CI builds in the main repository's
253-
# main branch, we'll push the gh-pages branch back up so that it is
254-
# published to our documentation site.
255-
documentation:
256-
name: Generate documentation
257-
if: success() || failure()
258-
runs-on: ubuntu-latest
259-
steps:
260-
- name: Check out repository
261-
uses: actions/checkout@v4
262-
with:
263-
path: source
264-
fetch-depth: 0
265-
- name: Set up container
266-
uses: ./source/.github/actions/download-or-build-container
267-
with:
268-
registry: ${{ env.docker-registry }}
269-
config-path: ${{ env.docker-config-path }}
270-
container: docurium
271-
github_token: ${{ secrets.github_token }}
272-
dockerfile: ${{ matrix.platform.container.dockerfile }}
273-
- name: Generate documentation
274-
working-directory: source
275-
run: |
276-
git config user.name 'Documentation Generation'
277-
git config user.email '[email protected]'
278-
git branch gh-pages origin/gh-pages
279-
docker login https://${{ env.docker-registry }} -u ${{ github.actor }} -p ${{ github.token }}
280-
docker run \
281-
--rm \
282-
-v "$(pwd):/home/libgit2" \
283-
-w /home/libgit2 \
284-
${{ env.docker-registry }}/${{ github.repository }}/docurium:latest \
285-
cm doc api.docurium
286-
git checkout gh-pages
287-
zip --exclude .git/\* --exclude .gitignore --exclude .gitattributes -r api-documentation.zip .
288-
- uses: actions/upload-artifact@v4
289-
name: Upload artifact
290-
with:
291-
name: api-documentation
292-
path: source/api-documentation.zip
293-
- name: Push documentation branch
294-
working-directory: source
295-
run: git push origin gh-pages
296-
if: github.event_name == 'push' && github.repository == 'libgit2/libgit2'

script/api-docs/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# API Documentation Generator
2+
3+
These scripts generate the "raw API" specs and reference documentation
4+
for [www.libgit2.org](https://libgit2.org/docs/reference).
5+
6+
The "raw API" specs consists of JSON documents, on per
7+
released version or branch, that describes the APIs. This is
8+
suitable for creating documentation from, or may be useful for
9+
language bindings as well.
10+
11+
The reference documentation is documentation fragments for each
12+
API in each version, ready to be included in the libgit2 documentation
13+
website.

0 commit comments

Comments
 (0)