Skip to content

Commit d2333c2

Browse files
vmdefclaude
andcommitted
[docs] Render the Moodle Marketplace API reference with Redocusaurus
Replace the hand-written Moodle Marketplace API guide with a reference generated from the Marketplace OpenAPI spec using Redocusaurus. The spec is fetched from the Marketplace on every start and build, so the reference stays up to date. A copy is committed in static/ and used if the Marketplace is unreachable. Site-relative links in the spec are rewritten to point to the Marketplace. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 54957e7 commit d2333c2

10 files changed

Lines changed: 1572 additions & 253 deletions

File tree

‎docusaurus.config.js‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import MoodleBannerRemark from './src/remark/moodleBanner.js';
2121
import TrackerLinksRemark from './src/remark/trackerLinks.js';
2222
import UnversionedDocsLinksRemark from './src/remark/unversionedDocsLinks.js';
2323
import * as nextVersion from './nextVersion.js';
24+
import { updateMarketplaceApiSpec } from './src/utils/marketplaceApiSpec.js';
2425

2526
// eslint-disable global-require
2627

@@ -122,6 +123,25 @@ const config = {
122123
},
123124
}),
124125
],
126+
127+
// Moodle Marketplace API reference.
128+
// Rendered with Redoc in general/community/plugincontribution/moodlemarketplaceapi.mdx.
129+
// The spec is refreshed from the Marketplace on every build (see the default export below).
130+
[
131+
'redocusaurus',
132+
{
133+
specs: [
134+
{
135+
id: 'marketplace-api',
136+
spec: 'static/marketplace-api/openapi.json',
137+
url: '/marketplace-api/openapi.json',
138+
},
139+
],
140+
theme: {
141+
primaryColor: '#bd5b00',
142+
},
143+
},
144+
],
125145
],
126146

127147
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
@@ -241,4 +261,10 @@ const config = {
241261
],
242262
};
243263

244-
export default config;
264+
export default async function createConfig() {
265+
// Keep the Marketplace API reference up to date.
266+
// The committed copy is used if the Marketplace is unreachable.
267+
await updateMarketplaceApiSpec();
268+
269+
return config;
270+
}

‎general/community/plugincontribution/moodlemarketplaceapi.md‎

Lines changed: 0 additions & 232 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Moodle Marketplace API
3+
sidebar_position: 2
4+
sidebar_label: Moodle Marketplace API
5+
hide_title: true
6+
hide_table_of_contents: true
7+
description: Reference documentation for the Moodle Marketplace API.
8+
tags:
9+
- Guidelines for contributors
10+
- Plugins
11+
- Plugin documentation
12+
- Moodle Marketplace
13+
---
14+
15+
import ApiDocMdx from '@theme/ApiDocMdx';
16+
17+
<ApiDocMdx id="marketplace-api" />

‎general/community/plugincontribution/pluginsdirectory/api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tags:
99

1010
:::warning
1111

12-
This page describes the Plugins Directory API, not [Moodle Marketplace APIs](general/community/plugincontribution/moodlemarketplaceapi.md).
12+
This page describes the Plugins Directory API, not [Moodle Marketplace APIs](../moodlemarketplaceapi.mdx).
1313

1414
For current Moodle Marketplace documentation, see [Moodle Marketplace documentation](https://moodle.atlassian.net/wiki/external/YTI4MmY4MWU2MDQyNDk5MTllZWY4YTBiNjA5ZDRjNWY).
1515

‎package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
"@docusaurus/faster": "^3.10.2",
3737
"@docusaurus/plugin-pwa": "^3.10.2",
3838
"@docusaurus/preset-classic": "^3.10.2",
39+
"@docusaurus/theme-common": "^3.10.2",
3940
"@docusaurus/theme-mermaid": "^3.10.2",
41+
"@docusaurus/utils": "^3.10.2",
4042
"@emotion/react": "^11.10.5",
4143
"@emotion/styled": "^11.10.5",
4244
"@mdx-js/react": "^3.0.0",
@@ -58,6 +60,7 @@
5860
"react": "19",
5961
"react-dom": "19",
6062
"react-player": "^2.16.0",
63+
"redocusaurus": "^2.5.2",
6164
"unist-util-find": "^3.0.0",
6265
"unist-util-visit": "^5.0.0"
6366
},

‎src/css/custom.css‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ html {
143143
footer.theme-doc-footer .theme-doc-footer-edit-meta-row {
144144
position: sticky;
145145
bottom: 0;
146+
147+
/* Stay above positioned page content, such as the Redoc API reference. */
148+
z-index: 2;
146149
background-color: var(--ifm-background-color);
147150
margin-top: 0.5rem;
148151
padding-top: 0.5rem;
@@ -170,3 +173,13 @@ ul ol {
170173
.roadmap-table table tbody tr:nth-child(3) { background-color: #fef7c8; }
171174
.roadmap-table table tbody tr:nth-child(4) { background-color: #ffeceb; }
172175
.roadmap-table table tbody tr:nth-child(5) { background-color: #f8eefe; }
176+
177+
/* Show the Redoc menu on the right, like the table of contents on other pages. */
178+
.redocusaurus .redoc-wrap {
179+
flex-direction: row-reverse;
180+
}
181+
182+
.redocusaurus .menu-content {
183+
border-right: none;
184+
border-left: 1px solid var(--ifm-toc-border-color);
185+
}

0 commit comments

Comments
 (0)