mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-19 09:25:28 +00:00
Merge pull request #55 from Pyppe/master
Add aggregate theme documentation and a script to generate them
This commit is contained in:
commit
fc7bef6562
@ -61,7 +61,7 @@ List installed packages.
|
||||
|
||||
#### `omf theme` _`<theme>`_
|
||||
|
||||
Apply a theme. To list available themes type `omf theme`.
|
||||
Apply a theme. To list available themes type `omf theme`. You can also [preview available Themes](./docs/Themes.md) before installing.
|
||||
|
||||
#### `omf remove` _`<name>`_
|
||||
|
||||
|
1772
docs/Themes.md
Normal file
1772
docs/Themes.md
Normal file
File diff suppressed because it is too large
Load Diff
55
tools/generate-themes-doc.fish
Executable file
55
tools/generate-themes-doc.fish
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
set -l project_dir (status -f|xargs dirname|xargs dirname)
|
||||
set -l theme_doc "$project_dir/docs/Themes.md"
|
||||
set temp_theme_contents (mktemp /tmp/fish.Themes.Content.XXXXX.md)
|
||||
set temp_theme_toc (mktemp /tmp/fish.Themes.TOC.XXXXX.md)
|
||||
|
||||
function __write_theme_readme -a name raw_content readme
|
||||
set -l escaped_raw_content (echo $raw_content | sed -r s"#[\/]#\\\/#gi")
|
||||
curl -s "$raw_content/$readme" | \
|
||||
sed -r 's/^#(.*)$/###\1/gi' | \
|
||||
sed -r 's/^=+$//gi' | \
|
||||
sed -r 's/^!\[(.*)\]\(([^h][^t][^t].*)\)$/![\1]('$escaped_raw_content'\/\2)/gi' \
|
||||
>> $temp_theme_contents
|
||||
echo "" >> $temp_theme_contents
|
||||
echo "" >> $temp_theme_contents
|
||||
end
|
||||
|
||||
function __find_readme -a raw_content
|
||||
for readme in "README.md" "readme.md"
|
||||
if curl -Ifs "$raw_content/$readme" > /dev/null
|
||||
echo $readme
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
echo "Generating Themes documentation ..."
|
||||
echo "# Available themes" > $temp_theme_toc
|
||||
|
||||
for theme in (command find $project_dir/db/themes/ -type f|sort)
|
||||
set -l name (echo $theme|xargs basename)
|
||||
set -l url (cat $theme)
|
||||
set -l raw_content (echo $url|sed -r 's#https://github.com/([-.a-z0-9]+)/([-.a-z0-9]+)#https://raw.githubusercontent.com/\1/\2/master#gi')
|
||||
set -l readme (__find_readme $raw_content)
|
||||
|
||||
echo "- [$name](#$name)" >> $temp_theme_toc
|
||||
echo "# $name" >> $temp_theme_contents
|
||||
if [ $readme ]
|
||||
echo "Fetching readme for $name"
|
||||
__write_theme_readme $name $raw_content $readme
|
||||
else
|
||||
echo "FAILED: No readme for $name" 1>&2
|
||||
echo "See $url for details" >> $temp_theme_contents
|
||||
end
|
||||
end
|
||||
|
||||
echo "" >> $temp_theme_toc
|
||||
cat $temp_theme_contents >> $temp_theme_toc
|
||||
rm $theme_doc
|
||||
cat $temp_theme_toc >> $theme_doc
|
||||
echo "All done: $theme_doc"
|
||||
|
||||
rm $temp_theme_contents
|
||||
rm $temp_theme_toc
|
Loading…
Reference in New Issue
Block a user