Skip to content

Commit 535a835

Browse files
authored
Merge pull request #41 from Rnfudge02/integrate-openapi
workflows: added workflow to facilitate embedding REST-OpenAPI docume…
2 parents e9d632e + 219adc0 commit 535a835

4 files changed

Lines changed: 22 additions & 10 deletions

File tree

.github/pull_request_template.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# Build outputs
1717
_build
1818

19+
# OpenAPI documentation Artifacts
20+
reference/api/
21+
1922
# Node.js
2023
package*.json
2124

docs/Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SOURCEDIR = .
1111
BUILDDIR = _build
1212
VENVDIR = $(SPHINXDIR)/venv
1313
PA11Y = $(SPHINXDIR)/node_modules/pa11y/bin/pa11y.js --config $(SPHINXDIR)/pa11y.json
14-
VENV = $(VENVDIR)/bin/activate
14+
VENV = $(VENVDIR)/bin/activate
1515
TARGET = *
1616
ALLFILES = *.rst **/*.rst
1717
METRICSDIR = $(SOURCEDIR)/.sphinx/metrics
@@ -45,7 +45,7 @@ help:
4545
.PHONY: full-help spellcheck-install pa11y-install install run html \
4646
epub serve clean clean-doc spelling spellcheck linkcheck woke \
4747
allmetrics pa11y pdf-prep-force pdf-prep pdf vale-install vale \
48-
update
48+
fetch-openapi-docs update
4949

5050
full-help: $(VENVDIR)
5151
@. $(VENV); $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -90,12 +90,15 @@ pa11y-install:
9090

9191
install: $(VENVDIR)
9292

93-
run: install
94-
. $(VENV); $(VENVDIR)/bin/sphinx-autobuild -b dirhtml --host $(SPHINX_HOST) --port $(SPHINX_PORT) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
93+
run: install fetch-openapi-docs
94+
mkdir -p $(BUILDDIR)/reference/api
95+
. $(VENV); $(VENVDIR)/bin/sphinx-autobuild -b dirhtml --host $(SPHINX_HOST) --port $(SPHINX_PORT) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --post-build "mv $(SOURCEDIR)/reference/api/redoc-static.html $(BUILDDIR)/reference/api/redoc-static.html"
9596

9697
# Doesn't depend on $(BUILDDIR) to rebuild properly at every run.
97-
html: install
98+
html: install fetch-openapi-docs
9899
. $(VENV); $(SPHINXBUILD) -W --keep-going -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" -w $(SPHINXDIR)/warnings.txt $(SPHINXOPTS)
100+
# @mkdir -p $(BUILDDIR)/reference/api
101+
# @mv $(SOURCEDIR)/reference/api/redoc-static.html $(BUILDDIR)/reference/api/redoc-static.html
99102

100103
epub: install
101104
. $(VENV); $(SPHINXBUILD) -b epub "$(SOURCEDIR)" "$(BUILDDIR)" -w $(SPHINXDIR)/warnings.txt $(SPHINXOPTS)
@@ -109,6 +112,7 @@ clean: clean-doc
109112
rm -rf $(SPHINXDIR)/node_modules/
110113
rm -rf $(SPHINXDIR)/styles
111114
rm -rf $(VALE_CONFIG)
115+
rm -rf $(SOURCEDIR)/reference/api
112116

113117
clean-doc:
114118
git clean -fx "$(BUILDDIR)"
@@ -155,6 +159,15 @@ vale-spelling: vale-install
155159
@. $(VENV); vale --config="$(VALE_CONFIG)" --filter='$(SPHINXDIR)/styles/spelling.filter' --glob='*.{md,rst}' $(TARGET)
156160
@cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt && rm $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt
157161

162+
fetch-openapi-docs: $(SOURCEDIR)/reference/api/index.html
163+
164+
$(SOURCEDIR)/reference/api/index.html:
165+
@mkdir -p $(SOURCEDIR)/reference/api
166+
@echo "Downloading OpenAPI docs from canonical/snapd-rest-openapi..."
167+
@LATEST_RUN_ID=$$(gh run list -R canonical/snapd-rest-openapi --workflow redocly.yaml --limit 1 --json databaseId -q '.[0].databaseId'); \
168+
gh run download $$LATEST_RUN_ID -R canonical/snapd-rest-openapi -n api-docs -D $(SOURCEDIR)/reference/api
169+
@echo "OpenAPI docs downloaded to $(SOURCEDIR)/reference/api"
170+
158171
pdf-prep: install
159172
@for packageName in $(REQPDFPACKS); do (dpkg-query -W -f='$${Status}' $$packageName 2>/dev/null | \
160173
grep -c "ok installed" >/dev/null && echo "Package $$packageName is installed") && continue || \

docs/reference/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Deepen your understanding of how snaps can run on all kinds of devices, in all k
2424
Extend snap functionality with API access and customised environments for your applications and devices.
2525

2626
* [Environment variables](/reference/development/environment-variables): Internal values accessible to snapped applications.
27-
* [Snapd REST API](/reference/development/rest-api/snapd-rest-api): Provides access to snapd’s state and many of its key functions.
27+
* <a href="api/redoc-static.html">Snapd REST API</a>: Interactive OpenAPI documentation for the Snapd REST API.
2828
* [REST API error codes](/reference/development/rest-api/error-responses): The types of errors returned by the API.
2929

3030
YAML schemas define exactly what a device, kernel and snap is capable of.

0 commit comments

Comments
 (0)