Skip to content

Commit

Permalink
Add doc_reaction function
Browse files Browse the repository at this point in the history
Looks up Reaction from class and shows doc in REPL
  • Loading branch information
sjdaines committed Jun 22, 2024
1 parent 4499b61 commit 6245442
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/ReactionFactory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ _classname(ReactionType::Type{<:AbstractReaction}) = String(last(split(string(Re
"""
find_reaction(class::AbstractString) -> ReactionType
Look up "class" in list of Reactions from [`find_all_reactions`](@ref), and return
Look up "class" in list of Reactions available in currently loaded modules
(using [`find_all_reactions`](@ref)), and return
fully-qualified Reaction Type (including module prefixes).
"""
function find_reaction(class::AbstractString)
Expand All @@ -58,6 +59,29 @@ function find_reaction(class::AbstractString)
end
end

"""
doc_reaction(class::AbstractString)
Look up "class" using [`find_reaction`](@ref), and display
fully-qualified Reaction Type and docstring in the Julia REPL.
NB: the VS Code Documentation browser has similar functionality
and is often easier to use. The key difference that it looks
at definitions *visible in the VS code projects and editor windows*, whilst
`doc_reaction` looks at definitions *available to code in the current REPL* ie
provided by modules that are currently loaded in the REPL.
"""
function doc_reaction(class::AbstractString)
RType = find_reaction(class)

println("\"$class\" -> $RType\n")

display(Base.Docs.doc(RType))

return RType
end


"""
create_reaction(ReactionType::Type{<:AbstractReaction}, base::ReactionBase) -> reaction::AbstractReaction
Expand Down

0 comments on commit 6245442

Please sign in to comment.