-
-
Save rachidbch/ade54f8cff1c717410856c760141ee55 to your computer and use it in GitHub Desktop.
Browse Ramda documentation in Terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Cette snippet permet de faire une recherche interactive en ligne de commande dans un document JSON. | |
# Ici c'est utilisé pour faire un live search de la doc Ramda mais le même principe peut être utilisé pour toute documentation structurée | |
# Browse Ramda documentation in Terminal | |
# Requires jq and a tool such as fzf or peco for interactive filtering | |
LATEST="http://raine.github.io/ramda-json-docs/latest.json" | |
DOCS_URL="http://ramdajs.com/docs/" | |
json=$(curl -s $LATEST) | |
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end') | |
fn=$(echo "$functions" | fzf --reverse) || exit 0 | |
fn_name=$(echo $fn | awk '{print $1}') | |
desc=$(echo "$json" | jq -r ".[] | select(.name == \"$fn_name\") | .description" | fmt) | |
docs_url="$DOCS_URL#$fn_name" | |
echo "$fn" | |
echo | |
echo "$desc" | |
echo | |
echo "$docs_url" | |
# Open URL in browser | |
# open $docs_url # mac | |
# xdg-open $docs_url # linux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment