Add api page #32

Merged
lunny merged 39 commits from HesterG/gitea-docusaurus:add-api-page into main 2023-07-05 03:54:55 +00:00
Member

Changes

  • Added redocusaurus package to display swagger api with reference to woodpecker
  • Change sed for swagger.json for proper version and baseurl.
  • Add a dropdown for different api versions. (screenshot below)
  • On API pages, only API version dropdown will show(hide locale dropdown, version dropdown for doc, and doc search)
  • Allow build CSR API pages for development so it saves building time.

Screenshots

Screen Shot 2023-06-27 at 11.56.59

Screen Shot 2023-06-27 at 10.58.11

Screen Shot 2023-06-21 at 12.26.26

Screen Shot 2023-06-19 at 16.34.33

Search:

Screen Shot 2023-06-21 at 14.49.15

# Changes - Added [redocusaurus](https://github.com/rohit-gohri/redocusaurus) package to display swagger api with reference to [woodpecker](https://github.com/woodpecker-ci/woodpecker/tree/master/docs) - Change `sed` for swagger.json for proper version and baseurl. - Add a dropdown for different api versions. (screenshot below) - On API pages, only API version dropdown will show(hide locale dropdown, version dropdown for doc, and doc search) - Allow build CSR API pages for development so it saves building time. # Screenshots ![Screen Shot 2023-06-27 at 11.56.59](/attachments/7f43976d-f9f1-42ff-85f5-0bc84e549441) ![Screen Shot 2023-06-27 at 10.58.11](/attachments/bde25da5-b0a6-4908-9c69-c6aed41f8f59) ![Screen Shot 2023-06-21 at 12.26.26](/attachments/84a9bf5a-229b-4031-9654-3bae6cb3301a) ![Screen Shot 2023-06-19 at 16.34.33](/attachments/653b2b59-bc8a-4e6c-82f2-eb9710f55d8d) Search: ![Screen Shot 2023-06-21 at 14.49.15](/attachments/3a09bd89-36a8-4156-a2df-2d3176d3ddb1)
HesterG added 3 commits 2023-06-14 04:00:18 +00:00
adjust style
All checks were successful
checks / build-docs (pull_request) Successful in 6m16s
1fba8113e4
HesterG force-pushed add-api-page from 1fba8113e4 to bf6a012c65 2023-06-14 07:20:27 +00:00 Compare
HesterG added 1 commit 2023-06-14 08:06:13 +00:00
Merge branch 'main' into add-api-page
All checks were successful
checks / build-docs (pull_request) Successful in 6m34s
5b237ae201
HesterG added 1 commit 2023-06-14 08:38:01 +00:00
update
Some checks failed
checks / build-docs (pull_request) Failing after 5m6s
d189638a19
HesterG added 1 commit 2023-06-14 09:35:01 +00:00
update
Some checks failed
checks / build-docs (pull_request) Failing after 1m3s
fb4523d478
HesterG added 1 commit 2023-06-14 09:43:08 +00:00
fix typo
Some checks failed
checks / build-docs (pull_request) Failing after 1m1s
ec0f6f1407
HesterG added 1 commit 2023-06-14 09:51:01 +00:00
typo
Some checks failed
checks / build-docs (pull_request) Failing after 5m7s
eceb2bac9f
HesterG added 2 commits 2023-06-14 10:03:36 +00:00
try add one api
All checks were successful
checks / build-docs (pull_request) Successful in 6m41s
05e01c455f
HesterG added 1 commit 2023-06-14 10:12:27 +00:00
try two api
Some checks failed
checks / build-docs (pull_request) Failing after 7m5s
236d0f8da1
HesterG added 1 commit 2023-06-14 10:26:04 +00:00
use online 1.20rc api
All checks were successful
checks / build-docs (pull_request) Successful in 6m21s
6946cbcda0
HesterG added 1 commit 2023-06-15 00:41:46 +00:00
try remove tmp and add spec
Some checks failed
checks / build-docs (pull_request) Failing after 7m16s
86cb069acf
HesterG added 1 commit 2023-06-15 01:48:51 +00:00
back to online doc
All checks were successful
checks / build-docs (pull_request) Successful in 6m17s
64f7420ab8
techknowlogick requested review from jolheiser 2023-06-16 04:38:05 +00:00
HesterG force-pushed add-api-page from 64f7420ab8 to 6dd6afb61d 2023-06-21 05:04:12 +00:00 Compare
HesterG added 1 commit 2023-06-21 05:56:18 +00:00
update for mobile
All checks were successful
checks / build-docs (pull_request) Successful in 7m3s
35043dc5ed
HesterG added 1 commit 2023-06-21 05:58:46 +00:00
Merge branch 'main' into add-api-page
All checks were successful
checks / build-docs (pull_request) Successful in 7m8s
cbb2070624
HesterG added 1 commit 2023-06-21 10:25:08 +00:00
update
Some checks failed
checks / build-docs (pull_request) Failing after 7m12s
ce9b3042bf
HesterG added 1 commit 2023-06-21 10:42:26 +00:00
try
Some checks failed
checks / build-docs (pull_request) Failing after 4m44s
a286e2c12e
HesterG added 1 commit 2023-06-21 10:45:14 +00:00
larger
All checks were successful
checks / build-docs (pull_request) Successful in 7m13s
e8367f856b
HesterG added 1 commit 2023-06-21 10:48:32 +00:00
remove remote
All checks were successful
checks / build-docs (pull_request) Successful in 7m5s
ebed46be67
HesterG added 1 commit 2023-06-21 10:55:04 +00:00
try 3
Some checks failed
checks / build-docs (pull_request) Failing after 24m43s
43f57905c5
HesterG added 1 commit 2023-06-21 10:57:43 +00:00
update publish
Some checks failed
checks / build-docs (pull_request) Failing after 17m5s
9450fac8d0
HesterG added 1 commit 2023-06-21 11:03:05 +00:00
rename label
Some checks failed
checks / build-docs (pull_request) Failing after 1h6m43s
0757001822
HesterG added 1 commit 2023-06-21 11:27:22 +00:00
back to 2
Some checks failed
checks / build-docs (pull_request) Failing after 17m26s
fe9c655e47
HesterG added 1 commit 2023-06-21 11:36:22 +00:00
revert
All checks were successful
checks / build-docs (pull_request) Successful in 7m42s
d9d78167e6
Owner

