Skip to content

Commit c36222d

Browse files
authored
Merge pull request #1217 from oasisprotocol/lw/scalar-docs
docs: Generate docs using @scalar/api-reference instead of redoc-cli
2 parents 4ac582e + 11a5357 commit c36222d

File tree

5 files changed

+71
-18
lines changed

5 files changed

+71
-18
lines changed

.changelog/1217.doc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generate docs using @scalar/api-reference instead of redoc-cli

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ tests/e2e_regression/**/rpc-cache/
2020
/logs
2121

2222
# API files.
23-
index.html
24-
api/spec/v1.html
2523
api/spec/v1.json
2624

2725
# Coverage reports.

Makefile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,9 @@ lint-go-mod-tidy:
141141

142142
lint: $(lint-targets)
143143

144-
# Documentation
145-
docs-targets := docs-api
146-
144+
# Documentation preview
147145
docs-api:
148-
@npx redoc-cli build api/spec/v1.yaml -o api/spec/v1.html
149-
150-
docs: $(docs-targets)
146+
@npx serve ./api/spec/
151147

152148
start-docker:
153149
@docker compose up --remove-orphans
@@ -241,5 +237,4 @@ release-build: codegen-go
241237
fetch-git \
242238
release-tag \
243239
$(lint-targets) lint \
244-
$(docs-targets) docs \
245240
run

api/spec/v1.html

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
6+
<script
7+
src="https://cdn.jsdelivr.net/npm/@scalar/[email protected]/dist/browser/standalone.js"
8+
integrity="sha256-6/qUfYX/AQu0WFPRVWGXdoDc7eKERmgweLT8mEjm89U="
9+
crossorigin="anonymous"
10+
></script>
11+
12+
<style>
13+
/* Big performance improvement */
14+
.section-container {
15+
contain: paint layout;
16+
content-visibility: auto;
17+
contain-intrinsic-size: 100px 600px;
18+
}
19+
.sidebar-indent-nested {
20+
contain: paint layout;
21+
content-visibility: auto;
22+
contain-intrinsic-size: 100px 32px;
23+
}
24+
.hljs > span {
25+
contain: paint layout;
26+
content-visibility: auto;
27+
contain-intrinsic-size: 16px 16px;
28+
}
29+
.scalar-code-block {
30+
contain: paint layout;
31+
content-visibility: auto;
32+
contain-intrinsic-size: 100px 600px;
33+
}
34+
35+
/* Clutters "Test Request" UI */
36+
.request-section-content-headers, .request-section-content-cookies {
37+
display: none;
38+
}
39+
</style>
40+
</head>
41+
<body>
42+
<div id="app"></div>
43+
44+
<script>
45+
(async () => {
46+
const spec = await (await fetch('./v1.yaml')).text()
47+
Scalar.createApiReference('#app', {
48+
content: spec,
49+
proxyUrl: undefined,
50+
withDefaultFonts: false,
51+
telemetry: false,
52+
hideModels: true, // It clutters sidebar
53+
defaultHttpClient: {
54+
targetKey: 'js',
55+
clientKey: 'fetch',
56+
},
57+
// Don't want to show these clients first on the list, but can not
58+
// merely move them lower. Have to disable them.
59+
hiddenClients: {
60+
ruby: ['native'],
61+
php: ['curl', 'guzzle'],
62+
node: ['undici'],
63+
},
64+
})
65+
})()
66+
</script>
67+
</body>
68+
</html>

docker/nexus/Dockerfile

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ RUN \
1212

1313
############
1414

15-
FROM node:18-slim AS openapi-builder
16-
17-
COPY api/spec /api/spec
18-
WORKDIR /
19-
RUN npx redoc-cli build api/spec/v1.yaml -o api/spec/v1.html
20-
21-
############
22-
2315
FROM golang:1.25-trixie AS nexus
2416

2517
WORKDIR /nexus
@@ -29,6 +21,5 @@ RUN apt-get update -q -q && \
2921

3022
COPY --from=nexus-builder /code/go/nexus /usr/local/bin/nexus
3123
COPY --from=nexus-builder /code/go/ /nexus
32-
COPY --from=openapi-builder /api/spec/v1.html api/spec/v1.html
3324

3425
ENTRYPOINT ["nexus"]

0 commit comments

Comments
 (0)