Repository navigation
168 lines (146 loc) · 5.77 KB
/
Copy pathdocs.yml
File metadata and controls
168 lines (146 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: API docs
# Builds the per-language API documentation (best-of-breed toolchains) and
# publishes the assembled site to GitHub Pages:
# Doxygen -> C / C++ (include/)
# DocFX -> .NET (src/dotnetlib)
# TypeDoc -> Node.js (src/nodejs/index.d.ts)
# Sphinx -> Python (SWIG-generated cec module from src/libcec/libcec.i)
# rustdoc -> Rust (src/rust)
# A hand-written landing page (docs/api/landing) links the five together.
on:
push:
branches: [ master ]
paths:
- 'include/**'
- 'src/dotnetlib/**'
- 'src/nodejs/**'
- 'src/rust/**'
- 'src/libcec/libcec.i'
- 'src/libcec/SwigHelper.h'
- 'docs/api/**'
- '.github/workflows/docs.yml'
- 'CMakeLists.txt'
workflow_dispatch:
# Least-privilege token that can still deploy Pages.
permissions:
contents: read
pages: write
id-token: write
# One in-flight deploy at a time; let a newer push cancel an older run.
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# No submodules needed: every documented binding lives in this repo.
- name: Resolve libCEC version
run: |
maj=$(sed -nE 's/.*LIBCEC_VERSION_MAJOR[[:space:]]+([0-9]+).*/\1/p' CMakeLists.txt)
min=$(sed -nE 's/.*LIBCEC_VERSION_MINOR[[:space:]]+([0-9]+).*/\1/p' CMakeLists.txt)
pat=$(sed -nE 's/.*LIBCEC_VERSION_PATCH[[:space:]]+([0-9]+).*/\1/p' CMakeLists.txt)
echo "LIBCEC_VERSION=${maj}.${min}.${pat}" >> "$GITHUB_ENV"
echo "LIBCEC_VERSION_MAJOR=${maj}" >> "$GITHUB_ENV"
echo "Documenting libCEC ${maj}.${min}.${pat}"
- name: Prepare site tree
run: mkdir -p site/cpp site/dotnet site/nodejs site/python site/rust
# --- C / C++ : Doxygen ------------------------------------------------
- name: Install Doxygen
run: sudo apt-get update && sudo apt-get install -y doxygen graphviz
- name: Fetch doxygen-awesome theme
run: |
git clone --depth 1 --branch v2.3.4 \
https://github.com/jothepro/doxygen-awesome-css.git /tmp/dac
cp /tmp/dac/doxygen-awesome.css \
/tmp/dac/doxygen-awesome-sidebar-only.css \
docs/api/doxygen/
- name: Run Doxygen
working-directory: docs/api/doxygen
run: |
( cat Doxyfile
echo "PROJECT_NUMBER=${LIBCEC_VERSION}"
echo "OUTPUT_DIRECTORY=${GITHUB_WORKSPACE}/site/cpp"
echo "HTML_OUTPUT=."
) | doxygen -
# --- .NET : DocFX -----------------------------------------------------
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install DocFX
run: |
dotnet tool install -g docfx
echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
- name: Run DocFX
working-directory: docs/api/dotnet
run: |
docfx metadata docfx.json
docfx build docfx.json
cp -r _site/. "${GITHUB_WORKSPACE}/site/dotnet/"
# --- Node.js : TypeDoc ------------------------------------------------
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run TypeDoc
working-directory: docs/api/nodejs
run: |
npm install --no-save typedoc typescript @types/node
npx typedoc --options typedoc.json
cp -r _site/. "${GITHUB_WORKSPACE}/site/nodejs/"
# --- Python : SWIG (-doxygen) + Sphinx --------------------------------
- name: Install SWIG + Sphinx
run: |
sudo apt-get install -y swig
python -m pip install --upgrade pip
pip install -r docs/api/python/requirements.txt
- name: Generate cec.py (SWIG carries the C++ docs into docstrings)
run: |
mkdir -p "${GITHUB_WORKSPACE}/pygen"
swig -c++ -python -doxygen \
-Iinclude -Isrc/libcec \
-DCEC_LIB_VERSION_MAJOR="${LIBCEC_VERSION_MAJOR}" \
-outdir "${GITHUB_WORKSPACE}/pygen" \
-o "${GITHUB_WORKSPACE}/pygen/cec_wrap.cxx" \
src/libcec/libcec.i
- name: Run Sphinx
env:
CEC_PY_MODULE_DIR: ${{ github.workspace }}/pygen
run: sphinx-build -b html docs/api/python "${GITHUB_WORKSPACE}/site/python"
# --- Rust : rustdoc ---------------------------------------------------
# No libCEC is installed on the runner and none is needed: build.rs only
# emits link flags, and documenting a crate never links it. Warnings are
# denied so a broken intra-doc link fails here rather than shipping.
- name: Run rustdoc
working-directory: src/rust
env:
RUSTDOCFLAGS: -D warnings
run: |
cargo doc --no-deps --offline
cp -r target/doc/. "${GITHUB_WORKSPACE}/site/rust/"
# rustdoc puts the crate under libcec/ and writes no root index when
# only one crate is documented, so /rust/ needs this redirect.
cp "${GITHUB_WORKSPACE}/docs/api/rust/index.html" \
"${GITHUB_WORKSPACE}/site/rust/index.html"
# --- Assemble + upload -----------------------------------------------
- name: Add landing page + shared assets
run: |
cp docs/api/landing/index.html site/index.html
cp -r docs/api/assets site/assets
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: site
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4