mirror of
https://github.com/longbridge/developers.git
synced 2026-09-19 03:34:09 +08:00
5accb00f24
## Summary - **Branding & version**: SDK 页与文档统一为 longbridge 品牌、版本 4.0.0,修正仓库与包地址 - **Getting started**: 更新 API Host、OAuth 示例与 4.0.0,修正 typo(开发中 → 开发者) - **Request examples**: 为所有 API 请求示例补充多语言 tabs(Python/Node/Java/Rust/C++),并增加 Go SDK 示例(en / zh-CN / zh-HK) - **Dependencies**: 更新 package.json 与 bun.lock Made with [Cursor](https://cursor.com)
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
const OAUTH_BLOCK = `oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
|
|
config = Config.from_oauth(oauth)`
|
|
|
|
function walkDir(dir, callback) {
|
|
const files = fs.readdirSync(dir)
|
|
for (const f of files) {
|
|
const p = path.join(dir, f)
|
|
if (fs.statSync(p).isDirectory()) {
|
|
walkDir(p, callback)
|
|
} else if (f.endsWith('.md')) {
|
|
callback(p)
|
|
}
|
|
}
|
|
}
|
|
|
|
walkDir(path.join(__dirname, '..', 'docs'), (filePath) => {
|
|
let content = fs.readFileSync(filePath, 'utf8')
|
|
if (!content.includes('longport.openapi') && !content.includes('Config.from_env()')) return
|
|
content = content.replace(/from longport\.openapi /g, 'from longbridge.openapi ')
|
|
content = content.replace(/config = Config\.from_env\(\)/g, OAUTH_BLOCK)
|
|
content = content.replace(
|
|
/(from longbridge\.openapi import [^\r\n]+)(\r?\n)/g,
|
|
(m, imp, nl) => (imp.includes('OAuthBuilder') ? m : imp + ', OAuthBuilder' + nl)
|
|
)
|
|
fs.writeFileSync(filePath, content, 'utf8')
|
|
console.log('Updated:', filePath)
|
|
})
|