I get a JS OOM running this as well.
I'm not sure if that is a docusaurus issue or what, but it seems strange for the process to not be able to handle it.

I get a JS OOM running this as well. I'm not sure if that is a docusaurus issue or what, but it seems strange for the process to not be able to handle it.
Member

Add export NODE_OPTIONS="--max-old-space-size=4096" to Makefile to give v8 4GB heap size. IIRC, node by default still only allocates 2GB heap size for v8, which is too little for some of the more involved JS build processes.

Add `export NODE_OPTIONS="--max-old-space-size=4096"` to Makefile to give v8 4GB heap size. IIRC, node by default still only allocates 2GB heap size for v8, which is too little for some of the more involved JS build processes.
silverwind reviewed 2023-06-22 19:06:15 +00:00
@ -33,4 +33,5 @@ jobs:
- name: build site
run: |
npm ci
export NODE_OPTIONS="--max-old-space-size=8192"
Member

Move it to Makefile so everyone benefits, not just actions. Also, 4096 is likely already sufficient as it doubles the default value.

Move it to Makefile so everyone benefits, not just actions. Also, 4096 is likely already sufficient as it doubles the default value.
Author
Member

I moved this to install necessary tools step for now, because I am not very sure where this should be put inside makefile, do you have a suggestion?

Update:

Looks like export is not working if moved to install necessary tools step, so reverted it.

I moved this to `install necessary tools` step for now, because I am not very sure where this should be put inside makefile, do you have a suggestion? Update: Looks like export is not working if moved to `install necessary tools` step, so reverted it.
Member

I don't know the specifics of this projects, but Makefile should be the single entry point for all activities, so it seems only logical to me to either export it there, or do the more cautious variant of only setting it per command, e.g.

