Skip to content

Commit

Permalink
Enable ? help for GAP.Globals.FOO
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasguts committed Jun 19, 2019
1 parent bcd7ebd commit 3fc7a3d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
5 changes: 0 additions & 5 deletions pkg/GAPJulia/JuliaInterface/julia/gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,3 @@ macro g_str(str)
end

export @g_str

function show_GAP_help( topic::String, onlyexact::Bool=false )
print( GAP.gap_to_julia( GAP.Globals.HelpString(
GAP.julia_to_gap( topic ), onlyexact ) ) )
end
25 changes: 25 additions & 0 deletions pkg/GAPJulia/JuliaInterface/julia/help.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function GAP_help_string(topic::String, onlyexact::Bool = false)
return GAP.gap_to_julia(GAP.Globals.HelpString(GAP.julia_to_gap(topic), onlyexact))
end

function show_GAP_help(topic::String, onlyexact::Bool = false)
print(GAP_help_string(topic, onlyexact))
end

import Base.Docs: Binding, getdoc, docstr

## Create a helper type that gets returned by Binding
struct GAPHelpType
name::Symbol
end

Base.Docs.Binding(x::GlobalsType, name::Symbol) = GAPHelpType(name)

function Base.Docs.doc(x::GAPHelpType, typesig::Type = Union{})
return Text(GAP_help_string(string(x.name)))
end

## Set getdoc for GlobalsType to nothing,
## so it dispatches on the Binding.
Base.Docs.getdoc(x::GlobalsType) = nothing
Base.Docs.getdoc(x::MPtr) = Text(GAP_help_string(gap_to_julia(Globals.NameFunction(x))))
1 change: 1 addition & 0 deletions pkg/GAPJulia/JuliaInterface/julia/libgap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ include( "ccalls.jl" )
include( "gap.jl" )
include( "gap_to_julia.jl" )
include( "julia_to_gap.jl" )
include( "help.jl" )

0 comments on commit 3fc7a3d

Please sign in to comment.