Skip to content

Docs: Add API Reference as top-level nav #2180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/docs-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
- name: Generate Helm Chart Index
run: python ./scripts/generate-helm-index.py > ./frontend/docs/docs/helm-repo/index.yaml

- name: Copy Docs Files
run: frontend/docs/copy-api-docs.sh
env:
DOCS_SOURCE_URL: https://app.browsertrix.com
ENABLE_ANALYTICS: true

- name: Build Docs
run: cd frontend/docs; mkdocs gh-deploy --force
env:
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN pip install mkdocs-material
COPY --link ./docs/mkdocs.yml .
COPY --link ./docs/docs ./docs

RUN mkdocs build
RUN API_DOCS_URL=/api/redoc mkdocs build

FROM docker.io/library/nginx:1.23.2

Expand Down
15 changes: 15 additions & 0 deletions frontend/docs/copy-api-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
CURR=$(dirname "${BASH_SOURCE[0]}")

TARGET=$CURR/docs/api/
mkdir $TARGET
curl "$DOCS_SOURCE_URL/api/openapi.json" > $TARGET/openapi.json
curl "$DOCS_SOURCE_URL/api/redoc" > $TARGET/index.html
curl "$DOCS_SOURCE_URL/docs-logo.svg" > $TARGET/../docs-logo.svg

if [ -n $ENABLE_ANALYTICS ]; then
SCRIPT_1=' <script defer data-domain=\"docs.browsertrix.com\" src=\"https://p.webrecorder.net/js/script.outbound-links.js\"></script>'
SCRIPT_2=' <script>window.plausible = window.plausible || function () { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>'
awk "1;/<head>/{ print \"$SCRIPT_1\"; print \"$SCRIPT_2\" }" $TARGET/index.html > $TARGET/index.html.new
mv $TARGET/index.html.new $TARGET/index.html
fi
Comment on lines +10 to +15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little messy but it looks like we'd have to fork redoc's html template to do this when building it, so whatever

1 change: 1 addition & 0 deletions frontend/docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Docs are organized into the following sections:
- [User Guide](./user-guide/index.md) — Instructions on how to use Browsertrix to create and share web archives.
- [Self-Hosting](./deploy/index.md) — Instructions on how to install, set up, and deploy self-hosted Browsertrix.
- [Development](./develop/index.md) — Contribute to the open source development of Browsertrix software.
- [API Reference](/api) - Full API reference for interacting with the Browsertrix backend.

If you have feedback on the docs, please feel free to [reach out to us](mailto:docs-feedback@webrecorder.net).

Expand Down
3 changes: 3 additions & 0 deletions frontend/docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ nav:
- develop/localization.md
- develop/docs.md

- API Reference: !ENV [ API_DOCS_URL, "/api/" ]


markdown_extensions:
- toc:
toc_depth: 3
Expand Down
Loading