Skip to content
Merged
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
51 changes: 51 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: docs

on:
push:
branches: [main]
paths:
- 'docs/**'
- 'README.md'
- 'assets/**'
- '.github/workflows/docs.yaml'
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: docs/package-lock.json
- uses: actions/configure-pages@v5
- name: Install dependencies
run: npm ci
working-directory: docs
- name: Build the site
run: npm run build
working-directory: docs
- uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ Thumbs.db
.DS_Store

/artifacts

# docs site
docs/node_modules
docs/.vitepress/dist
docs/.vitepress/cache
docs/guide
docs/public
55 changes: 55 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { defineConfig } from 'vitepress'

// The site is served from https://mysticmind.github.io/pgsqlparser-dotnet/.
// Set DOCS_BASE=/ when serving from a domain root.
const base = process.env.DOCS_BASE ?? '/pgsqlparser-dotnet/'

const guide = [
{ text: 'Getting started', link: '/guide/getting-started' },
{ text: 'Parse trees', link: '/guide/parse-tree' },
{ text: 'Deparse, format and normalize', link: '/guide/deparse-format' },
{ text: 'Query analysis', link: '/guide/analysis' },
{ text: 'Scan, tokenize and split', link: '/guide/scan-split' },
{ text: 'PL/pgSQL', link: '/guide/plpgsql' },
{ text: 'Errors and offsets', link: '/guide/errors-offsets' },
]

export default defineConfig({
base,
lang: 'en-US',
title: 'PgSqlParser',
description: 'PostgreSQL SQL parser for .NET, built on libpg_query, the real PostgreSQL parser.',
cleanUrls: true,
lastUpdated: false,
head: [
['link', { rel: 'icon', type: 'image/svg+xml', href: `${base}mark-light.svg` }],
['meta', { property: 'og:title', content: 'PgSqlParser' }],
['meta', { property: 'og:description', content: 'PostgreSQL SQL parser for .NET, built on libpg_query, the real PostgreSQL parser.' }],
['meta', { property: 'og:image', content: `https://mysticmind.github.io${base}icon-512.png` }],
],
themeConfig: {
logo: { light: '/mark-light.svg', dark: '/mark-dark.svg', alt: 'PgSqlParser' },
nav: [
{ text: 'Guide', link: '/guide/getting-started', activeMatch: '^/guide/(?!whats-new|license)' },
{ text: "What's new", link: '/guide/whats-new' },
{ text: 'NuGet', link: 'https://www.nuget.org/packages/pgsqlparser' },
],
sidebar: [
{ text: 'Guide', items: guide },
{
text: 'Project',
items: [
{ text: "What's new", link: '/guide/whats-new' },
{ text: 'License', link: '/guide/license' },
],
},
],
outline: { level: [2, 3] },
search: { provider: 'local' },
socialLinks: [{ icon: 'github', link: 'https://github.com/mysticmind/pgsqlparser-dotnet' }],
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright (c) 2026 Babu Annamalai',
},
},
})
35 changes: 35 additions & 0 deletions docs/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* The stock VitePress backgrounds, with accent colours taken from the library icon. */
:root {
--vp-c-brand-1: #2a62a6;
--vp-c-brand-2: #3b7acb;
--vp-c-brand-3: #2f6db5;
--vp-c-brand-soft: rgba(47, 109, 181, 0.14);

--vp-button-brand-bg: #2f6db5;
--vp-button-brand-hover-bg: #3b7acb;
--vp-button-brand-active-bg: #2a62a6;

--vp-home-hero-name-color: #2f6db5;
}

.dark {
--vp-c-brand-1: #e8b656;
--vp-c-brand-2: #f0c97f;
--vp-c-brand-3: #d9902f;
--vp-c-brand-soft: rgba(232, 182, 86, 0.16);

--vp-button-brand-bg: #e8b656;
--vp-button-brand-hover-bg: #f0c97f;
--vp-button-brand-active-bg: #d9902f;
--vp-button-brand-text: #132a45;
--vp-button-brand-hover-text: #132a45;
--vp-button-brand-active-text: #132a45;

--vp-home-hero-name-color: #e8b656;
}

/* A larger logo in the navigation bar. */
.VPNavBarTitle .logo {
height: 42px;
margin-right: 10px;
}
4 changes: 4 additions & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import DefaultTheme from 'vitepress/theme'
import './custom.css'

export default DefaultTheme
57 changes: 57 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
layout: home

hero:
name: PgSqlParser
text: The real PostgreSQL parser, for .NET
tagline: Parse, deparse, format, analyse and rewrite PostgreSQL SQL with the parser the server itself uses, through libpg_query.
image:
light: /mark-light.svg
dark: /mark-dark.svg
alt: PgSqlParser icon
actions:
- theme: brand
text: Get started
link: /guide/getting-started
- theme: alt
text: What's new
link: /guide/whats-new
- theme: alt
text: View on GitHub
link: https://github.com/mysticmind/pgsqlparser-dotnet

features:
- title: Parse and deparse
details: Turn SQL into the PostgreSQL parse tree, walk it, edit it, and turn it back into SQL, plain or pretty printed.
link: /guide/parse-tree
- title: Format and normalize
details: Format SQL, replace constants with placeholders, and fingerprint queries so that the same query shape always gets the same id.
link: /guide/deparse-format
- title: Query analysis
details: Classify statements, find the tables, columns and functions a query uses, and see which locks a statement takes.
link: /guide/analysis
- title: Scan, tokenize and split
details: Get the tokens of a query with their positions, and split a script into statements.
link: /guide/scan-split
- title: PL/pgSQL
details: Parse function bodies and reach the SQL statements inside them.
link: /guide/plpgsql
- title: Runs everywhere .NET does
details: Native libraries for Linux (glibc and musl), macOS and Windows on x64 and ARM64. Targets .NET 8 and later and is Native AOT compatible.
link: /guide/getting-started
---

## Install

```shell
dotnet add package pgsqlparser
```

## A first query

```csharp
using PgSqlParser;

var tree = Parser.Parse("SELECT id, name FROM users WHERE id = $1").GetValueOrThrow();
Console.WriteLine(tree.Stmts.Count);
```
Loading
Loading