Adding redoc / tsoa generated API docs. (#451)

* Adding redoc / tsoa generated API docs.

* Adding other submodules.

* Adding multiple versions os API docs at /api/next, and /api/latest .

- Fixes #452

* Fixing prettier check.

* Fixing eslint.

* Use main and v0.19 instead of latest and next.

* Updating lemmy-docs to show not available.

* Remove TODOs.

* Switching from tsoa_1 branch to main of lemmy-js-client.
This commit is contained in:
Dessalines 2025-01-28 05:04:57 -05:00 committed by GitHub
parent 38ad15408d
commit e6e046eed3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 53 additions and 15 deletions

8
.gitmodules vendored
View file

@ -10,10 +10,14 @@
path = lemmy-translations
url = https://github.com/lemmynet/lemmy-translations
branch = main
[submodule "lemmy-js-client"]
path = lemmy-js-client
[submodule "lemmy-js-client-v0.19"]
path = lemmy-js-client-v0.19
url = https://github.com/LemmyNet/lemmy-js-client
branch = release/v0.19
[submodule "lemmy-js-client-main"]
path = lemmy-js-client-main
url = https://github.com/LemmyNet/lemmy-js-client
branch = main
[submodule "lemmy-stats-crawler"]
path = lemmy-stats-crawler
url = https://github.com/LemmyNet/lemmy-stats-crawler.git

View file

@ -21,7 +21,7 @@ steps:
prettier_markdown_check:
image: tmknom/prettier:3.2.5
commands:
- prettier -c . "!dist" "!lemmy-docs" "!lemmy-translations" "!joinlemmy-translations" "!lemmy-js-client" "!lemmy-stats-crawler" "!src/shared/instance_stats.ts" "!src/shared/donation_stats.ts" "!pnpm-lock.yaml"
- prettier -c . "!dist" "!lemmy-docs" "!lemmy-translations" "!joinlemmy-translations" "!lemmy-js-client-v0.19" "!lemmy-js-client-main" "!lemmy-stats-crawler" "!src/shared/instance_stats.ts" "!src/shared/donation_stats.ts" "!pnpm-lock.yaml"
when:
- event: pull_request

View file

@ -14,14 +14,25 @@ RUN tar -xzf mdbook.tar.gz
COPY lemmy-docs ./lemmy-docs
RUN ./mdbook build lemmy-docs -d ../docs
# Build the typedoc API docs
FROM node:20-alpine AS api
# Build the typedoc lemmy-js-client docs, and swagger.json
FROM node:20-alpine AS api_v0.19
WORKDIR /app
COPY lemmy-js-client lemmy-js-client
COPY lemmy-js-client-v0.19 lemmy-js-client
WORKDIR /app/lemmy-js-client
RUN corepack enable pnpm
RUN pnpm i
RUN pnpm run docs
# OpenAPI isn't currently working for the v0.19 docs, so no pnpm tsoa
# Do the same for the api docs, but on main
FROM node:20-alpine AS api_main
WORKDIR /app
COPY lemmy-js-client-main lemmy-js-client
WORKDIR /app/lemmy-js-client
RUN corepack enable pnpm
RUN pnpm i
RUN pnpm run docs
RUN pnpm tsoa
# Build the isomorphic app
FROM node:20-alpine AS builder
@ -48,9 +59,11 @@ COPY joinlemmy-translations joinlemmy-translations
COPY lemmy-translations lemmy-translations
COPY src src
# Copy the docs and API
# Copy the rust docs, lemmy-js-client docs, and OpenAPI docs.
COPY --from=docs /app/docs ./src/assets/docs
COPY --from=api /app/lemmy-js-client/docs ./src/assets/api
COPY --from=api_v0.19 /app/lemmy-js-client/docs ./src/assets/lemmy-js-client-v0.19-docs
COPY --from=api_main /app/lemmy-js-client/docs ./src/assets/lemmy-js-client-main-docs
COPY --from=api_main /app/lemmy-js-client/redoc-static.html ./src/assets/api_main.html
RUN pnpm i
RUN pnpm prebuild:prod

View file

@ -31,7 +31,8 @@ export default [
"crawl.mjs",
"generate_rss_feed.mjs",
"generate_translations.mjs",
"lemmy-js-client",
"lemmy-js-client-main",
"lemmy-js-client-v0.19",
"webpack.config.js",
"tailwind.config.js",
"src/shared/build-config.js",

@ -1 +1 @@
Subproject commit cdec211a960139e7f477b3dfbd861849721b9e9d
Subproject commit 78d242413b70ca50032fb13fa840478aeb94b0ce

@ -1 +1 @@
Subproject commit fd75c843211dff9437a6c8aea4a360e090ce73cf
Subproject commit abb0f7d09f425bbb784fad940cf04efd8c7fcee4

@ -1 +0,0 @@
Subproject commit 5b3c7ebcfa7bc9598254999b72b9ec89007bd51e

1
lemmy-js-client-main Submodule

@ -0,0 +1 @@
Subproject commit 4a24cb1f62b825f54dd9f826557b5fd38090c2e3

1
lemmy-js-client-v0.19 Submodule

@ -0,0 +1 @@
Subproject commit 81dc69449f2ced9dd5a32ca13e55c1bd93a4e775

@ -1 +1 @@
Subproject commit ec65b0e65eec61f05b9c4fbdeaaabc907131a20e
Subproject commit e2e70155f32d59099fb9cd0f7e75011a44a421b8

@ -1 +1 @@
Subproject commit 61ca6bdfc1755a4ae4d0693b3296cba38ad4cae2
Subproject commit 30a97d394b5c83c398afd459b71f3f38e5c93e4d

View file

@ -26,7 +26,26 @@ server.use(express.json() as RequestHandler);
server.use(express.urlencoded({ extended: false }) as RequestHandler);
server.use("/static", express.static(path.resolve("./dist")));
server.use("/docs", express.static(path.resolve("./dist/assets/docs")));
server.use("/api", express.static(path.resolve("./dist/assets/api")));
// The v0.19 release docs
server.use(
"/api/v0.19",
express.static(path.resolve("./dist/assets/lemmy-js-client-v0.19-docs")),
);
server.use(
"/lemmy-js-client-docs/v0.19",
express.static(path.resolve("./dist/assets/lemmy-js-client-v0.19-docs")),
);
// The main release docs
server.use(
"/api/main",
express.static(path.resolve("./dist/assets/api_main.html")),
);
server.use(
"/lemmy-js-client-docs/main",
express.static(path.resolve("./dist/assets/lemmy-js-client-main-docs")),
);
server.use(
"/context.json",
cors,