Skip to content

Commit

Permalink
Move config docstring to InteractiveCodeSearch.CONFIG
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Sep 20, 2018
1 parent afee274 commit daca145
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 65 deletions.
63 changes: 34 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,6 @@ using InteractiveCodeSearch
* [percol](https://github.com/mooz/percol)
* [rofi](https://github.com/DaveDavenport/rofi) (GUI; default in IJulia)

## Configuration

```julia
using InteractiveCodeSearch
InteractiveCodeSearch.CONFIG.interactive_matcher = `peco` # default in terminal
InteractiveCodeSearch.CONFIG.interactive_matcher = `percol`
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "πŸ”Ž"` # use GUI matcher (default in non-terminal
# environment like IJulia)
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "πŸ”Ž" -fullscreen` # bigger screen
InteractiveCodeSearch.CONFIG.open = edit # default
InteractiveCodeSearch.CONFIG.open = less # use Base.less to read code
InteractiveCodeSearch.CONFIG.auto_open = true # default
InteractiveCodeSearch.CONFIG.auto_open = false # open matcher even when there
# is only one candidate
```

### Using InteractiveCodeSearch.jl by default

Use the same trick as [Revise.jl](https://github.com/timholy/Revise.jl/tree/v0.6); i.e., put the following code in your `~/.julia/config/startup.jl` (>= Julia 0.7) or `~/.juliarc.jl` (Julia 0.6):

```julia
@async begin
sleep(0.1)
@eval using InteractiveCodeSearch
end
```

## Reference

### `@search`
Expand Down Expand Up @@ -144,6 +115,40 @@ spzeros(3, 3)
```


### `InteractiveCodeSearch.CONFIG`
Configuration interface for `InteractiveCodeSearch`.

**Examples**

```julia
using InteractiveCodeSearch
InteractiveCodeSearch.CONFIG.interactive_matcher = `peco` # default in terminal
InteractiveCodeSearch.CONFIG.interactive_matcher = `percol`
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "πŸ”Ž"` # use GUI matcher (default in non-terminal
# environment like IJulia)
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "πŸ”Ž" -fullscreen` # bigger screen
InteractiveCodeSearch.CONFIG.open = edit # default
InteractiveCodeSearch.CONFIG.open = less # use Base.less to read code
InteractiveCodeSearch.CONFIG.auto_open = true # default
InteractiveCodeSearch.CONFIG.auto_open = false # open matcher even when there
# is only one candidate
```

**Using InteractiveCodeSearch.jl by default**

Use the same trick as [Revise.jl](https://github.com/timholy/Revise.jl/tree/v0.6); i.e., put the following code in your `~/.julia/config/startup.jl` (>= Julia 0.7) or `~/.juliarc.jl` (Julia 0.6):

```julia
@async begin
sleep(0.1)
@eval using InteractiveCodeSearch
# InteractiveCodeSearch.CONFIG.interactive_matcher = ...
end
```


[travis-img]: https://travis-ci.org/tkf/InteractiveCodeSearch.jl.svg?branch=master
[travis-url]: https://travis-ci.org/tkf/InteractiveCodeSearch.jl
[coveralls-img]: https://coveralls.io/repos/tkf/InteractiveCodeSearch.jl/badge.svg?branch=master&service=github
Expand Down
8 changes: 7 additions & 1 deletion scripts/generate_readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ function generate_readme(io::IO = stdout)

for (name, exported) in exports
md = dropheaders(doc(exported))
insert!(md.content, 1, Markdown.parse("### `$name`"))
println(io, "### `$name`")
println(io)
show(io, "text/markdown", md)
println(io)
println(io)
end

println(io, "### `InteractiveCodeSearch.CONFIG`")
show(io, "text/markdown", dropheaders(@doc InteractiveCodeSearch.CONFIG))
println(io)
println(io)

print(io, footer)
end

Expand Down
71 changes: 36 additions & 35 deletions src/InteractiveCodeSearch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,12 @@ using InteractiveCodeSearch
@searchreturn String Pkg # search methods returning a given type (Julia >= 0.7)
```
## Requirements
* Interactive matching command. For example:
* [peco](https://github.com/peco/peco) (default in terminal)
* [percol](https://github.com/mooz/percol)
* [rofi](https://github.com/DaveDavenport/rofi) (GUI; default in IJulia)
## Configuration
```julia
using InteractiveCodeSearch
InteractiveCodeSearch.CONFIG.interactive_matcher = `peco` # default in terminal
InteractiveCodeSearch.CONFIG.interactive_matcher = `percol`
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "πŸ”Ž"` # use GUI matcher (default in non-terminal
# environment like IJulia)
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "πŸ”Ž" -fullscreen` # bigger screen
InteractiveCodeSearch.CONFIG.open = edit # default
InteractiveCodeSearch.CONFIG.open = less # use Base.less to read code
InteractiveCodeSearch.CONFIG.auto_open = true # default
InteractiveCodeSearch.CONFIG.auto_open = false # open matcher even when there
# is only one candidate
```
### Using InteractiveCodeSearch.jl by default
Use the same trick as
[Revise.jl](https://github.com/timholy/Revise.jl/tree/v0.6); i.e., put
the following code in your `~/.julia/config/startup.jl` (>= Julia 0.7)
or `~/.juliarc.jl` (Julia 0.6):
```julia
@async begin
sleep(0.1)
@eval using InteractiveCodeSearch
end
```
"""
module InteractiveCodeSearch
export @search, @searchmethods
Expand Down Expand Up @@ -295,6 +260,42 @@ function code_search(p::SearchPolicy, ::T) where T
code_search(p, T)
end

"""
Configuration interface for `InteractiveCodeSearch`.
# Examples
```julia
using InteractiveCodeSearch
InteractiveCodeSearch.CONFIG.interactive_matcher = `peco` # default in terminal
InteractiveCodeSearch.CONFIG.interactive_matcher = `percol`
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "πŸ”Ž"` # use GUI matcher (default in non-terminal
# environment like IJulia)
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "πŸ”Ž" -fullscreen` # bigger screen
InteractiveCodeSearch.CONFIG.open = edit # default
InteractiveCodeSearch.CONFIG.open = less # use Base.less to read code
InteractiveCodeSearch.CONFIG.auto_open = true # default
InteractiveCodeSearch.CONFIG.auto_open = false # open matcher even when there
# is only one candidate
```
## Using InteractiveCodeSearch.jl by default
Use the same trick as
[Revise.jl](https://github.com/timholy/Revise.jl/tree/v0.6); i.e., put
the following code in your `~/.julia/config/startup.jl` (>= Julia 0.7)
or `~/.juliarc.jl` (Julia 0.6):
```julia
@async begin
sleep(0.1)
@eval using InteractiveCodeSearch
# InteractiveCodeSearch.CONFIG.interactive_matcher = ...
end
```
"""
const CONFIG = SearchConfig(
edit, # open
`peco`, # interactive_matcher
Expand Down

0 comments on commit daca145

Please sign in to comment.