diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f7254dd..ddf9658 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,8 @@ mise run install [`sources.yml`](sources.yml) lists each source repository, where it's mounted, and which tags to publish; `dev` is a branch built as an extra, unreleased -version. The assembler ([`assembler/`](assembler/)) fetches only the docs +version. A version with `local: ` instead of a `ref` is built from that +directory in this repo; the SDK placeholders in [`stubs/`](stubs/) use it. The assembler ([`assembler/`](assembler/)) fetches only the docs directory at each ref, reads it in its own format (Fern `index.yml`, mdBook `SUMMARY.md`, or `docset.yml`), and writes the Starlight content, navigation, and Markdown copies. The commits it used are recorded in diff --git a/README.md b/README.md index 1ddf1f8..b5abc15 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ the docs, such as the landing page, in [`website/`](website/). | Docset | Repository | Path | Dev branch | | --------- | ------------------------------------------------------------------- | ----------- | ---------- | | OpenShell | [ai-openshell/openshell](https://github.com/ai-openshell/openshell) | `docs/` | `main` | +| Go SDK | [ai-openshell/sdk-go](https://github.com/ai-openshell/sdk-go) | `docs/src/` | `main` | ## How it works @@ -27,6 +28,9 @@ at `/docs/`, all with one site bar and one search. Every page also has a Markdown copy for agents at its URL plus `.md`. The site is hosted on Netlify under the CNCF's account. +The Python, TypeScript, and Rust SDKs have placeholder pages from +[`stubs/`](stubs/) until their docs move out of the core docs. + To publish a new release, add its tag to `sources.yml`. ## Run it locally diff --git a/assembler/assemble.mjs b/assembler/assemble.mjs index 3d76fd2..d1d6d66 100644 --- a/assembler/assemble.mjs +++ b/assembler/assemble.mjs @@ -97,9 +97,12 @@ for (const [id, src] of Object.entries(manifest.sources)) { src, name: v.name ?? v.ref.replace(/^v/, ''), dev: false, - repo: v.repo ?? src.repo, - ref: v.ref, - subdir: v.path ?? src.path, + // A version can come from a directory in this repo (`local`) instead of + // a fetched ref, such as a placeholder for a docset with no docs yet. + repo: v.local ? manifest.site.repo : (v.repo ?? src.repo), + ref: v.local ? 'local' : v.ref, + subdir: v.local ? '' : (v.path ?? src.path), + local: v.local && path.join(root, v.local), }); const own = wanted.filter((w) => w.id === id); (own.find((w) => !w.dev) ?? own[0]).latest = true; diff --git a/sources.yml b/sources.yml index a9d3aaa..8db2536 100644 --- a/sources.yml +++ b/sources.yml @@ -8,7 +8,9 @@ # records the commit in build/sources.lock.json. # # Every source has its own versions, newest first. The first one is "latest". -# `dev` (optional) is a branch built as an extra, unreleased version. +# `dev` (optional) is a branch built as an extra, unreleased version. A version +# with `local: ` instead of a `ref` is built from that directory in this +# repo. # # The newest release is published at //, with no version in the # URL; every other version at ///. //latest/ @@ -31,6 +33,11 @@ topics: - id: core label: Core sources: [core] + - id: sdks + label: SDKs + description: Client libraries for the OpenShell gateway API. + intro: topics/sdks.mdx + sources: [sdk-go, sdk-python, sdk-typescript, sdk-rust] sources: core: @@ -44,3 +51,39 @@ sources: - { name: "0.1.9", ref: v0.1.9 } - { name: "0.1.8", ref: v0.1.8 } - { name: "0.1.7", ref: v0.1.7 } + + sdk-go: + title: Go SDK + description: Go client for services and command-line tools. + mount: sdks/go + repo: ai-openshell/sdk-go + path: docs/src + dev: { ref: main } + versions: + - { name: "0.1.9", ref: v0.1.9 } + - { name: "0.1.8", ref: v0.1.8 } + - { name: "0.1.7", ref: v0.1.7 } + + # The other SDKs don't publish docs yet: each has a placeholder page from + # stubs/ in this repo (a version with `local:` instead of a ref) until its + # docs move out of the core docs. + sdk-python: + title: Python SDK + description: Python client for the OpenShell gateway API. + mount: sdks/python + versions: + - { name: preview, local: stubs/sdk-python } + + sdk-typescript: + title: TypeScript SDK + description: TypeScript client for the OpenShell gateway API. + mount: sdks/typescript + versions: + - { name: preview, local: stubs/sdk-typescript } + + sdk-rust: + title: Rust SDK + description: Rust client for the OpenShell gateway API. + mount: sdks/rust + versions: + - { name: preview, local: stubs/sdk-rust } diff --git a/stubs/sdk-python/docset.yml b/stubs/sdk-python/docset.yml new file mode 100644 index 0000000..e6e45dd --- /dev/null +++ b/stubs/sdk-python/docset.yml @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +# Placeholder until the Python SDK publishes its own docs (see sources.yml). + +title: Python SDK +nav: + - page: index.mdx diff --git a/stubs/sdk-python/index.mdx b/stubs/sdk-python/index.mdx new file mode 100644 index 0000000..795e215 --- /dev/null +++ b/stubs/sdk-python/index.mdx @@ -0,0 +1,11 @@ +--- +# SPDX-License-Identifier: Apache-2.0 +title: Python SDK +description: Python client for the OpenShell gateway API. +--- + + +The Python SDK docs will move here from the core docs. Until then, see the [Python SDK page](core://sdk/python) in the core docs. + + +The SDK lives in [ai-openshell/sdk-python](https://github.com/ai-openshell/sdk-python) and is published to PyPI as `openshell`. diff --git a/stubs/sdk-rust/docset.yml b/stubs/sdk-rust/docset.yml new file mode 100644 index 0000000..44e0ca2 --- /dev/null +++ b/stubs/sdk-rust/docset.yml @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +# Placeholder until the Rust SDK publishes its own docs (see sources.yml). + +title: Rust SDK +nav: + - page: index.mdx diff --git a/stubs/sdk-rust/index.mdx b/stubs/sdk-rust/index.mdx new file mode 100644 index 0000000..a4d2b15 --- /dev/null +++ b/stubs/sdk-rust/index.mdx @@ -0,0 +1,11 @@ +--- +# SPDX-License-Identifier: Apache-2.0 +title: Rust SDK +description: Rust client for the OpenShell gateway API. +--- + + +The Rust SDK docs will move here from the core docs. Until then, see the [Rust SDK page](core://sdk/rust) in the core docs. + + +The SDK is the `openshell-sdk` crate in [ai-openshell/openshell](https://github.com/ai-openshell/openshell/tree/main/crates/openshell-sdk). diff --git a/stubs/sdk-typescript/docset.yml b/stubs/sdk-typescript/docset.yml new file mode 100644 index 0000000..0cb434f --- /dev/null +++ b/stubs/sdk-typescript/docset.yml @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +# Placeholder until the TypeScript SDK publishes its own docs (see sources.yml). + +title: TypeScript SDK +nav: + - page: index.mdx diff --git a/stubs/sdk-typescript/index.mdx b/stubs/sdk-typescript/index.mdx new file mode 100644 index 0000000..245bef8 --- /dev/null +++ b/stubs/sdk-typescript/index.mdx @@ -0,0 +1,11 @@ +--- +# SPDX-License-Identifier: Apache-2.0 +title: TypeScript SDK +description: TypeScript client for the OpenShell gateway API. +--- + + +The TypeScript SDK docs will move here from the core docs. Until then, see the [TypeScript SDK page](core://sdk/typescript) in the core docs. + + +The SDK lives in [ai-openshell/sdk-typescript](https://github.com/ai-openshell/sdk-typescript) and is published to npm as `@ai-openshell/sdk`. diff --git a/test/assemble.test.mjs b/test/assemble.test.mjs index 6834b04..7e26f0b 100644 --- a/test/assemble.test.mjs +++ b/test/assemble.test.mjs @@ -52,21 +52,14 @@ function sourcesYml() { } function assemble(name, ...extra) { + return assembleWith(sourcesYml(), name, ...extra); +} + +function assembleWith(sources, name, ...extra) { const out = path.join(tmp, name); const r = spawnSync( process.execPath, - [ - assembler, - '--base', - '/docs/', - '--sources', - sourcesYml(), - '--out', - out, - '--cache', - path.join(tmp, 'cache'), - ...extra, - ], + [assembler, '--base', '/docs/', '--sources', sources, '--out', out, '--cache', path.join(tmp, 'cache'), ...extra], { encoding: 'utf8', env: { ...process.env, GITHUB_ACTIONS: '' } }, ); const read = (f) => fs.readFileSync(path.join(out, f), 'utf8'); @@ -165,3 +158,27 @@ describe('build with a --local checkout', () => { assert.equal(build.json('sources.lock.json')['beta@dev'].sha, 'working-tree'); }); }); + +describe('a version from a directory in this repo', () => { + let build; + before(() => { + const file = path.join(tmp, 'stub-sources.yml'); + fs.writeFileSync( + file, + `site:\n title: Test\n repo: example/docs\ntopics:\n - id: core\n label: Core\n sources: [alpha, stub]\nsources:\n alpha:\n mount: ""\n repo: ${repo('alpha')}\n path: docs\n versions:\n - { name: "1.0", ref: v1.0 }\n stub:\n mount: stub\n versions:\n - { name: preview, local: test/fixtures/stub }\n`, + ); + build = assembleWith(file, 'stub'); + }); + + test('builds without fetching and is recorded as this repo', () => { + assert.equal(build.status, 0, build.log); + const lock = build.json('sources.lock.json'); + assert.equal(lock['stub@preview'].sha, 'working-tree'); + assert.equal(lock['stub@preview'].repo, 'example/docs'); + assert.equal(build.json('nav.json').docsets.stub.latest, 'preview'); + }); + + test('is published at its mount and links to other docsets', () => { + assert.match(build.read('content/stub/index.mdx'), /\]\(\/docs\/guide\/\)/); + }); +}); diff --git a/test/fixtures/stub/docset.yml b/test/fixtures/stub/docset.yml new file mode 100644 index 0000000..48f8a7a --- /dev/null +++ b/test/fixtures/stub/docset.yml @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +title: Stub +nav: + - page: index.mdx diff --git a/test/fixtures/stub/index.mdx b/test/fixtures/stub/index.mdx new file mode 100644 index 0000000..b785aef --- /dev/null +++ b/test/fixtures/stub/index.mdx @@ -0,0 +1,6 @@ +--- +# SPDX-License-Identifier: Apache-2.0 +title: Stub +--- + +Coming soon. Until then, see the [guide](alpha://guide). diff --git a/topics/sdks.mdx b/topics/sdks.mdx new file mode 100644 index 0000000..1d9304d --- /dev/null +++ b/topics/sdks.mdx @@ -0,0 +1,6 @@ +--- +# SPDX-License-Identifier: Apache-2.0 +# Hand-written intro for the generated /sdks/ page. Owned by the site repo. +--- + +Every SDK talks to the same gateway API, so pick the one for your language. To try OpenShell without writing code, start with [this overview](core://how-it-works/sandboxes/overview) using the CLI.