Skip to content
/ crdoc Public

CLI tool to search and open documentation for Crystal language

License

Notifications You must be signed in to change notification settings

rhysd/crdoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

CLI tool to search and open documentation for Crystal language

Resources

License

Stars

Watchers

Forks

Packages

No packages published