forked from nushell/nushell.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataframes_md-update.nu
33 lines (28 loc) · 1.25 KB
/
dataframes_md-update.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# The script is for updating the table with `polars` commands on the 'dataframes.md` page.
# 1. Gets a table with the current list of `polars` commands.
# 2. Joins the table with the currently specified values in the `Nushell Equivalent` column of the markdown table in `dataframes.md`.
let path = '../book/dataframes.md'
let chapter = open $path
let book_table_str = $chapter
| lines
| skip until {|line| $line starts-with '| Command Name '}
| take until {|line| $line starts-with '## Future'}
let book_table = $book_table_str
| parse '| {command_name} | {applies_to} | {description} | {nushell_equivalent} |'
| skip 2 # skip header and delimiter lines
| str trim command_name nushell_equivalent
| rename name
| select name nushell_equivalent
let updated_table = help commands
| where name =~ 'polars'
| where name != 'polars'
| update input_output {|i| $i.input_output.input | str join ', '}
| select name input_output usage
| join --left $book_table name
| rename "Command Name" "Applies To" Description "Nushell Equivalent"
| to md --pretty
| str replace -ar "(( |-){47} \\|\n)" " \|\n"
| $'($in)(char nl)'
$chapter
| str replace ($book_table_str | str join (char nl)) $updated_table
| save -f $path