From daca1457796513f013fda8a3b927e4dcdaf0ecc3 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 19 Sep 2018 20:50:06 -0700 Subject: [PATCH] Move config docstring to InteractiveCodeSearch.CONFIG --- README.md | 63 +++++++++++++++++--------------- scripts/generate_readme.jl | 8 +++- src/InteractiveCodeSearch.jl | 71 ++++++++++++++++++------------------ 3 files changed, 77 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 6ecf958..80bc8b1 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 diff --git a/scripts/generate_readme.jl b/scripts/generate_readme.jl index 2021580..13ab585 100755 --- a/scripts/generate_readme.jl +++ b/scripts/generate_readme.jl @@ -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 diff --git a/src/InteractiveCodeSearch.jl b/src/InteractiveCodeSearch.jl index 04bbe11..4e01475 100644 --- a/src/InteractiveCodeSearch.jl +++ b/src/InteractiveCodeSearch.jl @@ -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 @@ -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