Skip to content

Commit

Permalink
Try to use @vuepress/plugin-shiki
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Oct 2, 2023
1 parent 60a8d21 commit 15d6c04
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 19 deletions.
20 changes: 18 additions & 2 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import { defineUserConfig } from '@vuepress/cli';
import { gitPlugin } from '@vuepress/plugin-git';
import { feedPlugin } from 'vuepress-plugin-feed2';
import { shikiPlugin } from '@vuepress/plugin-shiki';
import { defaultTheme } from '@vuepress/theme-default';
import { sitemapPlugin } from 'vuepress-plugin-sitemap2';
import { docsearchPlugin } from '@vuepress/plugin-docsearch';
Expand Down Expand Up @@ -139,6 +140,21 @@ export default defineUserConfig({
gitPlugin(),
backToTopPlugin(),
mediumZoomPlugin(),
shikiPlugin({
theme: 'dark-plus',
langs: [
'nushell',
'rust',
'bash',
'shell',
'sh',
'toml',
'json',
'python',
'cpp',
'powershell',
],
}),
docsearchPlugin({
appId: 'GHCTOYCW6T',
indexName: 'nushell',
Expand All @@ -162,7 +178,7 @@ export default defineUserConfig({
: a.frontmatter.date,
b.data.git?.createdTime
? new Date(b.data.git?.createdTime)
: b.frontmatter.date
: b.frontmatter.date,
);
},
}),
Expand All @@ -173,7 +189,7 @@ export default defineUserConfig({
onPrepared: async (app) => {
await app.writeTemp(
'pages.js',
`export default ${JSON.stringify(app.pages.map(({ data }) => data))}`
`export default ${JSON.stringify(app.pages.map(({ data }) => data))}`,
);
},
});
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ Nushell is available as [downloadable binaries](https://github.com/nushell/nushe

#### macOS / Linux:

```console
```shell
$ brew install nushell
```

#### Windows:

```console
```shell
$ winget install nushell
```

Expand Down
2 changes: 1 addition & 1 deletion book/dataframes.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ CSV file that will become our sample dataframe that we will be using along with
the examples. In your favorite file editor paste the next lines to create out
sample csv file.
```csv
```
int_1,int_2,float_1,float_2,first,second,third,word
1,11,0.1,1.0,a,b,c,first
2,12,0.2,1.0,a,b,c,second
Expand Down
2 changes: 1 addition & 1 deletion book/how_nushell_code_gets_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ std::string my_path("foo");
or Rust
```rust!
```rust
let my_path = "foo";
use format!("{}::common", my_path);
```
Expand Down
22 changes: 13 additions & 9 deletions cookbook/polars_v_pandas_v_nushell.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ A dataframe example based on https://studioterabyte.nl/en/blog/polars-vs-pandas

## 1. Opening the file and show the shape of the DataFrame

```console
```shell
> let df = (dfr open NYCTaxi.csv)
```

```console
```shell
> $df | shape
╭───┬─────────┬─────────╮
# │ rows │ columns │
Expand All @@ -25,7 +25,7 @@ A dataframe example based on https://studioterabyte.nl/en/blog/polars-vs-pandas

## 2. Opening the file and show the first 5 rows

```console
```shell
> $df | first 5
╭───┬───────────┬───────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬──────────────┬──────────────╮
# │ id │ vendor_id │ pickup_dateti │ dropoff_datet │ passenger_cou │ pickup_longit │ pickup_latitu │ dropoff_longi │ dropoff_latit │ store_and_fw │ trip_duratio │
Expand All @@ -49,7 +49,7 @@ A dataframe example based on https://studioterabyte.nl/en/blog/polars-vs-pandas

## 3. Opening the file and get the length of all strings in the "id" column

```console
```shell
> let ids = ($df | first 5 | get id | str-lengths)
> $df | first 5 | append $ids | rename id_x vendor_id_length
╭───┬───────────┬───────────┬──────────────┬──────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
Expand All @@ -71,8 +71,10 @@ A dataframe example based on https://studioterabyte.nl/en/blog/polars-vs-pandas
│ │ │ │ ime │ time │ ount │ itude │ tude │ gitude │ itude │ wd_flag │ on │ ength │
╰───┴───────────┴───────────┴──────────────┴──────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────╯
```

Here's an alternate approach using `with-column`
```console

```shell
> $df | first 5 | with-column ($df | first 5 | get id | str-lengths) --name vendor_id_length
╭───┬───────────┬───────────┬──────────────┬──────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
# │ id │ vendor_id │ pickup_datet │ dropoff_date │ passenger_c │ pickup_long │ pickup_lati │ dropoff_lon │ dropoff_lat │ store_and_f │ trip_durati │ vendor_id_l │
Expand All @@ -96,7 +98,7 @@ Here's an alternate approach using `with-column`

## 4. Opening the file and apply a function to the "trip_duration" to divide the number by 60 to go from the second value to a minute value

```console
```shell
> $df | first 5 | with-column ((col trip_duration) / 60.0)
╭───┬───────────┬───────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬──────────────┬──────────────╮
│ # │ id │ vendor_id │ pickup_dateti │ dropoff_datet │ passenger_cou │ pickup_longit │ pickup_latitu │ dropoff_longi │ dropoff_latit │ store_and_fw │ trip_duratio │
Expand All @@ -117,9 +119,10 @@ Here's an alternate approach using `with-column`
│ │ │ │ me │ ime │ nt │ ude │ de │ tude │ ude │ d_flag │ n │
╰───┴───────────┴───────────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴──────────────┴──────────────╯
```
## 5. Opening the file and filtering out all rows with a trip duration shorther than 500 seconds
```console
```shell
> $df | filter-with ((col trip_duration) >= 500) | first 5
╭───┬───────────┬───────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬──────────────┬──────────────╮
│ # │ id │ vendor_id │ pickup_dateti │ dropoff_datet │ passenger_cou │ pickup_longit │ pickup_latitu │ dropoff_longi │ dropoff_latit │ store_and_fw │ trip_duratio │
Expand All @@ -140,9 +143,10 @@ Here's an alternate approach using `with-column`
│ │ │ │ me │ ime │ nt │ ude │ de │ tude │ ude │ d_flag │ n │
╰───┴───────────┴───────────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴──────────────┴──────────────╯
```
## 6. Opening the file, filtering out all the rows with a "Y" store_and_fwd_flag value, group by ID and calculate the mean duration time
```console
```shell
> $df | filter-with ((col store_and_fwd_flag) == "N") | group-by id | agg (col trip_duration | mean) | sort-by id | first 5
╭───┬───────────┬───────────────╮
│ # │ id │ trip_duration │
Expand All @@ -155,4 +159,4 @@ Here's an alternate approach using `with-column`
├───┼───────────┼───────────────┤
│ # │ id │ trip_duration │
╰───┴───────────┴───────────────╯
```
```
48 changes: 48 additions & 0 deletions package-lock.json

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

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
"@vuepress/plugin-docsearch": "2.0.0-beta.67",
"@vuepress/plugin-git": "2.0.0-beta.67",
"@vuepress/plugin-medium-zoom": "2.0.0-beta.67",
"@vuepress/plugin-shiki": "^2.0.0-beta.67",
"@vuepress/theme-default": "2.0.0-beta.67",
"lefthook": "^1.4.10",
"prettier": "^3.0.3",
"shiki": "^0.14.4",
"vuepress": "2.0.0-beta.67",
"vuepress-plugin-feed2": "2.0.0-beta.237",
"vuepress-plugin-sitemap2": "2.0.0-beta.237"
},
"engines" : {
"npm" : ">=9.0.0",
"node" : ">=18.12.0"
"engines": {
"npm": ">=9.0.0",
"node": ">=18.12.0"
}
}
2 changes: 1 addition & 1 deletion zh-CN/book/dataframes.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ $res
在看到了可以用`DataFrame`命令完成的事情之后,现在是时候开始测试它们了。首先,让我们创建一个样本 CSV 文件,该文件将成为我们的样本 DataFrame,并与示例一起使用。在你喜欢的编辑器中粘贴下面几行来创建样本 csv 文件:
```csv
```
int_1,int_2,float_1,float_2,first,second,third,word
1,11,0.1,1.0,a,b,c,first
2,12,0.2,1.0,a,b,c,second
Expand Down

0 comments on commit 15d6c04

Please sign in to comment.