Skip to content
This repository was archived by the owner on Mar 25, 2023. It is now read-only.

Commit 82e3259

Browse files
committed
Add syntax highlighting languages to various snippets.
A few hacks were needed for Bash that had newline escapes that didn't work with `bash` or `shell-session` -- these are either `python` or nothing at all.
1 parent 9db82b9 commit 82e3259

29 files changed

+206
-88
lines changed

content/docs/0000_getting-started/0200_installation.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To run the Splitgraph engine, you will need to be able to run [Docker](https://w
1717

1818
For Linux and OSX, there's a single script:
1919

20-
```
20+
```bash
2121
$ bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"
2222
```
2323

@@ -36,7 +36,7 @@ First, get the binary for `sgr` from [the releases page](https://github.com/spli
3636

3737
Then, create a new Splitgraph engine. Do:
3838

39-
```
39+
```shell-session
4040
$ sgr engine add
4141
```
4242

@@ -68,7 +68,7 @@ The simplest way to do this is by adding `alias sgr='winpty sgr'` to your `.bash
6868
You can also install the Splitgraph library from pip. This is useful if you want to use the
6969
[Splitgraph Python API](../python_api/splitgraph) to manipulate images from your code:
7070

71-
```
71+
```bash
7272
$ pip install splitgraph
7373
```
7474

@@ -81,7 +81,7 @@ on our GitHub.
8181
You can use Docker directly to pull and start the
8282
[engine](https://hub.docker.com/r/splitgraph/engine/):
8383

84-
```
84+
```python
8585
$ docker run -d \\
8686
-e POSTGRES_PASSWORD=supersecure \\
8787
-p 5432:5432 \\
@@ -97,14 +97,14 @@ can be changed by changing the [configuration file](#configuration-file).
9797

9898
To complete the installation, run:
9999

100-
```
100+
```shell-session
101101
$ sgr init
102102
```
103103

104104
You can also use [docker-compose](https://docs.docker.com/compose/). A sample
105105
Compose configuration for the service is as follows:
106106

107-
```
107+
```yaml
108108
version: '3'
109109
services:
110110
engine:

content/docs/0200_concepts/0300_splitfiles.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ Splitfiles are inspired by Dockerfiles and are the simplest way to build Splitgr
77

88
Here's an example Splitfile:
99

10-
```
10+
```splitfile
1111
FROM splitgraph/geonames:latest IMPORT {
1212
SELECT
1313
-- Note we need to escape the closing curly brace here for the
1414
-- Splitfile executor.
15-
substring(alternatenames FROM ',([A-Z]{3\}),') AS iata_code,
15+
substring(alternatenames FROM ',([A-Z]{3\\}),') AS iata_code,
1616
name,
1717
latitude,
1818
longitude,
1919
geonameid
2020
FROM all_countries
2121
WHERE feature_code = 'AIRP'
2222
AND country_code = 'US'
23-
AND substring(alternatenames FROM ',([A-Z]{3\}),') IS NOT NULL
23+
AND substring(alternatenames FROM ',([A-Z]{3\\}),') IS NOT NULL
2424
} AS airports
2525
2626
SQL {

content/docs/0300_ingesting_data/0100_load_csv_files.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ export const meta = {
44
};
55

66
<cast src="@splitgraph/content/casts/versioned/latest/import-from-csv.cast" />
7+
78
[Link to example](https://github.com/splitgraph/splitgraph/tree/master/examples/import-from-csv)
89

910
Splitgraph supports importing data from CSV files into Postgres tables. It uses [TableSchema](https://github.com/frictionlessdata/tableschema-py)'s schema inference functionality and
1011
Postgres' `COPY FROM STDIN` command to ingest the actual data.
1112

1213
To create a Splitgraph image from a CSV file:
1314

14-
```
15-
sgr init [repository_name]
16-
sgr csv import -f [filename] -k [primary_key] ... [repository_name] [table_name]
17-
# Import more data or alter the schema of table_name as you see fit
18-
sgr commit [repository_name]
15+
```bash
16+
sgr init [repository_name]
17+
sgr csv import -f [filename] -k [primary_key] ... [repository_name] [table_name]
18+
19+
# Import more data or alter the schema of table_name as you see fit
20+
sgr commit [repository_name]
1921
```

content/docs/0300_ingesting_data/0300_foreign_data_wrappers/0200_load_mongo_collections.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const meta = {
55

66
First, add this to your `.sgconfig`'s `mount_handlers` section to use [`mongo_fdw`](https://github.com/EnterpriseDB/mongo_fdw):
77

8-
```
8+
```ini
99
mongo_fdw=splitgraph.hooks.mount_handlers.mount_mongo
1010
```
1111

content/docs/0300_ingesting_data/0300_foreign_data_wrappers/0300_load_postgres_tables.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const meta = {
55

66
Add this to your `.sgconfig`'s `mount_handlers` section to use [`postgres_fdw`](https://www.postgresql.org/docs/12/postgres-fdw.html).
77

8-
```
8+
```ini
99
postgres_fdw=splitgraph.hooks.mount_handlers.mount_postgres
1010
```
1111

content/docs/0300_ingesting_data/0300_foreign_data_wrappers/0400_load_mysql_tables.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const meta = {
55

66
To mount a MySQL database into the Splitgraph engine using [`mysql_fdw`](https://github.com/EnterpriseDB/mysql_fdw), first, add this to your `.sgconfig`'s `mount_handlers` section:
77

8-
```
8+
```ini
99
mysql_fdw=splitgraph.hooks.mount_handlers.mount_mysql
1010
```
1111

content/docs/0300_ingesting_data/0300_foreign_data_wrappers/0500_load_mount_handlers.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ To mount a custom database into your Splitgraph engine, you have to do three thi
1010
- Write a Python function that, when invoked, will create the required mountpoint on the engine and initialize
1111
the remote foreign data wrapper. For an example, see `mount_postgres` in `splitgraph.hooks.mount_handlers`.
1212
- Register the handler in your `.sgconfig` file:
13-
```ini
14-
[mount_handlers]
15-
handler_name=your.handler.module.handler_function
16-
```
13+
14+
```ini
15+
[mount_handlers]
16+
handler_name=your.handler.module.handler_function
17+
```
1718

1819
Registering the handler in such a way will also parse its function signature and docstring, adding the handler automatically to the `sgr` client as a subcommand, as well as making it available to be used in Splitfiles.
1920

@@ -57,7 +58,7 @@ def mount_postgres(mountpoint, server, port, username, password, dbname, remote_
5758

5859
gets made available in the `sgr` client with this help message:
5960

60-
```
61+
```bash
6162
$ sgr mount postgres_fdw --help
6263
Usage: sgr mount postgres_fdw [OPTIONS] SCHEMA
6364

content/docs/0400_working_with_data/0100_query_the_engine.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const meta = {
66
Splitgraph images can be checked out into schemata with the same name as the repository that
77
the image belongs to. For example:
88

9-
```
9+
```bash
1010
$ sgr checkout example/repo_1:latest
1111
```
1212

@@ -15,15 +15,15 @@ can access the engine via a normal database connection can interact with the che
1515

1616
`sgr` provides a shorthand, [`sgr sql`](../sgr/image_information/sql), to run arbitrary SQL queries against the engine:
1717

18-
```
18+
```bash
1919
$ sgr sql --schema example/repo_1 "SELECT * FROM demo"
2020
```
2121

2222
However, any other SQL client will do. For example, you can use [pgcli](https://www.pgcli.com/) to
2323
query and write data to the engine. In the default `sgr engine add` configuration, the connection
2424
string is:
2525

26-
```
26+
```bash
2727
pgcli postgresql://sgr:password@localhost:5432/splitgraph
2828
```
2929

@@ -35,7 +35,7 @@ transformation on these datasets.
3535

3636
`sgr` comes with a few routines to set up repositories with some example data:
3737

38-
```
38+
```shell-session
3939
$ sgr example generate example/repo_1
4040
4141
Generated example/repo_1:demo with 10 rows, image hash 103cb2da2da0
@@ -47,8 +47,9 @@ in it called `demo`. The table has two columns, `key` (an integer) and
4747

4848
You can also inspect the currently checked out image in-depth:
4949

50-
```
50+
```shell-session
5151
$ sgr show example/repo_1:latest
52+
5253
Image example/repo_1:103cb2da2da000f3dce9512e3cc67434d7a3c977c0df259411c73a2687244706
5354
5455
Created at 2020-04-06T10:14:54.184552
@@ -64,8 +65,9 @@ and one table, `demo`.
6465

6566
Let's take a closer look at the new table.
6667

67-
```
68+
```shell-session
6869
$ sgr table example/repo_1:latest demo
70+
6971
Table example/repo_1:103cb2da2da000f3dce9512e3cc67434d7a3c977c0df259411c73a2687244706/demo
7072
7173
Size: 963.00 B

content/docs/0400_working_with_data/0200_clone_vs_checkout.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const meta = {
55

66
A Splitgraph repository can be cloned using [`sgr clone`](../sgr/sharing_images/clone):
77

8-
```
8+
```shell-session
99
$ sgr clone some_namespace/some_repository
1010
```
1111

@@ -16,9 +16,10 @@ By default, cloning a Splitgraph repository is different than what happens with
1616
In this case, only the repository's metadata is cloned, which is lightweight compared to the
1717
actual data but still lets the user to get an overview of the repository.
1818

19-
```
19+
```shell-session
2020
# This only transfers a few KB of metadata.
2121
$ sgr clone splitgraph/2016_election
22+
2223
Gathering remote metadata...
2324
Fetched metadata for 1 image, 1 table, 20 objects and 1 tag.
2425
@@ -42,8 +43,9 @@ checkout requires it. This behaviour can be overridden by passing `--download-al
4243
On checkout of an image, all objects that are required by that image are gathered, downloaded and
4344
assembled into tables in a process called "materialization".
4445

45-
```
46+
```shell-session
4647
$ sgr checkout splitgraph/2016_election:latest
48+
4749
Need to download 20 objects (26.75 MiB), cache occupancy: 492.69 MiB/10.00 GiB
4850
Fetching 20 objects, total size 26.75 MiB
4951
Getting download URLs from registry PostgresEngine data.splitgraph.com (5a87...@data.splitgraph.com:5432/sgregistry)...

content/docs/0400_working_with_data/0300_tracking_changes.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ this renders the whole repository as a tree.
1919

2020
Let's create another example repository and give the new image a tag:
2121

22-
```
22+
```shell-session
2323
$ sgr example generate example/repo_2
2424
$ sgr sql --schema example/repo_2 "SELECT * FROM demo ORDER BY key"
2525
$ sgr tag example/repo_2 original_data
@@ -29,7 +29,7 @@ The next step can be done from any application that can access the
2929
PostgreSQL database backing the Splitgraph engine, but `sgr` provides a
3030
shorthand to alter the generated image:
3131

32-
```
32+
```shell-session
3333
$ sgr example alter example/repo_2
3434
3535
Deleting 2 rows...
@@ -39,7 +39,7 @@ Adding 2 rows...
3939

4040
Let's inspect the current state of the repository:
4141

42-
```
42+
```shell-session
4343
$ sgr sql --schema example/repo_2 "SELECT * FROM demo ORDER BY key"
4444
```
4545

@@ -48,7 +48,7 @@ rows have been altered and two more rows have been added.
4848

4949
Let's compare the `demo` table to its previous version:
5050

51-
```
51+
```shell-session
5252
$ sgr diff example/repo_2 -v
5353
5454
Between 97900a827962 and the current working copy:

0 commit comments

Comments
 (0)