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 35ff89c commit cc15dfa
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
19 changes: 19 additions & 0 deletions pkg/GAPJulia/JuliaInterface/julia/libgap.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# This is a very hacky prototype calling libgap from julia
#
# It is intended to be a low level interface to the C functions
# the higher level API can be found in gap.jl
#

using Libdl

import Base: length, convert

const MPtr = Main.ForeignGAP.MPtr


include( "ccalls.jl" )
include( "gap.jl" )
include( "gap_to_julia.jl" )
include( "julia_to_gap.jl" )
include( "help.jl" )
1 change: 1 addition & 0 deletions src/GAP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,6 @@ include( "gap2.jl" )
include( "macros.jl" )
include( "gap_to_julia.jl" )
include( "julia_to_gap.jl" )
include( "help.jl" )

end
5 changes: 0 additions & 5 deletions src/gap2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,3 @@ function Display(x::GapObj)
error("variable was not correctly evaluated")
end
end

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 src/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::GapObj) = Text(GAP_help_string(gap_to_julia(Globals.NameFunction(x))))

0 comments on commit cc15dfa

Please sign in to comment.