/ docs / scripts / update-api-modules.ts
update-api-modules.ts
 1  import * as fs from 'fs';
 2  import path, { basename } from 'path';
 3  
 4  const PYTHON_API_PATH = 'api_reference/source/python_api/';
 5  const files = fs.readdirSync(PYTHON_API_PATH, { withFileTypes: false });
 6  const fileMap = {};
 7  
 8  files.forEach((file) => {
 9    if (file.startsWith('mlflow') && file.endsWith('.rst')) {
10      const filename = basename(file, '.rst');
11      // the eventual website path
12      fileMap[filename] = 'api_reference/python_api/' + filename + '.html';
13    }
14  });
15  
16  // manual mapping for auth since it's a special case in the docs hierarchy
17  fileMap['mlflow.server.auth'] = 'api_reference/auth/python-api.html';
18  fileMap['mlflow.server.cli'] = 'api_reference/cli.html';
19  fileMap['mlflow.r'] = 'api_reference/R-api.html';
20  fileMap['mlflow.java'] = 'api_reference/java_api/index.html';
21  fileMap['mlflow.python'] = 'api_reference/python_api/index.html';
22  fileMap['mlflow.rest'] = 'api_reference/rest-api.html';
23  fileMap['mlflow.typescript'] = 'api_reference/typescript_api/index.html';
24  fileMap['mlflow.llms.deployments.api'] = 'api_reference/llms/deployments/api.html';
25  
26  // write filemap to json file
27  fs.writeFileSync('src/api_modules.json', JSON.stringify(fileMap, null, 2));