NODE_OPTIONS="--max-old-space-size=8192" npx ...
I don't know the specifics of this projects, but `Makefile` should be the single entry point for all activities, so it seems only logical to me to either export it there, or do the more cautious variant of only setting it per command, e.g. ``` NODE_OPTIONS="--max-old-space-size=8192" npx ... ```
Author
Member

I see, I changed the npm run build into using make so it worked as expected.

I see, I changed the `npm run build` into using `make` so it worked as expected.
HesterG marked this conversation as resolved
Owner

Got it to build with the suggestion from silverwind.

This is really cool, I had to add a few things to the Makefile now that we have 1.21-dev, so my local server had three API docs to build.

I'm not sure how many we plan to have at once, but I have to say it was a very slow build and it chugged. Overall I like the idea to have the swagger info in the docs, but at least on my (admittedly older) machine it makes the build process a bit more painful.

Is there any way to make this an "optional" part of the build? That would at least make DX a bit easier.

Got it to build with the suggestion from silverwind. This is really cool, I had to add a few things to the Makefile now that we have 1.21-dev, so my local server had three API docs to build. I'm not sure how many we plan to have at once, but I have to say it was a very slow build and it _chugged_. Overall I like the idea to have the swagger info in the docs, but at least on my (admittedly older) machine it makes the build process a bit more painful. Is there any way to make this an "optional" part of the build? That would at least make DX a bit easier.
HesterG added 1 commit 2023-06-26 01:04:29 +00:00
Merge branch 'main' into add-api-page
All checks were successful
checks / build-docs (pull_request) Successful in 9m25s
fb675efcb1
HesterG added 1 commit 2023-06-26 09:47:30 +00:00
add no-api option and change position
Some checks failed
checks / build-docs (pull_request) Failing after 7m5s
c62e7b8c35
Author
Member

Got it to build with the suggestion from silverwind.

This is really cool, I had to add a few things to the Makefile now that we have 1.21-dev, so my local server had three API docs to build.

I'm not sure how many we plan to have at once, but I have to say it was a very slow build and it chugged. Overall I like the idea to have the swagger info in the docs, but at least on my (admittedly older) machine it makes the build process a bit more painful.

Is there any way to make this an "optional" part of the build? That would at least make DX a bit easier.

Hi, I added options for start and build steps in c62e7b8c35, so if do npm run start-noapi or npm run build-noapi, the api building step will be skipped. Please review if this is a proper way to do so, thanks.

> Got it to build with the suggestion from silverwind. > > This is really cool, I had to add a few things to the Makefile now that we have 1.21-dev, so my local server had three API docs to build. > > I'm not sure how many we plan to have at once, but I have to say it was a very slow build and it _chugged_. Overall I like the idea to have the swagger info in the docs, but at least on my (admittedly older) machine it makes the build process a bit more painful. > > Is there any way to make this an "optional" part of the build? That would at least make DX a bit easier. Hi, I added options for start and build steps in https://gitea.com/gitea/gitea-docusaurus/commit/c62e7b8c3523f4db71fbfcb408896943041fde82, so if do `npm run start-noapi` or `npm run build-noapi`, the api building step will be skipped. Please review if this is a proper way to do so, thanks.
HesterG added 1 commit 2023-06-26 09:58:27 +00:00
revert position
All checks were successful
checks / build-docs (pull_request) Successful in 9m38s
03aa8112c3
HesterG added 1 commit 2023-06-26 10:08:49 +00:00
remove
All checks were successful
checks / build-docs (pull_request) Successful in 10m10s
a5988d4925
HesterG force-pushed add-api-page from a5988d4925 to 62a6115b4f 2023-06-26 10:12:19 +00:00 Compare
HesterG added 1 commit 2023-06-27 02:55:45 +00:00
use to
All checks were successful
checks / build-docs (pull_request) Successful in 7m49s
2da7a5a4c8
HesterG added 1 commit 2023-06-27 03:12:48 +00:00
change routes
All checks were successful
checks / build-docs (pull_request) Successful in 7m52s
75e6682704
HesterG added 1 commit 2023-06-27 10:23:57 +00:00
test
All checks were successful
checks / build-docs (pull_request) Successful in 8m3s
3bf654722d
Member

