dyndoc-ruby-core 1.2.6 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/dyndoc/Tools/julia/Fig.dyn +28 -0
- data/lib/dyndoc-core.rb +3 -1
- data/lib/dyndoc/base/filter/server.rb +57 -23
- data/lib/dyndoc/base/scanner.rb +4 -3
- data/lib/dyndoc/base/tmpl/manager.rb +9 -6
- data/lib/dyndoc/base/tmpl/parse_do.rb +15 -5
- data/share/julia/dynArray.jl +10 -8
- data/share/julia/dyndoc.jl +51 -82
- data/share/julia/dyndocOLD.jl +192 -0
- data/share/julia/dynreport.jl +127 -0
- data/share/julia/ruby.jl +5 -5
- metadata +65 -64
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b302bae638dbe8908415fc844db0b81321c5cbbd3b07307d84d13c6ece678a6c
|
|
4
|
+
data.tar.gz: f72741abff2e5aee2568dbef254fa683eb3edd352838b10cc185bbd242dcdb2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45a49451d506304d9ff93149507eb7da54122923d62b2fcd6af9fa7604c341f1c95eeac9521c18f4e123ac67df2d65b6c3850898942ac6d3989d9f7b42b109ea
|
|
7
|
+
data.tar.gz: ea013b177b66156fe1fc9c262e9d8d812db0e71987b696d022a0f485a78ec3bbfe23ba9f1c4d5b5e153e4e881bf2f2839ba8d842de2a5abd965b76d145f9310e
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[#rb<]
|
|
2
|
+
$jlfig=0
|
|
3
|
+
$jlfig_exts={:png=>".png",:jpeg =>".jpg",:pdf=>".pdf"}
|
|
4
|
+
[#<]
|
|
5
|
+
|
|
6
|
+
{#def]imgJL[#,] jlcode[] [#,] img[]
|
|
7
|
+
[#,] widthR[15] [#,] heightR[15][#,] unitR[cm][#,] resR[72][#,] optR[]
|
|
8
|
+
[#,] optTex[scale=0.75]
|
|
9
|
+
[#,] newR[TRUE]
|
|
10
|
+
[#=]delete[FALSE]
|
|
11
|
+
[#?]Dyndoc.tmpl_mngr.fmtOutput == "tex"[#<]
|
|
12
|
+
{#if]#{0?img}[#=]img[:{File.join($dyn_rsrc,"img","jlfig_:{$jlfig+=1}:{$jlfig_exts[:png]}")}]
|
|
13
|
+
[#else][#<]
|
|
14
|
+
{#if]File.dirname(#{=img})=="."[#>]img[:{File.join($dyn_rsrc,"img",#{=img})}][#if}
|
|
15
|
+
[#if}
|
|
16
|
+
[#?]Dyndoc.tmpl_mngr.fmtOutput == "html"[#<]
|
|
17
|
+
{#if]#{0?img}[#=]img[#r{gsub("\\\\","/",tempfile(fileext=".png"))}][#=]delete[TRUE][#if}
|
|
18
|
+
[#?]#{+?jlcode}[#<]#{jlcode}[#?]end
|
|
19
|
+
[#R<]require(base64)
|
|
20
|
+
#print(#{=img})
|
|
21
|
+
codeimg<-img(#{=img})
|
|
22
|
+
#print(codeimg)
|
|
23
|
+
if(#{delete}) unlink(#{=img})
|
|
24
|
+
[#?]Dyndoc.tmpl_mngr.fmtOutput == "html"
|
|
25
|
+
[#>][#r{codeimg}]
|
|
26
|
+
[#?]Dyndoc.tmpl_mngr.fmtOutput == "tex"
|
|
27
|
+
[#>][\includegraphics[#{optTex}]{#{img}}]
|
|
28
|
+
[#}
|
data/lib/dyndoc-core.rb
CHANGED
|
@@ -30,6 +30,7 @@ Settings.define 'cfg_dyn.cmd_pandoc_options', :type => Array, :default => []
|
|
|
30
30
|
Settings.define 'cfg_dyn.options.pdflatex_nb_pass', :type => Integer, :default => 1
|
|
31
31
|
Settings.define 'cfg_dyn.options.pdflatex_echo', :type => :boolean, :default => false
|
|
32
32
|
Settings.define 'cfg_dyn.debug', :type => :boolean, :default => false
|
|
33
|
+
Settings.define 'cfg_dyn.ruby_only', :type => :boolean, :default => false
|
|
33
34
|
|
|
34
35
|
Settings.define 'cfg_dyn.dyndoc_session', :type => Symbol, :default => :normal #or :interactive
|
|
35
36
|
|
|
@@ -44,6 +45,7 @@ Settings.define 'cfg_dyn.devel_mode', :type=> Symbol, :default=> :none
|
|
|
44
45
|
Settings.define 'cfg_dyn.ruby_debug', :type=> Symbol, :default=> :none
|
|
45
46
|
|
|
46
47
|
Settings.define 'cfg_dyn.model_doc', :default => "default"
|
|
48
|
+
Settings.define 'cfg_dyn.exec_mode', :default => "no"
|
|
47
49
|
Settings.define 'cfg_dyn.format_doc', :default => :tex
|
|
48
50
|
Settings.define 'cfg_dyn.pandoc_filter', :default => ""
|
|
49
51
|
|
|
@@ -61,7 +63,7 @@ require 'dyndoc/init/config'
|
|
|
61
63
|
Dyndoc.init_dyndoc_library_path
|
|
62
64
|
Dyndoc.init_rootDoc
|
|
63
65
|
Dyndoc.add_logger
|
|
64
|
-
Dyndoc.logger.info("dyndoc-core loaded!")
|
|
66
|
+
## Dyndoc.logger.info("dyndoc-core loaded!")
|
|
65
67
|
## Dyndoc.logger.info(".dyndoc.yml: "+File.join(ENV["HOME"],".dyndoc.yml"))
|
|
66
68
|
|
|
67
69
|
CqlsDoc=Dyndoc #for compatibity
|
|
@@ -104,10 +104,30 @@ module Dyndoc
|
|
|
104
104
|
out
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
def RbServer.redirect
|
|
108
|
+
if block_given?
|
|
109
|
+
require 'stringio'
|
|
110
|
+
begin
|
|
111
|
+
# redirect output to StringIO objects
|
|
112
|
+
oldstdout,oldstderr=$stdout, $stderr
|
|
113
|
+
stdout, stderr = StringIO.new, StringIO.new
|
|
114
|
+
$stdout, $stderr = stdout, stderr
|
|
115
|
+
yield
|
|
116
|
+
ensure
|
|
117
|
+
# restore normal output
|
|
118
|
+
$stdout, $stderr = oldstdout,oldstderr
|
|
119
|
+
end
|
|
120
|
+
return {stdout: stdout.string, stderr: stderr.string}
|
|
121
|
+
else
|
|
122
|
+
return {stdout: "", stderr: ""}
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end
|
|
126
|
+
|
|
107
127
|
def RbServer.capture(code,rbEnvir=nil)
|
|
108
128
|
|
|
109
129
|
require 'stringio'
|
|
110
|
-
|
|
130
|
+
require 'ostruct'
|
|
111
131
|
|
|
112
132
|
begin
|
|
113
133
|
# redirect output to StringIO objects
|
|
@@ -273,10 +293,10 @@ module Dyndoc
|
|
|
273
293
|
short[0]=short[0].to_i
|
|
274
294
|
short[2]=short[2].to_i
|
|
275
295
|
## Dyndoc.warn "short",[short,txt]
|
|
276
|
-
(0...short[0]).each{|i| txtout << txt[i].force_encoding("utf-8") << "\n"}
|
|
296
|
+
(0...short[0]).each{|i| txtout << (txt[i] ? txt[i].force_encoding("utf-8") : "") << "\n"}
|
|
277
297
|
txtout << short[1] << "\n"
|
|
278
298
|
le = txt.length
|
|
279
|
-
((le-short[2])...le).each{|i| txtout << txt[i].force_encoding("utf-8") << "\n"}
|
|
299
|
+
((le-short[2])...le).each{|i| txtout << (txt[i] ? txt[i].force_encoding("utf-8") : "") << "\n"}
|
|
280
300
|
else
|
|
281
301
|
txt=txt.map{|e| e.force_encoding("utf-8")}
|
|
282
302
|
txtout << txt.join("\n")
|
|
@@ -808,59 +828,73 @@ module Dyndoc
|
|
|
808
828
|
@@initVerb=nil
|
|
809
829
|
|
|
810
830
|
def JLServer.initVerb
|
|
811
|
-
Julia << "include(
|
|
812
|
-
|
|
831
|
+
Julia << "Base.include(@__MODULE__,\""+File.join(Dyndoc.cfg_dir[:gem_path],"share","julia","dyndoc.jl")+"\")"
|
|
832
|
+
Julia << "push!(Libdl.DL_LOAD_PATH,\"/usr/lib\");push!(Libdl.DL_LOAD_PATH,\"/usr/local/lib\")"
|
|
833
|
+
@@initVerb=true
|
|
813
834
|
end
|
|
814
835
|
|
|
815
836
|
def JLServer.inputsAndOutputs(code,hash=true)
|
|
816
837
|
JLServer.initVerb unless @@initVerb
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
838
|
+
Dyndoc.logger.info("JLServer.inputsAndOutputs: "+code.strip)
|
|
839
|
+
res=(Julia << 'capture_output_julia('+code.strip.inspect.gsub("$","\\$")+')')
|
|
840
|
+
Dyndoc.logger.info("JLServer.inputsAndOutputs:"+res.inspect)
|
|
841
|
+
res.map!{|input,output,output2,error,error2|
|
|
820
842
|
{:input=>input,:output=>output,:output2=>output2,:error=>error,:error2=>error2}
|
|
821
843
|
} if res and hash
|
|
822
844
|
res
|
|
823
845
|
end
|
|
824
846
|
|
|
825
847
|
def JLServer.eval(code)
|
|
826
|
-
Julia.eval(code)
|
|
848
|
+
Julia.eval("capture_output_julia("+code.strip.inspect.gsub("$","\\$")+")")
|
|
827
849
|
end
|
|
828
850
|
|
|
829
851
|
def JLServer.output(code,opts={})
|
|
830
|
-
opts={:print=>true}.merge(opts)
|
|
852
|
+
#opts={:print=>true}.merge(opts)
|
|
831
853
|
## Dyndoc.warn "jlserv",code+"|"+Julia.eval(code,:print=>opts[:print]).to_s
|
|
832
|
-
Julia.eval(code,:print=>opts[:print]).to_s
|
|
854
|
+
#Julia.eval(code,:print=>opts[:print]).to_s
|
|
855
|
+
|
|
856
|
+
res=JLServer.inputsAndOutputs(code,false)
|
|
857
|
+
Dyndoc.warn "jlserv.output",[code,res]
|
|
858
|
+
return "" unless res
|
|
859
|
+
res=res.map{|input,output,output2,error,error2|
|
|
860
|
+
#Dyndoc.warn "output",output
|
|
861
|
+
output
|
|
862
|
+
}
|
|
863
|
+
res.length==0 ? "" : res[-1]
|
|
833
864
|
end
|
|
834
865
|
|
|
835
866
|
def JLServer.outputs(code,opts={}) #may have more than one lines in code
|
|
836
867
|
## Dyndoc.warn "JLServer.outputs opts",opts
|
|
837
|
-
##
|
|
868
|
+
##
|
|
869
|
+
Dyndoc.warn "JLServer code",code
|
|
870
|
+
res=JLServer.inputsAndOutputs(code,false)
|
|
838
871
|
if opts[:block]
|
|
839
|
-
res=JLServer.inputsAndOutputs(code,false)
|
|
840
872
|
return "" unless res
|
|
841
873
|
res.map{|input,output,output2,error,error2|
|
|
842
874
|
## Dyndoc.warn "output2",output2
|
|
843
|
-
|
|
875
|
+
output
|
|
844
876
|
}.join("\n")
|
|
845
|
-
else
|
|
846
|
-
JLServer.eval(code)
|
|
847
877
|
end
|
|
848
878
|
end
|
|
849
879
|
|
|
850
880
|
def JLServer.echo(code,prompt="julia> ",tab=2)
|
|
851
881
|
out=""
|
|
852
882
|
res=JLServer.inputsAndOutputs(code)
|
|
853
|
-
##
|
|
883
|
+
##
|
|
884
|
+
Dyndoc.warn "JLServer",res
|
|
885
|
+
return "Error when executing: "+code unless res
|
|
854
886
|
res.each do |cmd|
|
|
855
887
|
## Dyndoc.warn "input",cmd
|
|
856
888
|
out << prompt+ cmd[:input].split("\n").each_with_index.map{|e,i| i==0 ? e : " "*(prompt.length)+e}.join("\n").gsub(/\t/," "*tab)
|
|
857
|
-
out << "\n"
|
|
889
|
+
out << "\n" unless cmd[:input].strip[-1]==";"
|
|
858
890
|
## Dyndoc.warn "output1",out
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
891
|
+
if cmd[:error]==""
|
|
892
|
+
out << ((cmd[:output]=="nothing" or (cmd[:input].strip)[-1]==";") ? "" : cmd[:output])
|
|
893
|
+
out << ((cmd[:output2]=="nothing" or (cmd[:input].strip)[-1]==";") ? "" : cmd[:output2]) #cmd[:output2]
|
|
894
|
+
else
|
|
895
|
+
out << cmd[:error]
|
|
896
|
+
end
|
|
897
|
+
out << (cmd[:output]=="nothing" ? "" : "\n")
|
|
864
898
|
## Dyndoc.warn "output3",out
|
|
865
899
|
end
|
|
866
900
|
out
|
data/lib/dyndoc/base/scanner.rb
CHANGED
|
@@ -219,7 +219,7 @@ module Dyndoc
|
|
|
219
219
|
#IMPORTANT: process has to have as the second argument e[:type] corresponding to the inside_type and as the third argument res[:type] corresponding to the out_type
|
|
220
220
|
##Dyndoc.warn "scan",txt2,e[:type],res[:type],(filter ? filter.process(txt2,e[:type],res[:type]) : txt2)
|
|
221
221
|
txt2=((filter and !(txt2=~/\[HTML\]/)) ? filter.process(txt2,e[:type],res[:type]) : txt2)
|
|
222
|
-
##p txt2
|
|
222
|
+
##p [:txt2,txt2]
|
|
223
223
|
txt << txt2
|
|
224
224
|
end
|
|
225
225
|
#puts "txt";p txt
|
|
@@ -275,7 +275,7 @@ module Dyndoc
|
|
|
275
275
|
init_tag(@tag_type) if [:dtag].include? @tag_type
|
|
276
276
|
end
|
|
277
277
|
|
|
278
|
-
@@tagblck_set=[:<<,:<,:do,:>>,:>,:">!",:out,:nl,:"\\n",:"r<",:"R<",:"rb<",:"m<",:"M<",:"jl<",:"r>>",:"R>>",:rverb,:"rb>>",:rbverb,:"jl>>",:jlverb,:rout,:"r>",:"R>",:"rb>",:"m>",:"M>",:"jl>",:"_<",:"_>",:"__>",:"html>",:"tex>",:"txtl>",:"ttm>",:"md>",:"adoc>",:tag,:"??",:"?",:yield,:"=",:"-",:+,:"%",:"tex=",:"tex+",:"md=",:"md+",:"adoc=",:"adoc+",:"html=",:"html+",:"rb=",:"rb+",:"R=",:"R+",:"jl=",:"jl+",:"txtl=",:"txtl+"]
|
|
278
|
+
@@tagblck_set=[:<<,:<,:do,:>>,:>,:">!",:out,:nl,:"\\n",:"r<",:"R<",:"rb<",:"m<",:"M<",:"jl<",:"sh<",:"r>>",:"R>>",:rverb,:"rb>>",:rbverb,:"jl>>",:jlverb,:rout,:"r>",:"R>",:"rb>",:"m>",:"M>",:"jl>",:"_<",:"_>",:"__>",:"html>",:"tex>",:"txtl>",:"ttm>",:"md>",:"adoc>",:tag,:"??",:"?",:yield,:"=",:"-",:+,:"%",:"tex=",:"tex+",:"md=",:"md+",:"adoc=",:"adoc+",:"html=",:"html+",:"rb=",:"rb+",:"R=",:"R+",:"jl=",:"jl+",:"txtl=",:"txtl+"]
|
|
279
279
|
#Rmk: when a symbol is included in another one, you have to place it before! Ex: :>> before :> and also :<< before :<
|
|
280
280
|
|
|
281
281
|
@@tagblck_dyndoc_set = [:main,:content,:before,:after,:require,:helpers,:preamble,:postamble,:style,:title,:path,:first,:last,:default,:cfg]
|
|
@@ -302,6 +302,7 @@ module Dyndoc
|
|
|
302
302
|
:"rb<" => [:blck, :"rb<"],
|
|
303
303
|
:"R<" => [:blck, :"R<"],
|
|
304
304
|
:"jl<" => [:blck, :"jl<"],
|
|
305
|
+
:"sh<" => [:blck, :"sh<"],
|
|
305
306
|
:"r>>" => [:blck, :"r>>"],
|
|
306
307
|
:"R>>" => [:blck, :"r>>"],
|
|
307
308
|
:"*<" => [:blck, :"*<"],
|
|
@@ -366,7 +367,7 @@ module Dyndoc
|
|
|
366
367
|
},
|
|
367
368
|
:mode_arg=>:next_block,
|
|
368
369
|
:tag_code=>[:code,:<,:>,:<<,:txt], #used for arg mode!
|
|
369
|
-
:arg=>[:if,:unless,:elsif,:for,:case,:def,:func,:meth,:new,:super,:call,:input,:when,:break,:set,:style,:keys,:"?",:"rb<",:"r<",:"R<",:"m<",:"M<",:"jl<"],
|
|
370
|
+
:arg=>[:if,:unless,:elsif,:for,:case,:def,:func,:meth,:new,:super,:call,:input,:when,:break,:set,:style,:keys,:"?",:"rb<",:"r<",:"R<",:"m<",:"M<",:"jl<",:"sh<"],
|
|
370
371
|
:blck=>{
|
|
371
372
|
:instr=>[:document,:if,:unless,:case,:loop,:set,:tag,:keys,:rverb,:rbverb,:jlverb,:for],
|
|
372
373
|
:keyword=>{
|
|
@@ -89,16 +89,17 @@ module Dyndoc
|
|
|
89
89
|
# init rb4jl stuff
|
|
90
90
|
# since inside ruby, no need Ruby.start and Ruby.stop like in rb4R.
|
|
91
91
|
# sort of equivalent of JLServer.init_filter (but not yet defined)!
|
|
92
|
-
Julia << "include(
|
|
92
|
+
#Julia << "Base.include(@__MODULE__,\"ruby.jl\")"
|
|
93
|
+
Julia << "Base.include(@__MODULE__,\""+File.join(Dyndoc.cfg_dir[:gem_path],"share","julia","ruby.jl")+ "\")"
|
|
93
94
|
Dyndoc.logger.info "initJulia: ruby.jl"
|
|
94
|
-
Julia << "include(
|
|
95
|
+
Julia << "Base.include(@__MODULE__,\""+File.join(Dyndoc.cfg_dir[:gem_path],"share","julia","dynArray.jl")+ "\")"
|
|
95
96
|
Dyndoc.logger.info "initJulia: dynArray.jl"
|
|
96
97
|
#-| To debug ruby.jl and dynArray.jl => uncomment below and commnt above
|
|
97
98
|
# Julia << "include(\""+File.expand_path("~/Github/dyndoc/share/julia/ruby.jl")+"\")"
|
|
98
99
|
# Julia << "include(\""+File.expand_path("~/Github/dyndoc/share/julia/dynArray.jl")+"\")"
|
|
99
|
-
Julia << "using Dyndoc"
|
|
100
|
+
Julia << "using Main.Dyndoc"
|
|
100
101
|
Dyndoc.logger.info "initJulia: using Dyndoc"
|
|
101
|
-
Julia << "Ruby.alive(true)"
|
|
102
|
+
Julia << "Dyndoc.Ruby.alive(true)"
|
|
102
103
|
#Julia << "global const _dynArray=DynArray()"
|
|
103
104
|
Dyndoc.logger.info "Julia initialized inside dyndoc!"
|
|
104
105
|
|
|
@@ -120,8 +121,10 @@ module Dyndoc
|
|
|
120
121
|
@cfg[:part_tag][0]=@cfg[:part_tag][0][1..-1] if !(@cfg[:part_tag].empty?) and (@partTag_add= (@cfg[:part_tag][0][0,1]=="+"))
|
|
121
122
|
=end
|
|
122
123
|
## default system root appended
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
unless Dyndoc.cfg_dyn[:ruby_only]
|
|
125
|
+
TemplateManager.initR if Dyndoc.cfg_dyn[:langs].include? :R
|
|
126
|
+
TemplateManager.initJulia if Dyndoc.cfg_dyn[:langs].include? :jl
|
|
127
|
+
end
|
|
125
128
|
rbenvir_init(binding)
|
|
126
129
|
@rEnvir=["Global"]
|
|
127
130
|
@envirs={}
|
|
@@ -29,7 +29,7 @@ module Dyndoc
|
|
|
29
29
|
|
|
30
30
|
@@cmd=["newBlck","input","require","def","func","meth","new","super","blck","do","if","for","case", "loop","r","renv","rverb","rbverb","jlverb","rout","rb","var","set","hide","format","txt","code","<","<<",">","eval","ifndef","tags","keys","opt","document","yield","get","part","style"]
|
|
31
31
|
## Alias
|
|
32
|
-
@@cmdAlias={"unless"=>"if","out"=>"do","r<"=>"r","R<"=>"R","rb<"=>"rb","r>"=>"r","R>"=>"R","rb>"=>"rb","m<"=>"m","M<"=>"m","m>"=>"m","M>"=>"m","jl>"=>"jl","jl<"=>"jl","<"=>"txt","<<"=>"txt",">"=>"txt","code"=>"txt","dyn"=>"eval","r>>"=>"rverb","R>>"=>"rverb","rout"=>"rverb","rb>>" => "rbverb","jl>>" => "jlverb","saved"=>"blck","blckAnyTag"=>"blck"}
|
|
32
|
+
@@cmdAlias={"unless"=>"if","out"=>"do","r<"=>"r","R<"=>"R","rb<"=>"rb","r>"=>"r","R>"=>"R","rb>"=>"rb","m<"=>"m","M<"=>"m","m>"=>"m","M>"=>"m","jl>"=>"jl","jl<"=>"jl","sh<"=>"sh","<"=>"txt","<<"=>"txt",">"=>"txt","code"=>"txt","dyn"=>"eval","r>>"=>"rverb","R>>"=>"rverb","rout"=>"rverb","rb>>" => "rbverb","jl>>" => "jlverb","saved"=>"blck","blckAnyTag"=>"blck"}
|
|
33
33
|
@@cmd += @@cmdAlias.keys
|
|
34
34
|
|
|
35
35
|
def add_dtag(dtag,cmdAlias=nil)
|
|
@@ -482,7 +482,7 @@ p [vars,b2]
|
|
|
482
482
|
when :do,:<
|
|
483
483
|
i,*b2=next_block(blck,i)
|
|
484
484
|
parse(b2,filter) if cond_tag and cond
|
|
485
|
-
when :"r<",:"rb<",:"R<",:"m<",:"M<",:"jl<"
|
|
485
|
+
when :"r<",:"rb<",:"R<",:"m<",:"M<",:"jl<",:"sh<"
|
|
486
486
|
# if current_block_tag==:"jl<"
|
|
487
487
|
# ##p "iciiiii"
|
|
488
488
|
# end
|
|
@@ -498,7 +498,7 @@ p [vars,b2]
|
|
|
498
498
|
b2=[code.unshift(newblck)]
|
|
499
499
|
##puts "r<;rb<";p b2
|
|
500
500
|
filter.outType=":"+(blck[i].to_s)[0...-1]
|
|
501
|
-
#
|
|
501
|
+
#Dyndoc.warn "rb,jl,R block",filter.outType
|
|
502
502
|
parse(b2,filter)
|
|
503
503
|
filter.outType=nil
|
|
504
504
|
end
|
|
@@ -1056,7 +1056,7 @@ p [vars,b2]
|
|
|
1056
1056
|
when :binding
|
|
1057
1057
|
i,*b2=next_block(blck,i)
|
|
1058
1058
|
rbEnvir=b2[0][1].strip
|
|
1059
|
-
when :do,:<,:out,:>,:"r<",:"rb<",:"r>",:"R>",:"R<",:"r>>",:rverb,:"rb>>",:rbverb,:"jl>>",:jlverb,:"rb>",:"?",:tag,:"??",:yield,:>>,:"=",:"+",:<<,:"txtl>",:"md>",:"adoc>",:"ttm>",:"html>",:"tex>",:"_>"
|
|
1059
|
+
when :do,:<,:out,:>,:"r<",:"rb<",:"r>",:"R>",:"R<",:"r>>",:rverb,:"rb>>",:rbverb,:"jl>>",:jlverb,:"jl>",:"jl<",:"sh<",:"rb>",:"?",:tag,:"??",:yield,:>>,:"=",:"+",:<<,:"txtl>",:"md>",:"adoc>",:"ttm>",:"html>",:"tex>",:"_>"
|
|
1060
1060
|
code = blck[i..-1].unshift(:blck)
|
|
1061
1061
|
when :","
|
|
1062
1062
|
i,*b2=next_block(blck,i)
|
|
@@ -2138,6 +2138,7 @@ p call
|
|
|
2138
2138
|
def do_jl(tex,blck,filter)
|
|
2139
2139
|
return unless Dyndoc.cfg_dyn[:langs].include? :jl
|
|
2140
2140
|
## jlBlock stuff
|
|
2141
|
+
## Dyndoc.warn "do_jl",blck
|
|
2141
2142
|
as_default_tmpl_mngr! if
|
|
2142
2143
|
dynBlock=dynBlock_in_doLangBlock?(blck)
|
|
2143
2144
|
if dynBlock
|
|
@@ -2161,7 +2162,7 @@ p call
|
|
|
2161
2162
|
as_default_tmpl_mngr!
|
|
2162
2163
|
tex << JLServer.outputs(code,:block => true)
|
|
2163
2164
|
else
|
|
2164
|
-
JLServer.
|
|
2165
|
+
JLServer.outputs(code)
|
|
2165
2166
|
end
|
|
2166
2167
|
## revert all the stuff
|
|
2167
2168
|
if dynBlock
|
|
@@ -2171,6 +2172,15 @@ p call
|
|
|
2171
2172
|
filter.outType=nil
|
|
2172
2173
|
end
|
|
2173
2174
|
|
|
2175
|
+
def do_sh(tex,blck,filter)
|
|
2176
|
+
#Dyndoc.warn "do_sh: blck ";p blck[1..-1]
|
|
2177
|
+
filter.outType="none"
|
|
2178
|
+
code=parse(blck[1..-1],filter)
|
|
2179
|
+
%x[ #{code} ]
|
|
2180
|
+
#Dyndoc.warn "do_sh: code ";p code
|
|
2181
|
+
filter.outType=nil
|
|
2182
|
+
end
|
|
2183
|
+
|
|
2174
2184
|
def do_m(tex,blck,filter)
|
|
2175
2185
|
newblck=blck[0]
|
|
2176
2186
|
# Dyndoc.warn "do_m";p blck
|
data/share/julia/dynArray.jl
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
|
|
3
3
|
module Dyndoc
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
using Main.Ruby
|
|
7
|
+
|
|
8
|
+
import Base.setindex!,Base.getindex,Base.IO,Base.show #,Base.showarray
|
|
9
|
+
import Main.Ruby.start,Main.Ruby.stop,Main.Ruby.run,Main.Ruby.alive
|
|
7
10
|
|
|
8
11
|
export DynVector,DynArray,getindex,setindex!,show,Vector,sync,getkey
|
|
9
12
|
|
|
@@ -11,11 +14,11 @@ export DynVector,DynArray,getindex,setindex!,show,Vector,sync,getkey
|
|
|
11
14
|
# when change on the vector occurs
|
|
12
15
|
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
mutable struct DynVector
|
|
15
18
|
ary::Vector
|
|
16
19
|
key::String
|
|
17
20
|
|
|
18
|
-
DynVector(a::Vector,k::String)=(x=new();x.ary=a;x.key=k;x)
|
|
21
|
+
#DynVector(a::Vector,k::String)=(x=new();x.ary=a;x.key=k;x)
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
function getindex(dynvect::DynVector,i::Integer)
|
|
@@ -31,13 +34,12 @@ function setindex!(dynvect::DynVector,value,i::Integer)
|
|
|
31
34
|
end
|
|
32
35
|
end
|
|
33
36
|
|
|
34
|
-
show(io::IO,dynvect::DynVector)=
|
|
37
|
+
show(io::IO,dynvect::DynVector)=show(io,dynvect.ary)
|
|
35
38
|
|
|
36
39
|
# gather all the julia vectors connected to dyndoc.
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
mutable struct DynArray
|
|
39
42
|
vars::Dict
|
|
40
|
-
|
|
41
43
|
DynArray()=(x=new();x.vars=Dict();x)
|
|
42
44
|
end
|
|
43
45
|
|
data/share/julia/dyndoc.jl
CHANGED
|
@@ -1,87 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# res=Any[] #Dict{AbstractString,Any}()
|
|
7
|
-
# for l=split(cmd,"\n")
|
|
8
|
-
# #println("l => ",l)
|
|
9
|
-
# push!(cmd0,l)
|
|
10
|
-
# pcmd0=Base.parse_input_line(join(cmd0,"\n"))
|
|
11
|
-
# #print(join(cmd0,"\n")*":");println(pcmd0)
|
|
12
|
-
# add = typeof(pcmd0)==Expr && pcmd0.head == :continue
|
|
13
|
-
# if !add
|
|
14
|
-
# #print("ici:")
|
|
15
|
-
# #println(Base.eval(pcmd0))
|
|
16
|
-
# push!(res,(join(cmd0,"\n"),eval(pcmd0)))
|
|
17
|
-
# cmd0=AbstractString[]
|
|
18
|
-
# end
|
|
19
|
-
# #println(res)
|
|
20
|
-
# end
|
|
21
|
-
# res
|
|
22
|
-
# end
|
|
23
|
-
|
|
24
|
-
module DyndocSandbox
|
|
25
|
-
importall Ruby
|
|
26
|
-
importall Dyndoc
|
|
1
|
+
module Dyndoc2Sandbox
|
|
2
|
+
import Main.Ruby.run,Main.Ruby.alive
|
|
3
|
+
import Main.Dyndoc.DynVector,Main.Dyndoc.DynArray,Main.Dyndoc.getindex,Main.Dyndoc.setindex!,Main.Dyndoc.show,Main.Dyndoc.Vector,Main.Dyndoc.sync,Main.Dyndoc.getkey
|
|
4
|
+
using InteractiveUtils
|
|
5
|
+
end
|
|
27
6
|
|
|
28
|
-
# Replace OUTPUT_STREAM references so we can capture output.
|
|
29
|
-
OUTPUT_STREAM = IOBuffer()
|
|
30
|
-
print(x) = Base.print(OUTPUT_STREAM, x)
|
|
31
|
-
println(x) = Base.println(OUTPUT_STREAM, x)
|
|
32
7
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
emit(mime, data) = push!(MIME_OUTPUT, (mime, data))
|
|
8
|
+
function replace_dyndoc2sandbox(txt)
|
|
9
|
+
replace(replace(txt,"Main.Dyndoc2Sandbox." => ""),"Main.Dyndoc2Sandbox" => "Main")
|
|
36
10
|
end
|
|
37
11
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
12
|
+
function echo_repl_julia(res)
|
|
13
|
+
# buf = IOBuffer();
|
|
14
|
+
# td = TextDisplay(buf);
|
|
15
|
+
# display(td, res);
|
|
16
|
+
# takebuf_string(buf)
|
|
17
|
+
#println(typeof(res))
|
|
18
|
+
replace_dyndoc2sandbox(repr("text/plain",res))
|
|
44
19
|
end
|
|
45
20
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
21
|
+
## Rmk: The process is based on what is done in weave.jl (src/run.jl)
|
|
22
|
+
getstdout() = stdout #Base.STDOUT
|
|
23
|
+
function capture_output_expr(expr)
|
|
24
|
+
#oldSTDOUT = STDOUT
|
|
25
|
+
oldSTDOUT = getstdout()
|
|
26
|
+
out = nothing
|
|
27
|
+
obj = nothing
|
|
28
|
+
rw, wr = redirect_stdout()
|
|
29
|
+
reader = @async read(rw, String) # @async readstring(rw)
|
|
30
|
+
try
|
|
31
|
+
obj = Core.eval(Dyndoc2Sandbox, expr)
|
|
32
|
+
obj != nothing && display(obj)
|
|
33
|
+
#catch E
|
|
34
|
+
# throw_errors && throw(E)
|
|
35
|
+
# display(E)
|
|
36
|
+
# @warn("ERROR: $(typeof(E)) occurred, including output in Weaved document")
|
|
37
|
+
|
|
38
|
+
finally
|
|
39
|
+
redirect_stdout(oldSTDOUT)
|
|
40
|
+
close(wr)
|
|
41
|
+
out = fetch(reader) #wait(reader)
|
|
42
|
+
close(rw)
|
|
43
|
+
end
|
|
44
|
+
return (obj, out)
|
|
52
45
|
end
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
# module DyndocSandbox
|
|
56
|
-
# # Copied from Gadfly.jl/src/weave.jl
|
|
57
|
-
# # Replace OUTPUT_STREAM references so we can capture output.
|
|
58
|
-
# OUTPUT_STREAM = IOString()
|
|
59
|
-
# print(x) = Base.print(OUTPUT_STREAM, x)
|
|
60
|
-
# println(x) = Base.println(OUTPUT_STREAM, x)
|
|
61
|
-
|
|
62
|
-
# function eval(expr)
|
|
63
|
-
# result = try
|
|
64
|
-
# Base.eval(DyndocSandbox, expr)
|
|
65
|
-
# seek(DyndocSandbox.OUTPUT_STREAM, 0)
|
|
66
|
-
# output = takebuf_string(DyndocSandbox.OUTPUT_STREAM)
|
|
67
|
-
# truncate(DyndocSandbox.OUTPUT_STREAM, 0)
|
|
68
|
-
# output
|
|
69
|
-
# catch e
|
|
70
|
-
# io = IOBuffer()
|
|
71
|
-
# print(io, "ERROR: ")
|
|
72
|
-
# Base.error_show(io, e)
|
|
73
|
-
# tmp = bytestring(io)
|
|
74
|
-
# close(io)
|
|
75
|
-
# tmp
|
|
76
|
-
# end
|
|
77
|
-
# result
|
|
78
|
-
# end
|
|
79
|
-
# end
|
|
80
|
-
|
|
81
|
-
function capture_julia(cmd::AbstractString)
|
|
47
|
+
function capture_output_julia(cmd::AbstractString)
|
|
82
48
|
add,cmd0=true,AbstractString[]
|
|
83
49
|
res=Any[] #Dict{AbstractString,Any}()
|
|
84
50
|
#println(cmd)
|
|
51
|
+
#cmd=replace(cmd,r"\$","\$")
|
|
52
|
+
|
|
85
53
|
for l=split(cmd,"\n")
|
|
86
54
|
#println("l => ",l)
|
|
87
55
|
push!(cmd0,l)
|
|
@@ -91,17 +59,18 @@ function capture_julia(cmd::AbstractString)
|
|
|
91
59
|
if !add
|
|
92
60
|
#print("ici:")
|
|
93
61
|
#println(Base.eval(pcmd0))
|
|
94
|
-
result,error = "",""
|
|
62
|
+
result,error,out = "","",""
|
|
95
63
|
try
|
|
96
|
-
result=
|
|
64
|
+
result,out=capture_output_expr(pcmd0)
|
|
97
65
|
catch e
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
66
|
+
#io = IOBuffer()
|
|
67
|
+
#print(io, "ERROR: ")
|
|
68
|
+
#Base.error_show(io, e)
|
|
69
|
+
error = "ERROR: $(sprint(showerror,e))"
|
|
70
|
+
#close(io)
|
|
71
|
+
end
|
|
72
|
+
println(l)
|
|
73
|
+
push!(res,(join(cmd0,"\n"), echo_repl_julia(result),replace_dyndoc2sandbox(out),replace_dyndoc2sandbox(error),""))
|
|
105
74
|
cmd0=AbstractString[]
|
|
106
75
|
end
|
|
107
76
|
#println(res)
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
#cmd="a=1\n(a)\nfor i in 1:3\nprintln(i)\nend"
|
|
2
|
+
|
|
3
|
+
# # Unused! See capture_julia
|
|
4
|
+
# function capture_cmd(cmd::AbstractString)
|
|
5
|
+
# add,cmd0=true,AbstractString[]
|
|
6
|
+
# res=Any[] #Dict{AbstractString,Any}()
|
|
7
|
+
# for l=split(cmd,"\n")
|
|
8
|
+
# #println("l => ",l)
|
|
9
|
+
# push!(cmd0,l)
|
|
10
|
+
# pcmd0=Base.parse_input_line(join(cmd0,"\n"))
|
|
11
|
+
# #print(join(cmd0,"\n")*":");println(pcmd0)
|
|
12
|
+
# add = typeof(pcmd0)==Expr && pcmd0.head == :continue
|
|
13
|
+
# if !add
|
|
14
|
+
# #print("ici:")
|
|
15
|
+
# #println(Base.eval(pcmd0))
|
|
16
|
+
# push!(res,(join(cmd0,"\n"),eval(pcmd0)))
|
|
17
|
+
# cmd0=AbstractString[]
|
|
18
|
+
# end
|
|
19
|
+
# #println(res)
|
|
20
|
+
# end
|
|
21
|
+
# res
|
|
22
|
+
# end
|
|
23
|
+
|
|
24
|
+
module DyndocSandbox
|
|
25
|
+
import Main.Ruby.start,Main.Ruby.stop,Main.Ruby.run,Main.Ruby.alive
|
|
26
|
+
import Main.Dyndoc.DynVector,Main.Dyndoc.DynArray,Main.Dyndoc.getindex,Main.Dyndoc.setindex!,Main.Dyndoc.show,Main.Dyndoc.Vector,Main.Dyndoc.sync,Main.Dyndoc.getkey
|
|
27
|
+
|
|
28
|
+
# Replace OUTPUT_STREAM references so we can capture output.
|
|
29
|
+
OUTPUT_STREAM = IOBuffer()
|
|
30
|
+
print(x) = Base.print(OUTPUT_STREAM, x)
|
|
31
|
+
println(x) = Base.println(OUTPUT_STREAM, x)
|
|
32
|
+
|
|
33
|
+
# Output
|
|
34
|
+
MIME_OUTPUT = Array(Tuple, 0)
|
|
35
|
+
emit(mime, data) = push!(MIME_OUTPUT, (mime, data))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
function get_stdout_iobuffer()
|
|
39
|
+
#seek(DyndocSandbox.OUTPUT_STREAM, 0)
|
|
40
|
+
#jl4rb_out =
|
|
41
|
+
takebuf_string(DyndocSandbox.OUTPUT_STREAM)
|
|
42
|
+
#truncate(DyndocSandbox.OUTPUT_STREAM, 0)
|
|
43
|
+
#jl4rb_out
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
function get_stderr_iobuffer()
|
|
47
|
+
#jl4rb_out = takebuf_string(STDERR.buffer)
|
|
48
|
+
#jl4rb_out
|
|
49
|
+
## THIS FAILS WHEN DYNDOC DAEMONIZED SO AUTOMATIC EMPTY RESULT for now
|
|
50
|
+
## MAYBE TO DELETE SOON!
|
|
51
|
+
""
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# export weave
|
|
55
|
+
# module DyndocSandbox
|
|
56
|
+
# # Copied from Gadfly.jl/src/weave.jl
|
|
57
|
+
# # Replace OUTPUT_STREAM references so we can capture output.
|
|
58
|
+
# OUTPUT_STREAM = IOString()
|
|
59
|
+
# print(x) = Base.print(OUTPUT_STREAM, x)
|
|
60
|
+
# println(x) = Base.println(OUTPUT_STREAM, x)
|
|
61
|
+
|
|
62
|
+
# function eval(expr)
|
|
63
|
+
# result = try
|
|
64
|
+
# Base.eval(DyndocSandbox, expr)
|
|
65
|
+
# seek(DyndocSandbox.OUTPUT_STREAM, 0)
|
|
66
|
+
# output = takebuf_string(DyndocSandbox.OUTPUT_STREAM)
|
|
67
|
+
# truncate(DyndocSandbox.OUTPUT_STREAM, 0)
|
|
68
|
+
# output
|
|
69
|
+
# catch e
|
|
70
|
+
# io = IOBuffer()
|
|
71
|
+
# print(io, "ERROR: ")
|
|
72
|
+
# Base.error_show(io, e)
|
|
73
|
+
# tmp = bytestring(io)
|
|
74
|
+
# close(io)
|
|
75
|
+
# tmp
|
|
76
|
+
# end
|
|
77
|
+
# result
|
|
78
|
+
# end
|
|
79
|
+
# end
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
function capture_julia(cmd::AbstractString)
|
|
83
|
+
add,cmd0=true,AbstractString[]
|
|
84
|
+
res=Any[] #Dict{AbstractString,Any}()
|
|
85
|
+
#println(cmd)
|
|
86
|
+
#cmd=replace(cmd,r"\$","\$")
|
|
87
|
+
# for standard redirection
|
|
88
|
+
##OUT: (outRead, outWrite) = redirect_stdout()
|
|
89
|
+
for l=split(cmd,"\n")
|
|
90
|
+
#println("l => ",l)
|
|
91
|
+
push!(cmd0,l)
|
|
92
|
+
pcmd0=Base.parse_input_line(join(cmd0,"\n"))
|
|
93
|
+
#print(join(cmd0,"\n")*":");println(pcmd0)
|
|
94
|
+
add = typeof(pcmd0)==Expr && pcmd0.head == :incomplete
|
|
95
|
+
if !add
|
|
96
|
+
#print("ici:")
|
|
97
|
+
#println(Base.eval(pcmd0))
|
|
98
|
+
result,error = "",""
|
|
99
|
+
try
|
|
100
|
+
result=eval(DyndocSandbox, pcmd0)
|
|
101
|
+
catch e
|
|
102
|
+
#io = IOBuffer()
|
|
103
|
+
#print(io, "ERROR: ")
|
|
104
|
+
#Base.error_show(io, e)
|
|
105
|
+
error = "Error: $(string(e))"
|
|
106
|
+
#close(io)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
##OUT: data_out = readavailable(outRead)
|
|
110
|
+
|
|
111
|
+
##OUT: push!(res,(join(cmd0,"\n"),echo_repl_julia(result),get_stdout_iobuffer(),data_out,error,get_stderr_iobuffer()))
|
|
112
|
+
push!(res,(join(cmd0,"\n"),echo_repl_julia(result),get_stdout_iobuffer(),error,get_stderr_iobuffer()))
|
|
113
|
+
cmd0=AbstractString[]
|
|
114
|
+
end
|
|
115
|
+
#println(res)
|
|
116
|
+
end
|
|
117
|
+
##OUT: close(outWrite);close(outRead)
|
|
118
|
+
res
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
module Dyndoc2Sandbox
|
|
123
|
+
import Main.Ruby.run,Main.Ruby.alive
|
|
124
|
+
import Main.Dyndoc.DynVector,Main.Dyndoc.DynArray,Main.Dyndoc.getindex,Main.Dyndoc.setindex!,Main.Dyndoc.show,Main.Dyndoc.Vector,Main.Dyndoc.sync,Main.Dyndoc.getkey
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
function echo_repl_julia(res)
|
|
128
|
+
buf = IOBuffer();
|
|
129
|
+
td = TextDisplay(buf);
|
|
130
|
+
display(td, res);
|
|
131
|
+
takebuf_string(buf)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
## Rmk: The process is based on what is done in weave.jl (src/run.jl)
|
|
135
|
+
getstdout() = stdout #Base.STDOUT
|
|
136
|
+
function capture_output_expr(expr)
|
|
137
|
+
#oldSTDOUT = STDOUT
|
|
138
|
+
oldSTDOUT = getstdout()
|
|
139
|
+
out = nothing
|
|
140
|
+
obj = nothing
|
|
141
|
+
rw, wr = redirect_stdout()
|
|
142
|
+
reader = @async read(rw, String) # @async readstring(rw)
|
|
143
|
+
try
|
|
144
|
+
obj = eval(Dyndoc2Sandbox, expr)
|
|
145
|
+
obj != nothing && display(obj)
|
|
146
|
+
catch E
|
|
147
|
+
throw_errors && throw(E)
|
|
148
|
+
display(E)
|
|
149
|
+
@warn("ERROR: $(typeof(E)) occurred, including output in Weaved document")
|
|
150
|
+
|
|
151
|
+
finally
|
|
152
|
+
redirect_stdout(oldSTDOUT)
|
|
153
|
+
close(wr)
|
|
154
|
+
out = wait(reader)
|
|
155
|
+
close(rw)
|
|
156
|
+
end
|
|
157
|
+
return (obj, out)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
function capture_output_julia(cmd::AbstractString)
|
|
161
|
+
add,cmd0=true,AbstractString[]
|
|
162
|
+
res=Any[] #Dict{AbstractString,Any}()
|
|
163
|
+
#println(cmd)
|
|
164
|
+
#cmd=replace(cmd,r"\$","\$")
|
|
165
|
+
|
|
166
|
+
for l=split(cmd,"\n")
|
|
167
|
+
#println("l => ",l)
|
|
168
|
+
push!(cmd0,l)
|
|
169
|
+
pcmd0=Base.parse_input_line(join(cmd0,"\n"))
|
|
170
|
+
#print(join(cmd0,"\n")*":");println(pcmd0)
|
|
171
|
+
add = typeof(pcmd0)==Expr && pcmd0.head == :incomplete
|
|
172
|
+
if !add
|
|
173
|
+
#print("ici:")
|
|
174
|
+
#println(Base.eval(pcmd0))
|
|
175
|
+
result,error,out = "","",""
|
|
176
|
+
try
|
|
177
|
+
result,out=capture_output_expr(pcmd0)
|
|
178
|
+
catch e
|
|
179
|
+
#io = IOBuffer()
|
|
180
|
+
#print(io, "ERROR: ")
|
|
181
|
+
#Base.error_show(io, e)
|
|
182
|
+
error = "Error: $(string(e))"
|
|
183
|
+
#close(io)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
push!(res,(join(cmd0,"\n"),echo_repl_julia(result),out,error,""))
|
|
187
|
+
cmd0=AbstractString[]
|
|
188
|
+
end
|
|
189
|
+
#println(res)
|
|
190
|
+
end
|
|
191
|
+
res
|
|
192
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
|
|
2
|
+
## Inspired from the excellent weave.jl
|
|
3
|
+
|
|
4
|
+
using Compat
|
|
5
|
+
|
|
6
|
+
#Contains report global properties
|
|
7
|
+
mutable struct DyndocReport <: AbstractDisplay
|
|
8
|
+
#cwd::AbstractString
|
|
9
|
+
#basename::AbstractString
|
|
10
|
+
#formatdict::Dict{Symbol,Any}
|
|
11
|
+
#pending_code::AbstractString
|
|
12
|
+
#cur_result::AbstractString
|
|
13
|
+
#rich_output::AbstractString
|
|
14
|
+
fignum::Int
|
|
15
|
+
figures::Array{AbstractString}
|
|
16
|
+
#term_state::Symbol
|
|
17
|
+
#cur_chunk
|
|
18
|
+
mimetypes::Array{AbstractString}
|
|
19
|
+
# first_plot::Bool
|
|
20
|
+
#header_script::String
|
|
21
|
+
#throw_errors::Bool
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#function Report(cwd, basename, formatdict, mimetypes, throw_errors)
|
|
25
|
+
# Report(cwd, basename, formatdict, "", "", "", 1, AbstractString[], :text, nothing,
|
|
26
|
+
# mimetypes, true, "", throw_errors)
|
|
27
|
+
#end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
#Default mimetypes in order, can be overridden for some inside `run method` formats
|
|
31
|
+
const default_mime_types = ["image/svg+xml", "image/png", "text/html", "text/plain"]
|
|
32
|
+
#const default_mime_types = ["image/png", "image/svg+xml", "text/html", "text/plain"]
|
|
33
|
+
#From IJulia as a reminder
|
|
34
|
+
#const supported_mime_types = [ "text/html", "text/latex", "image/svg+xml", "image/png", "image/jpeg", "text/plain", "text/markdown" ]
|
|
35
|
+
|
|
36
|
+
function Base.display(report::DyndocReport, data)
|
|
37
|
+
#Set preferred mimetypes for report based on format
|
|
38
|
+
for m in report.mimetypes
|
|
39
|
+
if showable(m, data)
|
|
40
|
+
try
|
|
41
|
+
if !istextmime(m)
|
|
42
|
+
Compat.invokelatest(display, report, m, data)
|
|
43
|
+
elseif report.cur_chunk.options[:term]
|
|
44
|
+
Compat.invokelatest(display, report, "text/plain", data)
|
|
45
|
+
else
|
|
46
|
+
Compat.invokelatest(display, report, m, data)
|
|
47
|
+
end
|
|
48
|
+
catch e
|
|
49
|
+
throw(e)
|
|
50
|
+
@warn("Failed to display data in \"$m\" format")
|
|
51
|
+
continue
|
|
52
|
+
end
|
|
53
|
+
break
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
function Base.display(report::DyndocReport, m::MIME"image/png", data)
|
|
59
|
+
figname = add_figure(report, data, m, ".png")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
function Base.display(report::DyndocReport, m::MIME"image/svg+xml", data)
|
|
63
|
+
figname = add_figure(report, data, m, ".svg")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
function Base.display(report::DyndocReport, m::MIME"application/pdf", data)
|
|
67
|
+
figname = add_figure(report, data, m, ".pdf")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#Text is written to stdout, called from "term" mode chunks
|
|
71
|
+
function Base.display(report::DyndocReport, m::MIME"text/plain", data)
|
|
72
|
+
io = PipeBuffer()
|
|
73
|
+
show(IOContext(io, :limit => true), m, data)
|
|
74
|
+
flush(io)
|
|
75
|
+
s = read(io, String)
|
|
76
|
+
close(io)
|
|
77
|
+
println(s)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
function Base.display(report::DyndocReport, m::MIME"text/plain", data::Exception)
|
|
81
|
+
println("Error: " * sprint(showerror, data))
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
function Base.display(report::DyndocReport, m::MIME"text/html", data::Exception)
|
|
85
|
+
report.rich_output = sprint(show, m, data)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
function Base.show(io, m::MIME"text/html", data::Exception)
|
|
89
|
+
println(io ,"<pre class=\"julia-error\">")
|
|
90
|
+
println(io, Markdown.htmlesc("ERROR: " * sprint(showerror, data)))
|
|
91
|
+
println(io ,"</pre>")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
#Catch "rich_output"
|
|
95
|
+
function Base.display(report::DyndocReport, m::MIME"text/html", data)
|
|
96
|
+
s = repr(m, data)
|
|
97
|
+
report.rich_output *= "\n" * s
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
#Catch "rich_output"
|
|
101
|
+
function Base.display(report::DyndocReport, m::MIME"text/markdown", data)
|
|
102
|
+
s = repr(m, data)
|
|
103
|
+
report.rich_output *= "\n" * s
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
function Base.display(report::DyndocReport, m::MIME"text/latex", data)
|
|
107
|
+
s = repr(m, data)
|
|
108
|
+
report.rich_output *= "\n" * s
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
"""Add saved figure name to results and return the name"""
|
|
112
|
+
function add_figure(report::DyndocReport, data, m, ext)
|
|
113
|
+
chunk = report.cur_chunk
|
|
114
|
+
full_name, rel_name = get_figname(report, chunk, ext = ext)
|
|
115
|
+
|
|
116
|
+
open(full_name, "w") do io
|
|
117
|
+
if ext == ".pdf"
|
|
118
|
+
write(io, repr(m, data))
|
|
119
|
+
else
|
|
120
|
+
show(io, m, data)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
push!(report.figures, rel_name)
|
|
125
|
+
report.fignum += 1
|
|
126
|
+
return full_name
|
|
127
|
+
end
|
data/share/julia/ruby.jl
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
module Ruby
|
|
4
|
-
|
|
4
|
+
using Libdl
|
|
5
5
|
librb=Libdl.dlopen(("JULIA_RUBYLIB_PATH" in keys(ENV)) ? ENV["JULIA_RUBYLIB_PATH"] : "/usr/lib/libruby")
|
|
6
6
|
|
|
7
7
|
export start,stop,run,alive
|
|
@@ -9,20 +9,20 @@ module Ruby
|
|
|
9
9
|
global ruby_alive=false
|
|
10
10
|
|
|
11
11
|
function start()
|
|
12
|
-
ccall(Libdl.dlsym(librb,:ruby_init),
|
|
13
|
-
ccall(Libdl.dlsym(librb,:ruby_init_loadpath),
|
|
12
|
+
ccall(Libdl.dlsym(librb,:ruby_init),Cvoid,())
|
|
13
|
+
ccall(Libdl.dlsym(librb,:ruby_init_loadpath),Cvoid,())
|
|
14
14
|
ruby_alive=true
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
function stop()
|
|
18
|
-
ccall(Libdl.dlsym(librb,:ruby_finalize),
|
|
18
|
+
ccall(Libdl.dlsym(librb,:ruby_finalize),Cvoid,())
|
|
19
19
|
ruby_alive=false
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
function run(code::AbstractString)
|
|
23
23
|
state=1 #not modified then
|
|
24
24
|
##println(code)
|
|
25
|
-
res=ccall(Libdl.dlsym(librb,:rb_eval_string_protect),Ptr{UInt64},(Ptr{UInt8},
|
|
25
|
+
res=ccall(Libdl.dlsym(librb,:rb_eval_string_protect),Ptr{UInt64},(Ptr{UInt8},Ref{UInt32}),string(code),state)
|
|
26
26
|
return nothing
|
|
27
27
|
end
|
|
28
28
|
|
metadata
CHANGED
|
@@ -1,98 +1,63 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dyndoc-ruby-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- CQLS
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: configliere
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '0.4'
|
|
20
|
-
- -
|
|
20
|
+
- - ">="
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
22
|
version: 0.4.18
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
|
-
- - ~>
|
|
27
|
+
- - "~>"
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
29
|
version: '0.4'
|
|
30
|
-
- -
|
|
30
|
+
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: 0.4.18
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: ultraviolet
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
-
- -
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '1.0'
|
|
40
|
-
- - '>='
|
|
37
|
+
- - ">="
|
|
41
38
|
- !ruby/object:Gem::Version
|
|
42
39
|
version: 1.0.0
|
|
40
|
+
- - "~>"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '1.0'
|
|
43
43
|
type: :runtime
|
|
44
44
|
prerelease: false
|
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
46
|
requirements:
|
|
47
|
-
- -
|
|
48
|
-
- !ruby/object:Gem::Version
|
|
49
|
-
version: '1.0'
|
|
50
|
-
- - '>='
|
|
47
|
+
- - ">="
|
|
51
48
|
- !ruby/object:Gem::Version
|
|
52
49
|
version: 1.0.0
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
- - "~>"
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '1.0'
|
|
53
|
+
description: " Provide templating in text document.\n"
|
|
55
54
|
email: rdrouilh@gmail.com
|
|
56
55
|
executables: []
|
|
57
56
|
extensions: []
|
|
58
57
|
extra_rdoc_files: []
|
|
59
58
|
files:
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
- lib/dyndoc/base/filter/call.rb
|
|
63
|
-
- lib/dyndoc/base/filter/filter_mngr.rb
|
|
64
|
-
- lib/dyndoc/base/filter/server.rb
|
|
65
|
-
- lib/dyndoc/base/filters.rb
|
|
66
|
-
- lib/dyndoc/base/helpers.rb
|
|
67
|
-
- lib/dyndoc/base/helpers/core.rb
|
|
68
|
-
- lib/dyndoc/base/helpers/parser.rb
|
|
69
|
-
- lib/dyndoc/base/scanner.rb
|
|
70
|
-
- lib/dyndoc/base/tags.rb
|
|
71
|
-
- lib/dyndoc/base/tags/keys_mngr.rb
|
|
72
|
-
- lib/dyndoc/base/tags/part_tag.rb
|
|
73
|
-
- lib/dyndoc/base/tags/tag_mngr.rb
|
|
74
|
-
- lib/dyndoc/base/tags/user_tag.rb
|
|
75
|
-
- lib/dyndoc/base/tmpl.rb
|
|
76
|
-
- lib/dyndoc/base/tmpl/eval.rb
|
|
77
|
-
- lib/dyndoc/base/tmpl/extension.rb
|
|
78
|
-
- lib/dyndoc/base/tmpl/manager.rb
|
|
79
|
-
- lib/dyndoc/base/tmpl/oop.rb
|
|
80
|
-
- lib/dyndoc/base/tmpl/parse_do.rb
|
|
81
|
-
- lib/dyndoc/base/tmpl/rbenvir.rb
|
|
82
|
-
- lib/dyndoc/base/utils.rb
|
|
83
|
-
- lib/dyndoc/common/dynArray.rb
|
|
84
|
-
- lib/dyndoc/common/file.rb
|
|
85
|
-
- lib/dyndoc/common/init.rb
|
|
86
|
-
- lib/dyndoc/common/tilt.rb
|
|
87
|
-
- lib/dyndoc/common/utils.rb
|
|
88
|
-
- lib/dyndoc/common/uv.rb
|
|
89
|
-
- lib/dyndoc/init/config.rb
|
|
90
|
-
- lib/dyndoc/init/home.rb
|
|
91
|
-
- lib/dyndoc/plugins/tex.rb
|
|
92
|
-
- lib/dyndoc/plugins/tex/beamer.rb
|
|
93
|
-
- lib/dyndoc/plugins/tex/tex_eval.rb
|
|
94
|
-
- lib/dyndoc/plugins/tex/tex_parse_do.rb
|
|
95
|
-
- lib/dyndoc/plugins/tex/tex_user_tag.rb
|
|
59
|
+
- dyndoc/Dyn/.postload
|
|
60
|
+
- dyndoc/Dyn/.preload
|
|
96
61
|
- dyndoc/Dyn/After.dyn
|
|
97
62
|
- dyndoc/Dyn/Base.dyn
|
|
98
63
|
- dyndoc/Dyn/Minimum.dyn
|
|
@@ -130,6 +95,8 @@ files:
|
|
|
130
95
|
- dyndoc/Style/Text/StdAlias.dyn
|
|
131
96
|
- dyndoc/Style/Text/StdTex.dyn
|
|
132
97
|
- dyndoc/Style/Text/Txt.dyn
|
|
98
|
+
- dyndoc/Tex/.postload
|
|
99
|
+
- dyndoc/Tex/.preload
|
|
133
100
|
- dyndoc/Tex/10pt_tmpl.tex
|
|
134
101
|
- dyndoc/Tex/11pt_tmpl.tex
|
|
135
102
|
- dyndoc/Tex/12pt_tmpl.tex
|
|
@@ -178,23 +145,58 @@ files:
|
|
|
178
145
|
- dyndoc/Tools/Web/TabBar.dyn
|
|
179
146
|
- dyndoc/Tools/Web/Ttm.dyn
|
|
180
147
|
- dyndoc/Tools/Web/Txtl.dyn
|
|
181
|
-
-
|
|
182
|
-
-
|
|
183
|
-
-
|
|
148
|
+
- dyndoc/Tools/julia/Fig.dyn
|
|
149
|
+
- lib/dyndoc-core.rb
|
|
150
|
+
- lib/dyndoc/base/envir.rb
|
|
151
|
+
- lib/dyndoc/base/filter/call.rb
|
|
152
|
+
- lib/dyndoc/base/filter/filter_mngr.rb
|
|
153
|
+
- lib/dyndoc/base/filter/server.rb
|
|
154
|
+
- lib/dyndoc/base/filters.rb
|
|
155
|
+
- lib/dyndoc/base/helpers.rb
|
|
156
|
+
- lib/dyndoc/base/helpers/core.rb
|
|
157
|
+
- lib/dyndoc/base/helpers/parser.rb
|
|
158
|
+
- lib/dyndoc/base/scanner.rb
|
|
159
|
+
- lib/dyndoc/base/tags.rb
|
|
160
|
+
- lib/dyndoc/base/tags/keys_mngr.rb
|
|
161
|
+
- lib/dyndoc/base/tags/part_tag.rb
|
|
162
|
+
- lib/dyndoc/base/tags/tag_mngr.rb
|
|
163
|
+
- lib/dyndoc/base/tags/user_tag.rb
|
|
164
|
+
- lib/dyndoc/base/tmpl.rb
|
|
165
|
+
- lib/dyndoc/base/tmpl/eval.rb
|
|
166
|
+
- lib/dyndoc/base/tmpl/extension.rb
|
|
167
|
+
- lib/dyndoc/base/tmpl/manager.rb
|
|
168
|
+
- lib/dyndoc/base/tmpl/oop.rb
|
|
169
|
+
- lib/dyndoc/base/tmpl/parse_do.rb
|
|
170
|
+
- lib/dyndoc/base/tmpl/rbenvir.rb
|
|
171
|
+
- lib/dyndoc/base/utils.rb
|
|
172
|
+
- lib/dyndoc/common/dynArray.rb
|
|
173
|
+
- lib/dyndoc/common/file.rb
|
|
174
|
+
- lib/dyndoc/common/init.rb
|
|
175
|
+
- lib/dyndoc/common/tilt.rb
|
|
176
|
+
- lib/dyndoc/common/utils.rb
|
|
177
|
+
- lib/dyndoc/common/uv.rb
|
|
178
|
+
- lib/dyndoc/init/config.rb
|
|
179
|
+
- lib/dyndoc/init/home.rb
|
|
180
|
+
- lib/dyndoc/plugins/tex.rb
|
|
181
|
+
- lib/dyndoc/plugins/tex/beamer.rb
|
|
182
|
+
- lib/dyndoc/plugins/tex/tex_eval.rb
|
|
183
|
+
- lib/dyndoc/plugins/tex/tex_parse_do.rb
|
|
184
|
+
- lib/dyndoc/plugins/tex/tex_user_tag.rb
|
|
184
185
|
- share/R/dyndocMsys2.R
|
|
185
186
|
- share/R/dyndocTools.R
|
|
186
187
|
- share/R/test.R
|
|
187
188
|
- share/R/tools/dynArray.R
|
|
188
189
|
- share/R/tools/dynCapture.R
|
|
189
190
|
- share/R/tools/dynMsys2.R
|
|
190
|
-
-
|
|
191
|
-
- dyndoc
|
|
192
|
-
-
|
|
193
|
-
-
|
|
191
|
+
- share/julia/dynArray.jl
|
|
192
|
+
- share/julia/dyndoc.jl
|
|
193
|
+
- share/julia/dyndocOLD.jl
|
|
194
|
+
- share/julia/dynreport.jl
|
|
195
|
+
- share/julia/ruby.jl
|
|
194
196
|
homepage: http://cqls.upmf-grenoble.fr
|
|
195
197
|
licenses:
|
|
196
198
|
- MIT
|
|
197
|
-
- GPL-2
|
|
199
|
+
- GPL-2.0
|
|
198
200
|
metadata: {}
|
|
199
201
|
post_install_message:
|
|
200
202
|
rdoc_options: []
|
|
@@ -202,18 +204,17 @@ require_paths:
|
|
|
202
204
|
- lib
|
|
203
205
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
206
|
requirements:
|
|
205
|
-
- -
|
|
207
|
+
- - ">="
|
|
206
208
|
- !ruby/object:Gem::Version
|
|
207
209
|
version: '0'
|
|
208
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
211
|
requirements:
|
|
210
|
-
- -
|
|
212
|
+
- - ">="
|
|
211
213
|
- !ruby/object:Gem::Version
|
|
212
214
|
version: '0'
|
|
213
215
|
requirements:
|
|
214
216
|
- none
|
|
215
|
-
|
|
216
|
-
rubygems_version: 2.0.14.1
|
|
217
|
+
rubygems_version: 3.0.6
|
|
217
218
|
signing_key:
|
|
218
219
|
specification_version: 4
|
|
219
220
|
summary: R and Ruby in text document
|