https://github.com/nitrictech/snippy
Multi-lang snippet parser for stable documentation snippets
https://github.com/nitrictech/snippy
Last synced: about 2 months ago
JSON representation
Multi-lang snippet parser for stable documentation snippets
- Host: GitHub
- URL: https://github.com/nitrictech/snippy
- Owner: nitrictech
- License: apache-2.0
- Archived: true
- Created: 2021-07-29T05:35:59.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-08T02:45:07.000Z (over 4 years ago)
- Last Synced: 2026-02-04T21:06:47.381Z (5 months ago)
- Language: TypeScript
- Homepage:
- Size: 270 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @nitric/snippy

[](https://codecov.io/gh/nitrictech/snippy)
[](https://npmjs.org/package/@nitric/snippy)
[](https://npmjs.org/package/@nitric/snippy)
> The Code snippet parser.
The `@nitric/snippy` package was created to find and parse snippets into readable data that can be consumed by any application.
This package was used to create all code snippets used in the [nitric documentation.](https://nitric.io/docs)
## Features
- **Any langauge**. Parses snippets in any programming language.
- **Universal**. Works in all modern browsers and [Node.js](https://nodejs.org/).
- **Typed**. Has entensive TypeScript declarations.
## Usage
### Node 12+
Install with `npm install @nitric/snippy`, or `yarn add @nitric/snippy`
#### Get a snippet
```typescript
const { snippy } = require('@nitric/snippy');
const result = await snippy().get(
'nitrictech/node-sdk/examples/documents/get.ts'
);
```
#### Get a snippet with Auth
```typescript
const { snippy } = require('@nitric/snippy');
const result = await snippy({
auth: process.env.GITHUB_AUTH_TOKEN,
}).get('nitrictech/node-sdk/examples/documents/get.ts');
```
#### Search
```typescript
const { snippy } = require('@nitric/snippy');
const result = await snippy({
repos: [
{
url: 'nitrictech/node-sdk',
exts: ['ts', 'js'],
},
{
url: 'nitrictech/go-sdk',
exts: ['go'],
},
{
url: 'nitrictech/python-sdk',
exts: ['py'],
},
],
}).search();
```
#### Search with auth
Install with `npm install @nitric/snippy`, or `yarn add @nitric/snippy`
```typescript
import { snippy } from '@nitric/snippy';
const result = await snippy({
auth: process.env.GITHUB_AUTH_TOKEN,
repos: [
{
url: 'nitrictech/node-sdk',
exts: ['ts', 'js'],
},
{
url: 'nitrictech/go-sdk',
exts: ['go'],
},
{
url: 'nitrictech/python-sdk',
exts: ['py'],
},
],
}).search();
```