Also, I recommend removing all the scripts in package.json and move them to Makefile. Either use one or the other, but not both.

Also, I recommend removing all the scripts in `package.json` and move them to `Makefile`. Either use one or the other, but not both.
HesterG added 1 commit 2023-06-28 02:20:07 +00:00
change position
Some checks failed
checks / build-docs (pull_request) Failing after 5m14s
7024aedf79
HesterG added 1 commit 2023-06-28 02:31:21 +00:00
update
Some checks failed
checks / build-docs (pull_request) Failing after 5m18s
2d166f8479
HesterG added 1 commit 2023-06-28 02:52:43 +00:00
fix
All checks were successful
checks / build-docs (pull_request) Successful in 7m35s
887f545381
HesterG added 1 commit 2023-06-28 03:26:31 +00:00
change to make
All checks were successful
checks / build-docs (pull_request) Successful in 7m38s
ba178d7601
Author
Member

Also, I recommend removing all the scripts in package.json and move them to Makefile. Either use one or the other, but not both.

I think the whole tranform can be in another PR, for this one, I seperated steps in make build into make prepare-docs and make build and changed npm ci & npm run build in action yaml files to make build for the export NODE_OPTIONS in makefile to work.

Also updated README

> Also, I recommend removing all the scripts in `package.json` and move them to `Makefile`. Either use one or the other, but not both. I think the whole tranform can be in another PR, for this one, I seperated steps in `make build` into `make prepare-docs` and `make build` and changed `npm ci & npm run build` in action yaml files to `make build` for the `export NODE_OPTIONS` in `makefile` to work. Also updated README
HesterG added 1 commit 2023-06-28 04:14:51 +00:00
update for make serve
All checks were successful
checks / build-docs (pull_request) Successful in 7m53s
41b6442e09
Member

I guess I can follow up to this with the script moving.

I guess I can follow up to this with the script moving.
silverwind reviewed 2023-06-28 06:14:03 +00:00
Makefile Outdated
@ -3,3 +1,1 @@
else
SED_INPLACE := sed -i ''
endif
export NODE_OPTIONS := "--max-old-space-size=8192"
Member

Is 4096 enough to make it work? Some people might not have so much free memory and we shouldn't take more than necessary.

Is 4096 enough to make it work? Some people might not have so much free memory and we shouldn't take more than necessary.
Author
Member

I will try one

I will try one
Author
Member
It works https://gitea.com/gitea/gitea-docusaurus/actions/runs/149
HesterG marked this conversation as resolved
HesterG added 1 commit 2023-06-28 07:07:46 +00:00
try 4096
All checks were successful
checks / build-docs (pull_request) Successful in 8m51s
776cd1fd97
Author
Member

Found another way to improve api build for development:

Disable ssr and use client-only for api with reference to this discussion, but might be a bit hacky to implement:

https://gitea.com/HesterG/gitea-docusaurus/compare/add-api-page...HesterG/gitea-docusaurus:csr-api

In this implementation, if do npm run start-noapi or npm run build-noapi, api pages will be csr and so api build is skipped during build time.

