nu_scripts/modules/make_readme_table.nu

33 lines
1.4 KiB
Plaintext
Raw Normal View History

# A Script to try and create the table for the readme.md file
2021-05-19 15:50:57 +03:00
# | Category | File |
# | ---------------- | ----------------------------------------------------------------------------- |
# | coloring | [24bit-1.nu](./coloring\24bit-1.nu) |
# | coloring | [color_table.nu](./coloring\color_table.nu) |
# | coloring | [color_tables.nu](./coloring\color_tables.nu) |
# | coloring | [gradient.nu](./coloring\gradient.nu) |
# Right now there is still manual manipulation in order to update the README.md
# Hopefully, in the future someone will contribute a script to make this automatic.
2021-05-19 15:50:57 +03:00
let nu_files = (ls **/*.nu)
2021-05-26 20:50:40 +03:00
let nu_table = ($nu_files |
get name |
2021-05-19 15:50:57 +03:00
wrap File |
2021-05-25 00:24:34 +03:00
insert Category { |it|
2021-05-26 20:50:40 +03:00
let cat = ($it.File | path dirname)
if $cat == "" {
2021-05-24 21:37:07 +03:00
"not assigned yet"
} else {
2021-05-24 21:37:07 +03:00
$cat
}
2021-05-19 15:50:57 +03:00
} | where Category !~ ".git" | select Category File | sort-by Category)
# Let's fix the file now
2021-05-26 21:04:04 +03:00
let nu_table = ($nu_table | update File { |it|
let file_path = ($it.File | into string | str replace '\' '/' --all)
2021-05-26 21:04:04 +03:00
let file_name = ($file_path | path basename)
2021-05-26 20:50:40 +03:00
$"[($file_name)](char lparen)./($file_path)(char rparen)"
})
2021-05-26 20:50:40 +03:00
echo $nu_table | to md --pretty