|
| 1 | +/** |
| 2 | + * Dynamic Infra Providers Generator |
| 3 | + * |
| 4 | + * Automatically discovers and generates infrastructure provider pages from the llm-d repository. |
| 5 | + * This syncs provider-specific documentation for deploying llm-d on different infrastructure. |
| 6 | + * |
| 7 | + * Infra provider docs are synced from the specific release version defined in components-data.yaml, |
| 8 | + * not from the main branch. This ensures documentation matches the released version. |
| 9 | + */ |
| 10 | + |
| 11 | +import { createContentWithSource } from '../utils.js'; |
| 12 | +import { findRepoConfig, RELEASE_INFO } from '../component-configs.js'; |
| 13 | +import { getRepoTransform } from '../repo-transforms.js'; |
| 14 | + |
| 15 | +// Get repository configuration for the main llm-d repo |
| 16 | +const repoConfig = findRepoConfig('llm-d'); |
| 17 | + |
| 18 | +// Use the release version from YAML instead of the branch |
| 19 | +const releaseVersion = RELEASE_INFO.version; |
| 20 | +const repoUrl = `https://github.com/${repoConfig.org}/${repoConfig.name}`; |
| 21 | +const sourceBaseUrl = `https://raw.githubusercontent.com/${repoConfig.org}/${repoConfig.name}/${releaseVersion}/`; |
| 22 | + |
| 23 | +// Create a custom transform that uses the release version instead of 'main' |
| 24 | +const transform = getRepoTransform(repoConfig.org, repoConfig.name); |
| 25 | +const contentTransform = (content, sourcePath) => transform(content, { |
| 26 | + repoUrl, |
| 27 | + branch: releaseVersion, // Use release version, not 'main' |
| 28 | + org: repoConfig.org, |
| 29 | + name: repoConfig.name, |
| 30 | + sourcePath |
| 31 | +}); |
| 32 | + |
| 33 | +/** |
| 34 | + * Configuration for infrastructure providers |
| 35 | + * These are the provider-specific README.md files in docs/infra-providers/ |
| 36 | + * with their descriptive titles and sidebar positions |
| 37 | + */ |
| 38 | +const INFRA_PROVIDERS = [ |
| 39 | + { |
| 40 | + dirName: 'aks', |
| 41 | + title: 'Azure Kubernetes Service', |
| 42 | + description: 'Deploy llm-d on Azure Kubernetes Service', |
| 43 | + sidebarPosition: 1 |
| 44 | + }, |
| 45 | + { |
| 46 | + dirName: 'digitalocean', |
| 47 | + title: 'DigitalOcean Kubernetes Service (DOKS)', |
| 48 | + description: 'Deploy llm-d on DigitalOcean Kubernetes Service (DOKS)', |
| 49 | + sidebarPosition: 2 |
| 50 | + } |
| 51 | +]; |
| 52 | + |
| 53 | +/** |
| 54 | + * Create plugin configurations for all infra providers |
| 55 | + */ |
| 56 | +function createInfraProviderPlugins() { |
| 57 | + const plugins = []; |
| 58 | + |
| 59 | + // Add individual provider pages |
| 60 | + INFRA_PROVIDERS.forEach((provider) => { |
| 61 | + const sourceFile = `docs/infra-providers/${provider.dirName}/README.md`; |
| 62 | + |
| 63 | + plugins.push([ |
| 64 | + 'docusaurus-plugin-remote-content', |
| 65 | + { |
| 66 | + name: `infra-provider-${provider.dirName}`, |
| 67 | + sourceBaseUrl, |
| 68 | + outDir: 'docs/guide/InfraProviders', |
| 69 | + documents: [sourceFile], |
| 70 | + noRuntimeDownloads: false, |
| 71 | + performCleanup: true, |
| 72 | + |
| 73 | + modifyContent(filename, content) { |
| 74 | + if (filename === sourceFile) { |
| 75 | + return createContentWithSource({ |
| 76 | + title: provider.title, |
| 77 | + description: provider.description, |
| 78 | + sidebarLabel: provider.title, |
| 79 | + sidebarPosition: provider.sidebarPosition, |
| 80 | + filename: sourceFile, |
| 81 | + newFilename: `${provider.dirName}.md`, |
| 82 | + repoUrl, |
| 83 | + branch: releaseVersion, |
| 84 | + content, |
| 85 | + contentTransform |
| 86 | + }); |
| 87 | + } |
| 88 | + return undefined; |
| 89 | + }, |
| 90 | + }, |
| 91 | + ]); |
| 92 | + }); |
| 93 | + |
| 94 | + return plugins; |
| 95 | +} |
| 96 | + |
| 97 | +// Export all infra provider plugins |
| 98 | +export default createInfraProviderPlugins(); |
| 99 | + |
0 commit comments