Found another way to improve api build for development: Disable ssr and use client-only for api with reference to [this discussion](https://github.com/rohit-gohri/redocusaurus/discussions/88#discussioncomment-4918457), but might be a bit hacky to implement: https://gitea.com/HesterG/gitea-docusaurus/compare/add-api-page...HesterG/gitea-docusaurus:csr-api In this implementation, if do `npm run start-noapi` or `npm run build-noapi`, api pages will be csr and so api build is skipped during build time.
HesterG force-pushed add-api-page from 776cd1fd97 to d1ba4f3b62 2023-06-30 03:12:05 +00:00 Compare
HesterG added 1 commit 2023-06-30 03:14:05 +00:00
fix swagger
All checks were successful
checks / build-docs (pull_request) Successful in 8m51s
05e4aa7fc6
silverwind approved these changes 2023-06-30 17:51:17 +00:00
Author
Member

@silverwind Hi, which do you think is better for the npm run start-noapi and npm run build-noapi implementation? (These are just for developement.)

  1. Simply exclude api building step.
  2. Use csr as mentioned in #32 (comment) so that api build will not be included in build step. (I think this implementation might be a bit hacky)
@silverwind Hi, which do you think is better for the `npm run start-noapi` and `npm run build-noapi` implementation? (These are just for developement.) 1. Simply exclude api building step. 2. Use csr as mentioned in https://gitea.com/gitea/gitea-docusaurus/pulls/32#issuecomment-742323 so that api build will not be included in build step. (I think this implementation might be a bit hacky)
Member

If there is no noticeable difference whether it's server- or client-rendered, I would probably prefer client-rendered.

BTW what I don't understand about the current build: How do you obtain the JSON files? Maybe we could have a small build script that does shallow checkout on the gitea repo to obtain the swagger file for each branch?

I think the current code could use some DRY. Have a YAML config that maps versions to branches, for example:

versions:
  - name: "1.21"
    branch: main
  - name: "1.20"
    branch: release/v1.20

That way, you don't have to do so many changes in this repo when a new version releases. Also I recomment naming the swagger jsons swagger-${version.name}.json.

If there is no noticeable difference whether it's server- or client-rendered, I would probably prefer client-rendered. BTW what I don't understand about the current build: How do you obtain the JSON files? Maybe we could have a small build script that does shallow checkout on the gitea repo to obtain the swagger file for each branch? I think the current code could use some DRY. Have a YAML config that maps versions to branches, for example: ```yaml versions: - name: "1.21" branch: main - name: "1.20" branch: release/v1.20 ``` That way, you don't have to do so many changes in this repo when a new version releases. Also I recomment naming the swagger jsons `swagger-${version.name}.json`.
HesterG added 1 commit 2023-07-05 01:05:09 +00:00
rename
Some checks failed
checks / build-docs (pull_request) Failing after 2m57s
dfa2d5c9ae
HesterG added 1 commit 2023-07-05 02:20:05 +00:00
allow csr mode for api
All checks were successful
checks / build-docs (pull_request) Successful in 8m2s
9929fdcd4a
Author
Member

If there is no noticeable difference whether it's server- or client-rendered, I would probably prefer client-rendered.

I think the main difference should be SEO. But if it is just for developement, should be fine. Pushed a commit to allow render api pages by csr.

BTW what I don't understand about the current build: How do you obtain the JSON files? Maybe we could have a small build script that does shallow checkout on the gitea repo to obtain the swagger file for each branch?

They are inside prepare steps in makefile, copied from gitea. There is a step cloning the specific branch.

I think the current code could use some DRY. Have a YAML config that maps versions to branches, for example:

versions:
  - name: "1.21"
    branch: main
  - name: "1.20"
    branch: release/v1.20

I can do this in next PR.

That way, you don't have to do so many changes in this repo when a new version releases. Also I recomment naming the swagger jsons swagger-${version.name}.json.

Done

> If there is no noticeable difference whether it's server- or client-rendered, I would probably prefer client-rendered. I think the main difference should be SEO. But if it is just for developement, should be fine. Pushed a commit to allow render api pages by csr. > BTW what I don't understand about the current build: How do you obtain the JSON files? Maybe we could have a small build script that does shallow checkout on the gitea repo to obtain the swagger file for each branch? > They are inside prepare steps in `makefile`, copied from gitea. There is a step cloning the specific branch. > I think the current code could use some DRY. Have a YAML config that maps versions to branches, for example: > > ```yaml > versions: > - name: "1.21" > branch: main > - name: "1.20" > branch: release/v1.20 > ``` > I can do this in next PR. > That way, you don't have to do so many changes in this repo when a new version releases. Also I recomment naming the swagger jsons `swagger-${version.name}.json`. Done
HesterG changed title from WIP: Add api page to Add api page 2023-07-05 02:24:26 +00:00
lunny approved these changes 2023-07-05 03:54:29 +00:00
lunny merged commit 04a97d20b1 into main 2023-07-05 03:54:55 +00:00
lunny referenced this issue from a commit 2023-07-05 03:54:57 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/gitea-docusaurus#32
No description provided.