Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ jobs:
# `steps.install.outcome == 'success'`).
- name: ⬇️ Install Dependencies
id: install
run: npm ci
run: |
npm ci
npm run docs:install

- name: ⚖️ Validate Version / Preview Alignment
id: validate-version
Expand Down
123 changes: 123 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Documentation

on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- 'packages/docs/**'
- 'test/docs/**'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/docs.yml'
- '.nvmrc'
push:
branches:
- main
paths:
- 'packages/docs/**'
- 'test/docs/**'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/docs.yml'
- '.nvmrc'

permissions:
contents: read

# Keep main builds and deployments in order; superseded PR builds can be cancelled.
concurrency:
group: docs-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
name: Build and test documentation
runs-on: ubuntu-latest
timeout-minutes: 20
env:
DOCS_BASE: /${{ github.event.repository.name }}/

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: |
package-lock.json
packages/docs/package-lock.json

- name: Install test dependencies
run: npm ci

- name: Install documentation dependencies
run: npm ci --workspaces=false
working-directory: packages/docs

- name: Run documentation unit tests
run: npx vitest run --config test/docs/vitest.config.ts

- name: Install Chromium and system dependencies
run: npx playwright install --with-deps chromium

- name: Type-check and build static site
run: npm run build
working-directory: packages/docs

- name: Test the static site
id: browser-tests
# Unlike the VS Code/Electron suite, headless Chromium needs no Xvfb display.
run: npm run docs:test

