Skip to content

Commit bf977e5

Browse files
committed
moar docs
1 parent 713312a commit bf977e5

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/Atom.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
__precompile__()
22

3+
@doc read(joinpath(dirname(@__DIR__), "README.md"), String)
34
module Atom
45

56
using Juno, Lazy, JSON, MacroTools, Media, Base.StackTraces

src/utils.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,25 @@ Calls `CodeTools.getmodule(args...)`, but returns `Main` instead of `nothing` in
157157
"""
158158
getmodule(args...) = (m = CodeTools.getmodule(args...)) === nothing ? Main : m
159159

160+
"""
161+
getmethods(mod::Module, word::AbstractString)
162+
getmethods(mod::AbstractString, word::AbstractString)
163+
164+
Returns the [`MethodList`](@ref) for `word`, which is bound within `mod` module.
165+
"""
160166
getmethods(mod::Module, word::AbstractString) = methods(CodeTools.getthing(mod, word))
161167
getmethods(mod::AbstractString, word::AbstractString) = getmethods(getmodule(mod), word)
162168

169+
"""
170+
getdocs(mod::Module, word::AbstractString, fallbackmod::Module = Main)
171+
getdocs(mod::AbstractString, word::AbstractString, fallbackmod::Module = Main)
172+
173+
Retrieves docs for `mod.word` with [`@doc`](@ref) macro. If `@doc` is not available
174+
within `mod` module, `@doc` will be evaluated in `fallbackmod` module if possible.
175+
176+
!!! note
177+
You may want to run [`cangetdocs`](@ref) in advance.
178+
"""
163179
getdocs(mod::Module, word::AbstractString, fallbackmod::Module = Main) = begin
164180
md = if Symbol(word) in keys(Docs.keywords)
165181
Core.eval(Main, :(@doc($(Symbol(word)))))
@@ -179,6 +195,14 @@ end
179195
getdocs(mod::AbstractString, word::AbstractString, fallbackmod::Module = Main) =
180196
getdocs(getmodule(mod), word, fallbackmod)
181197

198+
"""
199+
cangetdocs(mod::Module, word::Symbol)
200+
cangetdocs(mod::Module, word::AbstractString)
201+
cangetdocs(mod::AbstractString, word::Union{Symbol, AbstractString})
202+
203+
Checks if the documentation bindings for `mod.word` is resolved and `mod.word`
204+
is not deprecated.
205+
"""
182206
cangetdocs(mod::Module, word::Symbol) =
183207
Base.isbindingresolved(mod, word) &&
184208
!Base.isdeprecated(mod, word)

test/goto.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
@testset "module goto" begin
5353
let item = modulegotoitems("Atom", Main)[1]
5454
@test item.file == realpath′(joinpath(@__DIR__, "..", "src", "Atom.jl"))
55-
@test item.line == 2
55+
@test item.line == 3
5656
end
5757
let item = modulegotoitems("Junk2", Main.Junk)[1]
5858
@test item.file == joinpath(@__DIR__, "fixtures", "Junk.jl")

0 commit comments

Comments
 (0)