CLI tool to search and open documentation for Crystal language
Crystal
Latest commit cbc1a3a Jan 23, 2016 @rhysd update for Crystal 0.11.0
Permalink
Failed to load latest commit information.
bin set proper exit status Oct 3, 2015
spec open in external browser using open.cr Oct 3, 2015
src
vendor support Crystal 0.9.0 Oct 31, 2015
.gitignore crdoc list --path show path to HTML documents Oct 3, 2015
.gitmodules use git-submodule to manage package dependency Oct 3, 2015
.travis.yml
LICENSE
README.md update for Crystal 0.11.0 Jan 23, 2016

README.md

crdoc

Build Status

crdoc is a CLI tool to search and open documentation for Crystal language.

Installation

Please download a binary from release page (OS X only) or build

$ cd /your/favorite/directory/
$ git clone https://github.com/rhysd/crdoc.git && cd crdoc
$ git submodule update
$ crystal build --release bin/crdoc.cr
$ cp crdoc /your/favorite/bin

Usage

crdoc search [-f] KEYWORD...
crdoc api [-f] KEYWORD...
crdoc syntax_and_semantics [-f] KEYWORD...
crdoc list [-p|--path] [-a|--api] [-s|--syntax-and-semantics]
crdoc update

main usage

  • search searches all documents with keyword(s) and show the result in browser.
  • api searches API document with keyword(s) and show the result in browser.
  • syntax_and_semantics searches 'syntax and semantics' document with keyword(s) and show the result in browser.
  • list shows list of candidates. When --path is specified, it shows full paths to HTML documents instead.
  • update updates cached repository.

Using with peco/percol

If you want to search documents incrementally, awesome filtering tools are available. You can use them as below (OS X example)

$ open "$(crdoc list --path | peco)"
$ open "$(crdoc list --path | percol)"

peco example

If you often use these commands, it is also handy to make a function or an alias. Below is a Zsh & peco example.

function peco-crdoc() {
    local open
    case $OSTYPE in
    darwin*)
        open="open"
        ;;
    linux*)
        open="xdg-open"
        ;;
    esac

    local selected=$(crdoc list --path | peco --prompt 'crdoc >' --query "$LBUFFER")
    if [ -n "$selected" ]; then
        $open "${selected}"
    fi
    zle clear-screen
}
zle -N peco-crdoc

TODOs

  • Show markdown document in CLI instead of opening with browser
    • 'syntax and semantics' markdown documents already exists
    • It is necessary to generate markdown document from inline documents in comment
    • Add --browser option to preserve current features
  • Ignore-case match

Development

  • Crystal v0.11.0

Contributing

  1. Fork it ( https://github.com/rhysd/crdoc/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • @rhysd - creator, maintainer