- name: Upload browser failure details
if: ${{ !cancelled() && steps.browser-tests.outcome == 'failure' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: docs-browser-results-${{ github.run_attempt }}
path: test/e2e/.results/docs/**
include-hidden-files: true
if-no-files-found: warn
retention-days: 14

- name: Upload Pages artifact
if: >-
github.repository == 'microsoft/vscode-cosmosdb' &&
github.ref == 'refs/heads/main' &&
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
with:
path: packages/docs/.vitepress/dist

deploy:
name: Deploy documentation
needs: build
if: >-
github.repository == 'microsoft/vscode-cosmosdb' &&
github.ref == 'refs/heads/main' &&
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
concurrency:
group: github-pages
cancel-in-progress: false

steps:
- name: Configure Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
15 changes: 15 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
"options": {
"tabWidth": 2
}
},
{
"files": ["packages/docs/**"],
"options": {
"printWidth": 80
}
},
{
"files": ["packages/docs/**/*.md"],
"options": {
"embeddedLanguageFormatting": "auto"
}
}
],
"ignorePatterns": [
Expand All @@ -57,6 +69,9 @@
"skills",
"NOTICE.html",
"package-lock.json",
"packages/docs/package-lock.json",
"packages/docs/.vitepress/cache",
"packages/docs/.vitepress/dist",
"package.nls.*.json"
]
}
2 changes: 2 additions & 0 deletions .oxlintrc.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"dist",
"out",
"node_modules",
"packages/docs/.vitepress/cache",
"packages/docs/.vitepress/dist",
"resources",
"scripts",
"skills",
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"main": "./main.mjs",
"l10n": "./l10n",
"workspaces": [
"packages/*"
"packages/nosql-language-service",
"packages/schema-analyzer"
],
"activationEvents": [
"onFileSystem:azureDatabases",
Expand All @@ -56,6 +57,11 @@
"workspaceContains:.cosmosdb-migration"
],
"scripts": {
"docs:install": "npm --prefix packages/docs ci --workspaces=false",
"docs:dev": "npm --prefix packages/docs run dev",
"docs:build": "npm --prefix packages/docs run build",
"docs:preview": "npm --prefix packages/docs run preview",
"docs:test": "playwright test --config test/docs/playwright.config.ts",
"build": "concurrently -n tsc,vitest,test -c cyan,magenta,yellow \"tsc --noEmit\" \"tsc -p tsconfig.vitest.json --noEmit\" \"tsc -p tsconfig.test.json --noEmit\"",
"clean": "git clean -dfx",
"compile": "tsc -watch",
Expand Down
55 changes: 54 additions & 1 deletion packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,57 @@ historical-version test matrix; pre-1.0 dependencies such as Monaco can also cha
3. Add a `tsconfig.json` that extends `../../tsconfig.base.json`
4. Add path aliases to `tsconfig.base.json` (`paths`) so `tsc` resolves the package to its `src/`
5. Add matching `resolve.alias` entries to `vite.config.ext.mjs` and/or `vite.config.views.mjs` (subpath aliases must come before the bare-package alias)
6. Run `npm install` from the repo root so npm workspaces creates the `node_modules/@azure/cosmosdb-<name>` junction
6. Add the package directory to the root `package.json` `workspaces` list
7. Run `npm install` from the repo root so npm workspaces creates the `node_modules/@azure/cosmosdb-<name>` junction

## Documentation and Playground

`docs/` is a private, standalone VitePress site for both packages, with Monaco and CodeMirror playgrounds and VS Code
integration examples. It is deliberately excluded from npm workspaces: its own lockfile pins published npm packages,
so the playground exercises the release artifacts rather than local source code.

The site requires Node.js **22.18 or later** and pins **VitePress 2.0.0-alpha.20**, Vue, and TypeScript.
This prerelease uses the current Vite toolchain rather than the unsupported Vite 5 dependency in VitePress 1.6.

From the repository root:

```sh
npm run docs:install
npm run docs:dev
```

Use `npm run docs:build` to type-check the site and examples and generate static files in `docs/.vitepress/dist`.
Use `npm run docs:preview` to serve that build locally. Set `DOCS_BASE` during the build when hosting under a subpath,
for example `/vscode-cosmosdb/` on GitHub Pages. No deployment or Azure account is needed for local use.

Content lives in Markdown, runnable integration examples in `docs/samples/*.ts`, and scenario inputs in
`docs/samples/scenarios.json`.

After building, `npm run docs:test` uses the repository's existing Playwright setup to exercise the static site,
both editor adapters, completion refresh after schema changes, invalid JSON, and navigation. It requires the root
development dependencies and Playwright Chromium (`npx playwright install chromium`).
Run `npx vitest run --config test/docs/vitest.config.ts` for the docs unit tests against the installed npm releases,
without the root test suite's workspace-source aliases. Set the same `DOCS_BASE` for the build and browser tests
when testing a subpath deployment; both default to `/` locally.

### GitHub Pages

The `Documentation` workflow (`.github/workflows/docs.yml`) runs unit tests, type-checks and builds the site, then runs
browser tests for pull requests targeting `main` and pushes to `main`. Changes to `packages/docs/**`, `test/docs/**`,
the root dependency manifests, the workflow, or `.nvmrc` trigger it. It installs root test dependencies and standalone
documentation dependencies, but does not build the extension or start the Cosmos DB emulator.

The browser tests use headless Chromium with system dependencies installed by
`npx playwright install --with-deps chromium`. Unlike the VS Code/Electron tests, they do not need `xvfb-run`.
Failed browser tests upload traces and screenshots for diagnosis.

After a successful build and tests on `main`, a separate deployment job publishes the tested Pages artifact to
`https://microsoft.github.io/vscode-cosmosdb/`. Pull requests only build and test; they cannot deploy. A manual workflow
run on `main` can publish again without a new commit; manual runs on other branches only build and test.

Before the first deployment, select **Settings > Pages > Build and deployment > Source: GitHub Actions** in the
repository. If the `github-pages` environment has deployment branch restrictions or required reviewers, allow `main`
and approve deployments as required.

The workflow builds with `DOCS_BASE=/vscode-cosmosdb/` for the repository's Pages subpath. If hosting moves to a custom
domain or another path, update that build setting as well. Generated files stay in the Pages artifact, not a Git branch.
2 changes: 2 additions & 0 deletions packages/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vitepress/cache/
.vitepress/dist/
72 changes: 72 additions & 0 deletions packages/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { defineConfig } from 'vitepress';
import packageJson from '../package.json' with { type: 'json' };

export default defineConfig({
title: 'Cosmos DB developer tools',
description:
'Schema inference and Cosmos DB query language tooling for Monaco, CodeMirror, and VS Code.',
lang: 'en-US',
base: process.env.DOCS_BASE ?? '/',
appearance: false,
head: [
[
'script',
{},
`(() => {
const param = new URLSearchParams(window.location.search).get("scoutTheme");
const theme =
param || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
document.documentElement.setAttribute("data-theme", theme);
document.documentElement.classList.toggle("dark", theme === "dark");
})();`,
],
],
themeConfig: {
siteTitle: 'Cosmos DB tools',
nav: [
{ text: 'Playground', link: '/playground' },
{
text: 'npm',
items: [
{
text: 'Language service',
link: 'https://www.npmjs.com/package/@azure/cosmosdb-nosql-language-service',
},
{
text: 'Schema analyzer',
link: 'https://www.npmjs.com/package/@azure/cosmosdb-schema-analyzer',
},
],
},
],
sidebar: [
{ text: 'Overview', link: '/' },
{ text: 'Getting started', link: '/getting-started' },
{ text: 'Language Service API', link: '/language-service' },
{ text: 'Diagnostics', link: '/diagnostics' },
{ text: 'Schema Analyzer API', link: '/schema-analyzer' },
{ text: 'Monaco', link: '/monaco' },
{ text: 'CodeMirror', link: '/codemirror' },
{ text: 'VS Code', link: '/vscode' },
{ text: 'Samples', link: '/samples' },
{ text: 'Playground', link: '/playground' },
{ text: 'Limitations', link: '/limitations' },
],
socialLinks: [
{
icon: 'github',
link: 'https://github.com/microsoft/vscode-cosmosdb',
},
],
search: { provider: 'local' },
footer: {
message: `Language service ${packageJson.dependencies['@azure/cosmosdb-nosql-language-service']} | Schema analyzer ${packageJson.dependencies['@azure/cosmosdb-schema-analyzer']}. Released under the MIT License.`,
copyright: 'Copyright Microsoft Corporation.',
},
},
});
Loading
Loading