dyndoc-ruby-core 1.0.0

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.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/dyndoc/.DS_Store +0 -0
  3. data/dyndoc/Dyn/.postload +1 -0
  4. data/dyndoc/Dyn/.preload +1 -0
  5. data/dyndoc/Dyn/After.dyn +3 -0
  6. data/dyndoc/Dyn/Base.dyn +18 -0
  7. data/dyndoc/Dyn/Minimum.dyn +20 -0
  8. data/dyndoc/Model/Html/DefaultPost_html.dyn +5 -0
  9. data/dyndoc/Model/Html/DefaultPre_html.dyn +15 -0
  10. data/dyndoc/Model/Odt/DefaultPost_content.xml +3 -0
  11. data/dyndoc/Model/Odt/DefaultPost_tmpl_content.xml +3 -0
  12. data/dyndoc/Model/Odt/DefaultPre_content.xml +8 -0
  13. data/dyndoc/Model/Odt/DefaultPre_tmpl_content.xml +8 -0
  14. data/dyndoc/Model/Tex/ContentPost_tmpl.tex +1 -0
  15. data/dyndoc/Model/Tex/ContentPre_tmpl.tex +6 -0
  16. data/dyndoc/Model/Tex/DefaultPost_tmpl.tex +73 -0
  17. data/dyndoc/Model/Tex/DefaultPre_tmpl.tex +16 -0
  18. data/dyndoc/Model/Ttm/DefaultPost_tmpl.ttm +3 -0
  19. data/dyndoc/Model/Ttm/DefaultPre_tmpl.ttm +16 -0
  20. data/dyndoc/Std/Array.dyn +96 -0
  21. data/dyndoc/Std/Composer.dyn +38 -0
  22. data/dyndoc/Std/DevTag.dyn +101 -0
  23. data/dyndoc/Std/DynVar.dyn +23 -0
  24. data/dyndoc/Std/File.dyn +55 -0
  25. data/dyndoc/Std/Git.dyn +34 -0
  26. data/dyndoc/Std/List.dyn +46 -0
  27. data/dyndoc/Std/OOP.dyn +32 -0
  28. data/dyndoc/Std/Signal.dyn +18 -0
  29. data/dyndoc/Std/String.dyn +22 -0
  30. data/dyndoc/Std/Styles.dyn +1 -0
  31. data/dyndoc/Std/Test.dyn +282 -0
  32. data/dyndoc/Std/Utils.dyn +42 -0
  33. data/dyndoc/Std/Verb.dyn +5 -0
  34. data/dyndoc/Style/Notation/Math.dyn +7 -0
  35. data/dyndoc/Style/Notation/Stat/Classic.dyn +8 -0
  36. data/dyndoc/Style/Notation/Stat/Cqls.dyn +44 -0
  37. data/dyndoc/Style/Text/Std.dyn +5 -0
  38. data/dyndoc/Style/Text/StdAlias.dyn +3 -0
  39. data/dyndoc/Style/Text/StdTex.dyn +17 -0
  40. data/dyndoc/Style/Text/Txt.dyn +1 -0
  41. data/dyndoc/Tex/.postload +1 -0
  42. data/dyndoc/Tex/.preload +1 -0
  43. data/dyndoc/Tex/10pt_tmpl.tex +1 -0
  44. data/dyndoc/Tex/11pt_tmpl.tex +1 -0
  45. data/dyndoc/Tex/12pt_tmpl.tex +1 -0
  46. data/dyndoc/Tex/Article_tmpl.tex +1 -0
  47. data/dyndoc/Tex/Beamer.dyn_tex +35 -0
  48. data/dyndoc/Tex/BeamerHandout_tmpl.tex +2 -0
  49. data/dyndoc/Tex/Book_tmpl.tex +1 -0
  50. data/dyndoc/Tex/DefaultFirst_tmpl.tex +1 -0
  51. data/dyndoc/Tex/DefaultLast_tmpl.tex +8 -0
  52. data/dyndoc/Tex/Default_tmpl.tex +9 -0
  53. data/dyndoc/Tex/First_tmpl.tex +8 -0
  54. data/dyndoc/Tex/Fr_tmpl.tex +17 -0
  55. data/dyndoc/Tex/Header_tmpl.tex +3 -0
  56. data/dyndoc/Tex/InclGraph_tmpl.tex +19 -0
  57. data/dyndoc/Tex/InclSpatProc_tmpl.tex +70 -0
  58. data/dyndoc/Tex/InclSumMI_tmpl.tex +4 -0
  59. data/dyndoc/Tex/LargeA4_tmpl.tex +5 -0
  60. data/dyndoc/Tex/Last_tmpl.tex +1 -0
  61. data/dyndoc/Tex/Option_tmpl.tex +8 -0
  62. data/dyndoc/Tex/Png_tmpl.tex +1 -0
  63. data/dyndoc/Tex/RefCite2_tmpl.tex +16 -0
  64. data/dyndoc/Tex/RefCite_tmpl.tex +16 -0
  65. data/dyndoc/Tex/Report_tmpl.tex +1 -0
  66. data/dyndoc/Tex/Theorem_tmpl.tex +14 -0
  67. data/dyndoc/Tools/.DS_Store +0 -0
  68. data/dyndoc/Tools/Atom.dyn/index.dyn +42 -0
  69. data/dyndoc/Tools/AtomDyndocker.dyn/index.dyn +43 -0
  70. data/dyndoc/Tools/R/Fig.dyn +144 -0
  71. data/dyndoc/Tools/R/Tools.dyn +344 -0
  72. data/dyndoc/Tools/Tex/Beamer.dyn +204 -0
  73. data/dyndoc/Tools/Tex/BeamerSlide.dyn_tex +199 -0
  74. data/dyndoc/Tools/Tex/Pgf.dyn +115 -0
  75. data/dyndoc/Tools/Tex/Table.dyn +278 -0
  76. data/dyndoc/Tools/Tex/Tools.dyn +37 -0
  77. data/dyndoc/Tools/Tex/Verb.dyn +77 -0
  78. data/dyndoc/Tools/Web/.DS_Store +0 -0
  79. data/dyndoc/Tools/Web/Ace.dyn +54 -0
  80. data/dyndoc/Tools/Web/Code.dyn +129 -0
  81. data/dyndoc/Tools/Web/DHtmlX.dyn +39 -0
  82. data/dyndoc/Tools/Web/DataTable.dyn_html +354 -0
  83. data/dyndoc/Tools/Web/Html.dyn +286 -0
  84. data/dyndoc/Tools/Web/Html/JQuery.dyn +123 -0
  85. data/dyndoc/Tools/Web/Html/Styles.dyn +4 -0
  86. data/dyndoc/Tools/Web/JQueryTools.dyn +87 -0
  87. data/dyndoc/Tools/Web/Layout.dyn +86 -0
  88. data/dyndoc/Tools/Web/Layout/CQLS.dyn +6 -0
  89. data/dyndoc/Tools/Web/Layout/LJK.dyn +41 -0
  90. data/dyndoc/Tools/Web/TabBar.dyn +37 -0
  91. data/dyndoc/Tools/Web/Ttm.dyn +20 -0
  92. data/dyndoc/Tools/Web/Txtl.dyn +14 -0
  93. data/lib/dyndoc-core.rb +59 -0
  94. data/lib/dyndoc/base/envir.rb +541 -0
  95. data/lib/dyndoc/base/filter/call.rb +127 -0
  96. data/lib/dyndoc/base/filter/filter_mngr.rb +637 -0
  97. data/lib/dyndoc/base/filter/server.rb +882 -0
  98. data/lib/dyndoc/base/filters.rb +3 -0
  99. data/lib/dyndoc/base/helpers.rb +9 -0
  100. data/lib/dyndoc/base/helpers/core.rb +32 -0
  101. data/lib/dyndoc/base/helpers/parser.rb +188 -0
  102. data/lib/dyndoc/base/scanner.rb +886 -0
  103. data/lib/dyndoc/base/tags.rb +4 -0
  104. data/lib/dyndoc/base/tags/keys_mngr.rb +401 -0
  105. data/lib/dyndoc/base/tags/part_tag.rb +194 -0
  106. data/lib/dyndoc/base/tags/tag_mngr.rb +125 -0
  107. data/lib/dyndoc/base/tags/user_tag.rb +216 -0
  108. data/lib/dyndoc/base/tmpl.rb +6 -0
  109. data/lib/dyndoc/base/tmpl/eval.rb +581 -0
  110. data/lib/dyndoc/base/tmpl/extension.rb +337 -0
  111. data/lib/dyndoc/base/tmpl/manager.rb +450 -0
  112. data/lib/dyndoc/base/tmpl/oop.rb +57 -0
  113. data/lib/dyndoc/base/tmpl/parse_do.rb +2446 -0
  114. data/lib/dyndoc/base/tmpl/rbenvir.rb +54 -0
  115. data/lib/dyndoc/base/utils.rb +367 -0
  116. data/lib/dyndoc/common/dynArray.rb +234 -0
  117. data/lib/dyndoc/common/file.rb +52 -0
  118. data/lib/dyndoc/common/init.rb +2 -0
  119. data/lib/dyndoc/common/tilt.rb +149 -0
  120. data/lib/dyndoc/common/utils.rb +61 -0
  121. data/lib/dyndoc/common/uv.rb +163 -0
  122. data/lib/dyndoc/init/config.rb +296 -0
  123. data/lib/dyndoc/init/home.rb +9 -0
  124. data/lib/dyndoc/plugins/tex.rb +4 -0
  125. data/lib/dyndoc/plugins/tex/beamer.rb +208 -0
  126. data/lib/dyndoc/plugins/tex/tex_eval.rb +69 -0
  127. data/lib/dyndoc/plugins/tex/tex_parse_do.rb +25 -0
  128. data/lib/dyndoc/plugins/tex/tex_user_tag.rb +32 -0
  129. data/share/R/dyndocMsys2.R +5 -0
  130. data/share/R/dyndocTools.R +9 -0
  131. data/share/R/test.R +14 -0
  132. data/share/R/tools/dynArray.R +34 -0
  133. data/share/R/tools/dynCapture.R +84 -0
  134. data/share/R/tools/dynMsys2.R +54 -0
  135. data/share/julia/dynArray.jl +93 -0
  136. data/share/julia/dyndoc.jl +110 -0
  137. data/share/julia/ruby.jl +37 -0
  138. metadata +202 -0
Binary file
@@ -0,0 +1,42 @@
1
+ {#def]atomInit[#>]
2
+ {$,ScrollView,TextEditorView} = require "atom-space-pen-views"
3
+ fs = require 'fs-plus'
4
+ DyndocViewer = require fs.absolute "~/.atom/packages/dyndoc-viewer/lib/dyndoc-viewer"
5
+ [#def}
6
+
7
+ {#def]atomClass[#,]class[][#,]extends[]
8
+ [#,]view[][#,]init[][#,]body[][#<]view -> contents, init -> initialize, body -> rest of methods (often empty)
9
+ [#rb<]code,tab=""," "
10
+ code << "class " + #{=class}.strip
11
+ code << " extends " + #{=extends}.strip unless #{=extends}.strip.empty?
12
+ code << "\n"
13
+ if #{+?view}
14
+ code << tab << "@content: ->"
15
+ content = #{=view}.split("\n",-1).map{|l| #
16
+ l2=l.gsub(/@miniEditor\(([^\)]*)\)\s*\"(.*)\"\s*$/,'@subview "\1",new TextEditorView(mini: true,placeholderText: "\2")')
17
+ l2.gsub!(/@dyndoc\(([^\)]*)\)/,'@subview "\1",new DyndocViewer(editorId: "\1") ')
18
+ tab*2 + l2.gsub(/(\@[a-zA-Z0-9\-_\.]*)(\()([^\)]*)(\))/,'\1 outlet: "\3",')
19
+ }
20
+ code << content.join("\n") << "\n"
21
+ end
22
+ if #{+?init}
23
+ code << tab << "initialize: ->\n"
24
+ code << #{=init}.split("\n",-1).map{|l| tab*2+l}.join("\n") << "\n"
25
+ end
26
+ if #{+?body}
27
+ code << #{=body}.split("\n",-1).map{|l| tab+l}.join("\n") << "\n"
28
+ end
29
+ code << tab << "getTitle: ->\n" << tab*2 << '"' << #{=class}.strip << '"' << "\n"
30
+ code << tab << "getIconName: ->\n" << tab*2 << '"' << #{=class}.strip << '"' << "\n"
31
+ code << tab << "getUri: ->\n" << tab*2 << '"dyndoc-atom://' << #{=class}.strip << '"' << "\n"
32
+ [#rb>]code
33
+ [#def}
34
+
35
+ {#def]atomNew[#,]id[][#,]of[][#,]side[right]
36
+ [#rb<]code,tab=""," "
37
+ code << #{=id} << " = new " << #{=of} << "\n"
38
+ code << "console.log(\"ID:\")" << "\n"
39
+ code << "console.log(" + #{=id}+")" << "\n"
40
+ code << "atom.workspace.getActivePane().activateItem(" << #{=id} << ")\n"
41
+ [#rb>]code
42
+ [#def}
@@ -0,0 +1,43 @@
1
+ {#def]atomInit[#>]
2
+ {$,ScrollView,TextEditorView} = require "atom-space-pen-views"
3
+ fs = require 'fs-plus'
4
+ DyndockerViewer = require fs.absolute "~/.atom/packages/dyndocker/lib/dyndocker-viewer"
5
+ [#def}
6
+
7
+ {#def]atomClass[#,]class[][#,]extends[]
8
+ [#,]view[][#,]init[][#,]body[]
9
+ [#%]view -> contents, init -> initialize, body -> rest of methods (often empty)
10
+ [#rb<]code,tab=""," "
11
+ code << "class " + #{=class}.strip
12
+ code << " extends " + #{=extends}.strip unless #{=extends}.strip.empty?
13
+ code << "\n"
14
+ if #{+?view}
15
+ code << tab << "@content: ->"
16
+ content = #{=view}.split("\n",-1).map{|l| #
17
+ l2=l.gsub(/@miniEditor\(([^\)]*)\)\s*\"(.*)\"\s*$/,'@subview "\1",new TextEditorView(mini: true,placeholderText: "\2")')
18
+ l2.gsub!(/@dyndoc\(([^\)]*)\)/,'@subview "\1",new DyndockerViewer(editorId: "\1") ')
19
+ tab*2 + l2.gsub(/(\@[a-zA-Z0-9\-_\.]*)(\()([^\)]*)(\))/,'\1 outlet: "\3",')
20
+ }
21
+ code << content.join("\n") << "\n"
22
+ end
23
+ if #{+?init}
24
+ code << tab << "initialize: ->\n"
25
+ code << #{=init}.split("\n",-1).map{|l| tab*2+l}.join("\n") << "\n"
26
+ end
27
+ if #{+?body}
28
+ code << #{=body}.split("\n",-1).map{|l| tab+l}.join("\n") << "\n"
29
+ end
30
+ code << tab << "getTitle: ->\n" << tab*2 << '"' << #{=class}.strip << '"' << "\n"
31
+ code << tab << "getIconName: ->\n" << tab*2 << '"' << #{=class}.strip << '"' << "\n"
32
+ code << tab << "getUri: ->\n" << tab*2 << '"dyndoc-atom://' << #{=class}.strip << '"' << "\n"
33
+ [#rb>]code
34
+ [#def}
35
+
36
+ {#def]atomNew[#,]id[][#,]of[][#,]side[right]
37
+ [#rb<]code,tab=""," "
38
+ code << #{=id} << " = new " << #{=of} << "\n"
39
+ code << "console.log(\"ID:\")" << "\n"
40
+ code << "console.log(" + #{=id}+")" << "\n"
41
+ code << "atom.workspace.getActivePane().activateItem(" << #{=id} << ")\n"
42
+ [#rb>]code
43
+ [#def}
@@ -0,0 +1,144 @@
1
+ [#rb<]
2
+ $rfig=0
3
+ $rfig_exts={:png=>".png",:jpeg =>".jpg",:pdf=>".pdf"}
4
+ [#<]
5
+
6
+ {#def]rfig[#,] rcode[] [#,] img[]
7
+ [#,] deviceR[png] [#,] widthR[10] [#,] heightR[10][#,] unitR[cm][#,] resR[128] [#,] optR[]
8
+ [#,] include[true] [#,] optTex[scale=0.75]
9
+ [#,] newR[FALSE]
10
+ [#,] Renvir[Global]
11
+ [#?]{#dyndoc_mode#} == :web[#rb<]p "ici"[#rb<]p "rfig web:"+#{=img}
12
+ [#<]{#if]#{0?img}[#=]img[public:rfig][#if}
13
+ {#if]#{=img}[0...7]=="public:" [#rb<]p "ii22"; imgName= #{=img}[7..-1]; p imgName
14
+ [#=]img[{#cqlsweb_auto_img]:{imgName}[#cqlsweb_auto_img}][#if}
15
+ {#if]:r{capabilities()["aqua"]}[#=]optR[type="quartz"][#if}
16
+ [#rb<]p "rfig web:"+#{=img}
17
+ [#?]else[#<]
18
+ {#if]#{0?img}[#=]img[:{File.join($dyn_rsrc,"img","rfig_:{$rfig+=1}:{$rfig_exts[:#{deviceR}]}")}]
19
+ [#else][#<]
20
+ {#if]File.dirname(#{=img})=="."[#>]img[:{File.join($dyn_rsrc,"img",#{=img})}][#if}
21
+ [#if}
22
+ [#?]end
23
+ [#<]{#if]File.basename(#{=img},".*")==File.basename(#{=img})[#>]img[#{img}:{$rfig_exts[:#{deviceR}]}][#}
24
+ [#rb<]
25
+ require 'fileutils'
26
+ imgdir=File.expand_path(File.dirname(#{=img}))
27
+ FileUtils.mkdir_p(imgdir) unless File.exists? imgdir
28
+ rcode=#{=rcode}.strip
29
+ Utils.clean_eol(rcode)
30
+ [#rb>]img[File.expand_path(#{=img})]
31
+ [#<]{#r]
32
+ if(#{newR} || !file.exists('#{img}')) {
33
+ #{deviceR}('#{img}',width=#{widthR},height=#{heightR}{#if]#{+?unitR}[#>],units="#{unitR}"[#}{#if]#{+?resR}[#>],res=#{resR}[#} {#if]#{+?optR}[#>],[#}#{optR})
34
+ :{rcode}
35
+ dev.off()
36
+ }[#in]#{Renvir}[#}
37
+ [#?] #{include} [#>]{#if]{#dyndoc_mode#} == :web[#>]{#if](File.exists? #{=img}) and (File.stat(#{=img}).size>0)[#>]<img src="{#cqlsweb_public_imgName]#{img}[#}" alt="rfig"/>[#else]<p>Error in the following figure R code!</p><code><pre>:{rcode}</pre></code>[#if}[#else][\includegraphics[#{optTex}]{#{img}}][#if}
38
+ [#}
39
+
40
+ {#hide] WITH SHORTHANDOFF
41
+ {#def]rfig[#,] rcode[] [#,] img[]
42
+ [#,] deviceR[png] [#,] widthR[10] [#,] heightR[10][#,] unitR[cm][#,] resR[128] [#,] optR[]
43
+ [#,] include[true] [#,] optTex[scale=0.75]
44
+ [#,] newR[FALSE]
45
+ [#,] Renvir[Global]
46
+ [#?]{#dyndoc_mode#} == :web[#rb<]p "ici"[#rb<]p "rfig web:"+#{=img}
47
+ [#<]{#if]#{0?img}[#=]img[public:rfig][#if}
48
+ {#if]#{=img}[0...7]=="public:" [#rb<]p "ii22"; imgName= #{=img}[7..-1]; p imgName
49
+ [#=]img[{#cqlsweb_auto_img]:{imgName}[#cqlsweb_auto_img}][#if}
50
+ {#if]:r{capabilities()["aqua"]}[#=]optR[type="quartz"][#if}
51
+ [#rb<]p "rfig web:"+#{=img}
52
+ [#?]else[#<]
53
+ {#if]#{0?img}[#=]img[:{File.join($dyn_rsrc,"img","rfig_:{$rfig+=1}:{$rfig_exts[:#{deviceR}]}")}]
54
+ [#else][#<]
55
+ {#if]File.dirname(#{=img})=="."[#>]img[:{File.join($dyn_rsrc,"img",#{=img})}][#if}
56
+ [#if}
57
+ [#?]end
58
+ [#<]{#if]File.basename(#{=img},".*")==File.basename(#{=img})[#>]img[#{img}:{$rfig_exts[:#{deviceR}]}][#}
59
+ [#rb<]
60
+ require 'fileutils'
61
+ imgdir=File.expand_path(File.dirname(#{=img}))
62
+ FileUtils.mkdir_p(imgdir) unless File.exists? imgdir
63
+ rcode=#{=rcode}.strip
64
+ Utils.clean_eol(rcode)
65
+ [#rb>]img[File.expand_path(#{=img})]
66
+ [#%]Very bad trip about (french) babel package and : (caractère actif latex) solved by \shorthandoff{:}
67
+ [#?]RUBY_PLATFORM =~ /mingw/ and (#{=_USEPACKAGE_} =~ /[^\[\]]*\[[^\[\]]*french[^\[\]]*\]\{babel\}/) and #{=img}.include? ":"[#=]shorthandoff[:ok][#?]end
68
+ [#<]{#r]
69
+ if(#{newR} || !file.exists('#{img}')) {
70
+ #{deviceR}('#{img}',width=#{widthR},height=#{heightR}{#if]#{+?unitR}[#>],units="#{unitR}"[#}{#if]#{+?resR}[#>],res=#{resR}[#} {#if]#{+?optR}[#>],[#}#{optR})
71
+ :{rcode}
72
+ dev.off()
73
+ }[#in]#{Renvir}[#}
74
+ [#?] #{include} [#>]{#if]{#dyndoc_mode#} == :web[#>]{#if](File.exists? #{=img}) and (File.stat(#{=img}).size>0)[#>]<img src="{#cqlsweb_public_imgName]#{img}[#}" alt="rfig"/>[#else]<p>Error in the following figure R code!</p><code><pre>:{rcode}</pre></code>[#if}[#else][{#if]#{shorthandoff}==:ok[#>]{\shorthandoff{:}[#if}\includegraphics[#{optTex}]{#{img}}{#if]#{shorthandoff}==:ok[#>]}[#if}][#if}
75
+ [#} [#hide}
76
+
77
+
78
+ {#def]rpng[#,] rcode[] [#,] img[]
79
+ [#,] widthR[15] [#,] heightR[15][#,] unitR[cm][#,] resR[72][#,] optR[]
80
+ [#,] include[true] [#,] optTex[scale=0.75]
81
+ [#,] newR[FALSE]
82
+ [#>][{#rfig]#{rcode}[#,]deviceR[png][#}]
83
+ [#}
84
+
85
+ {#def]img[#,] rcode[] [#,] img[]
86
+ [#,] widthR[15] [#,] heightR[15][#,] unitR[cm][#,] resR[72][#,] optR[]
87
+ [#,] optTex[scale=0.75]
88
+ [#,] newR[TRUE]
89
+ [#=]delete[FALSE]
90
+ [#?]Dyndoc.tmpl_mngr.fmtOutput == "tex"[#<]
91
+ {#if]#{0?img}[#=]img[:{File.join($dyn_rsrc,"img","rfig_:{$rfig+=1}:{$rfig_exts[:png]}")}]
92
+ [#else][#<]
93
+ {#if]File.dirname(#{=img})=="."[#>]img[:{File.join($dyn_rsrc,"img",#{=img})}][#if}
94
+ [#if}
95
+ [#?]Dyndoc.tmpl_mngr.fmtOutput == "html"[#<]
96
+ {#if]#{0?img}[#=]img[#r{tempfile(fileext=".png")}][#=]delete[TRUE][#if}
97
+ [#?]#{+?rcode}[#<]{#rpng]#{rcode}[#}[#?]end
98
+ [#R<]require(base64)
99
+ #print(#{=img})
100
+ codeimg<-img(#{=img})
101
+ #print(codeimg)
102
+ if(#{delete}) unlink(#{=img})
103
+ [#?]Dyndoc.tmpl_mngr.fmtOutput == "html"
104
+ [#>][#r{codeimg}]
105
+ [#?]Dyndoc.tmpl_mngr.fmtOutput == "tex"
106
+ [#>][\includegraphics[#{optTex}]{#{img}}]
107
+ [#}
108
+
109
+
110
+
111
+
112
+ {#def]rjpeg[#,] rcode[] [#,] img[]
113
+ [#,] widthR[10] [#,] heightR[10][#,] unitR[cm][#,] resR[72][#,] optR[]
114
+ [#,] include[true] [#,] optTex[scale=0.75]
115
+ [#,] newR[FALSE]
116
+ [#>][{#rfig]#{rcode}[#,]deviceR[jpeg][#}]
117
+ [#}
118
+
119
+ {#def]rpdf[#,] rcode[] [#,] img[]
120
+ [#,] widthR[5] [#,] heightR[5][#,] optR[]
121
+ [#,] include[true] [#,] optTex[scale=1.0]
122
+ [#,] newR[FALSE]
123
+ [#>][{#rfig]#{rcode}[#,]deviceR[pdf][#,]unitR[][#,]resR[][#}]
124
+ [#}
125
+
126
+ {#def]rsvg[#,] rcode[] [#,] img[]
127
+ [#,] widthR[5] [#,] heightR[5][#,] pointsizeR[12][#,] optR[]
128
+ [#,] Renvir[Global]
129
+ [#rb<]
130
+ require 'fileutils'
131
+ imgdir=File.expand_path("~/dyndoc/tmp")
132
+ FileUtils.mkdir_p(imgdir) unless File.exists? imgdir
133
+ rcode=#{=rcode}.strip
134
+ Utils.clean_eol(rcode)
135
+ img=File.join(imgdir,"last.svg")
136
+ Dyndoc.warn "img",img
137
+ [#<]{#r]
138
+ svg(:{=img},width=#{widthR},height=#{heightR}{#if]#{+?pointsizeR}[#>],pointsize="#{pointsizeR}"[#}{#if]#{+?optR}[#>],[#}#{optR})
139
+ :{rcode}
140
+ dev.off()
141
+ [#in]#{Renvir}[#}
142
+ [#rb<]p [:rsvg,img,File.readlines(img).join("\n")]
143
+ [#rb>]File.readlines(img)[1..-1].join("\n") #everything except first line
144
+ [#def}
@@ -0,0 +1,344 @@
1
+ {#def]xtable[#,]rexpr[][#,]_xtable_opt[][#,]_print_opt[]
2
+ [#?]#{+?_xtable_opt}[#>]_xtable_opt[,#{_xtable_opt}][#?]end
3
+ [#?]#{+?_print_opt}[#>]_print_opt[,#{_print_opt}][#?]end
4
+ [#r>]
5
+ [require(xtable)
6
+ print(xtable({#{rexpr}}#{_xtable_opt})#{_print_opt})]
7
+ [#}
8
+
9
+ {#def]rpart[#,]part[][#,]saved[]
10
+ [#rb<]CqlsDoc.make_dir("part")
11
+ [#>]rdata[part/#{part}.RData]
12
+ [#tag]rpart:#{part}[#yield]default
13
+ [#r<]save(#{saved},file="#{rdata}")
14
+ [#tag]else[#r<]
15
+ [#?]File.exist?(#{=rdata}) [#r<]load("#{rdata}")
16
+ [#?]else[#yield]default
17
+ [#r<]save(#{saved},file="#{rdata}")
18
+ [#}
19
+
20
+ {#def]sweave[#,]rcode[]
21
+ [#rb>]rcode[#{=rcode}.strip.gsub("\r\n","\n")]
22
+ [#>]
23
+ [\begin{CodeChunk}<\n>]
24
+ [#rb>]
25
+ [res=CqlsDoc::RServer.echo_blocks(#{=rcode})
26
+ i,res2=0,[[],[]]
27
+ while i<res[:in].length
28
+ input="R"+res[:in][i]
29
+ while res[:out][i].empty?
30
+ i+=1
31
+ input<<(res[:in][i][0,1]=="+" ? " " : "R") << res[:in][i]
32
+ end
33
+ res2[0]<<"\\begin{CodeInput}\n"+input+"\\end{CodeInput}"
34
+ res2[1]<<"\\begin{CodeOutput}\n"+res[:out][i]+"\\end{CodeOutput}"
35
+ i+=1
36
+ end
37
+ (0...(res2[0].length)).map{|i| res2[0][i]+"\n"+res2[1][i]+"\n"}.join
38
+ ]
39
+ [#>]
40
+ [\end{CodeChunk}]
41
+ [#}
42
+
43
+ {#def]supeR[#,]rcode[][#,]_optLst[]
44
+ [#?]!$dyn_supeR[#rb<]$dyn_supeR=0
45
+ [#<]{#document][#package]
46
+ \RequirePackage{listings}
47
+ \RequirePackage{xcolor}
48
+ [#}[#?]end
49
+ [#rb<]res=CqlsDoc::RServer.inputsAndOutputs(#{=rcode}.strip,$dyn_supeR+=1)
50
+ header={"keywordstyle"=>'\bf\color{green}',
51
+ "stringstyle"=>'\color{red}',
52
+ "showstringspaces"=>true,
53
+ "numbers"=>"left",
54
+ "numberstyle"=>'\tiny\bf',
55
+ "stepnumber"=>1,
56
+ "frame"=>"l"
57
+ }
58
+ header2=@vars.extract("_optLst")
59
+ header.merge!(header2) if header2 and header2.is_a? Hash
60
+ header=header.map{|k,v| k+"="+v.to_s}.join(",")
61
+ [#>][\begin{lstlisting}[language=R,name=algoR:{$dyn_supeR},:{header}]
62
+ {#for]line in res
63
+ [#rb>][(case line[:prompt];when :normal;">";when :continue;"+";when :none;"";end)]
64
+ [#>][ :{line[:input]}]
65
+ [#?]!line[:output].empty?[#>][:{line[:output]}]
66
+ [#?]line[:img] and !(line[:img][:opt] and line[:img][:opt]["include"] and line[:img][:opt]["include"]=="ok")[#>]\end{lstlisting}
67
+ [#>][\includegraphics{:{line[:img][:name]}}
68
+ \begin{lstlisting}[language=R,firstnumber=auto,name=algoR:{$dyn_supeR},:{header}]<\n>]
69
+ [#}\end{lstlisting}]
70
+ [#}
71
+
72
+
73
+ {#def]peteR[#,]rcode[][#,]_optLst[]
74
+ [#?]!$dyn_supeR[#rb<]$dyn_supeR=0
75
+ [#<]{#document][#package]
76
+ \RequirePackage{fancyvrb}
77
+ \RequirePackage{xcolor}
78
+ \definecolor{beaubleu}{rgb}{0.26,0.31,0.61}
79
+ [#}[#?]end
80
+ [#rb<]
81
+ res=CqlsDoc::RServer.inputsAndOutputs(#{=rcode}.strip.gsub("\r\n","\n"),$dyn_supeR+=1)
82
+ header={"formatcom"=>'\color{beaubleu}',"fontfamily"=>"courier"
83
+ }
84
+ header2=@vars.extract("_optLst")
85
+ header.merge!(header2) if header2 and header2.is_a? Hash
86
+ header=header.map{|k,v| k+"="+v.to_s}.join(",")
87
+ [#>][\begin{Verbatim}[:{header}]
88
+ {#for]line in res
89
+ [#rb<][(line[:prompt]==:normal ? ">" : "+")]
90
+ [#rb>][(case line[:prompt];when :normal;">";when :continue;"+";when :none;"";end)]
91
+ [#>][ :{line[:input]}]
92
+ [#?]!line[:output].empty?[#>][:{line[:output]}]
93
+ [#?]line[:img] and !(line[:img][:opt] and line[:img][:opt]["include"] and line[:img][:opt]["include"]=="ok")[#>]\end{Verbatim}
94
+ [#>][\includegraphics{:{line[:img][:name]}}
95
+ \begin{Verbatim}[:{header}]<\n>]
96
+ [#}\end{Verbatim}]
97
+ [#}
98
+
99
+ {#def]peteR[#,]rcode[][#>]{#Rems]#{rcode}[#}[#def}
100
+
101
+ {#def]RVerb[#,]rcode[][#>]{#Rems]#{rcode}[#}[#def}
102
+
103
+ {#def]Rems_in[#?]!line[:input].empty?[#>] \textcolor{beaubleu}{:{line[:input].chomp.gsub(/\'\\t\'/,"'{\\textbackslash}t'").gsub(/\"\\t\"/,"\"{\\textbackslash}t\"")}}<\n>[#}
104
+
105
+ {#def]Rems_out[#rb>]line[:output].split("\n").map{|l| '\textit{\textcolor{beauvert}{'+l+"}}"}.join("\n")+"\n"[#}
106
+
107
+
108
+ {#def]Rems_content[#rb<][(line[:prompt]==:normal ? ">" : "+")]
109
+ [#rb>][(case line[:prompt];when :normal;">";when :continue;"+";when :none;"";end)][#rb<]#p line[:img] if line[:img]
110
+ [#>][{#Rems_in#}]
111
+ [#?]!line[:output].empty?[#>][{#Rems_out#}]
112
+ [#}
113
+
114
+ {#def]Rems[#,]rcode[][#,]_optLst[][#,]RDevice[<<type[pdf]<<opt[width=5,height=5,onefile=FALSE]]
115
+ [#,]graph[<<before[]<<after[]]
116
+ [#?]!$dyn_supeR[#rb<]$dyn_supeR=0
117
+ [#<]{#document][#package]
118
+ %\RequirePackage{fancyvrb}
119
+ \usepackage{xcolor}
120
+ [#preamble]
121
+ \definecolor{beaubleu}{rgb}{0.26,0.31,0.61}
122
+ \definecolor{beauvert}{rgb}{0.27,0.52,0.42}
123
+ [#}[#?]end
124
+ [#rb<]
125
+ RServer.device(#{=RDevice.type})
126
+ ##Dyndoc.warn #{=rcode}.encoding
127
+ res=CqlsDoc::RServer.inputsAndOutputs(#{=rcode}.strip.gsub("\r\n","\n"),$dyn_supeR+=1,#{=RDevice.opt})
128
+ #Dyndoc.warn "res_in_Rems",res
129
+ header={"fontfamily"=>"courier","fontseries"=>"b","fontsize"=>"\\small"}
130
+ header2=@vars.extract("_optLst")
131
+ header.merge!(header2) if header2 and header2.is_a? Hash
132
+ header=header.map{|k,v| k+"="+v.to_s}.join(",")
133
+ [#>]\begin{Verbatim}[commandchars=\\\{\},:{header}]<\n>[#rb<]openVerb=true
134
+ [#>]{#for]i in 0...(res.length)[#rb<]line=res[i]
135
+ [#>][{#Rems_content#}]
136
+ [#?]line[:img] and !(line[:img][:opt] and line[:img][:opt]["include"] and line[:img][:opt]["include"].downcase=="no")[#>]\end{Verbatim}<\n>[#rb<]openVerb=false
137
+ [#>][#{graph.before}\begin{center}\includegraphics{#if]line[:img][:opt] and line[:img][:opt]["opt"][#>][[:{line[:img][:opt]["opt"]}]][#if}{:{line[:img][:name]}}\end{center}#{graph.after}<\n>]
138
+ [#?] & (i < (res.length-1))[#>][\begin{Verbatim}[commandchars=\\\{\},:{header}]<\n>][#rb<]openVerb=true
139
+ [#}[#?]openVerb[#>]\end{Verbatim}
140
+ [#}
141
+
142
+ {#def]verbR_init[#,]optIn[][#,]optOut[]
143
+ [#,]verbIn[Verbatim][#,]verbOut[Verbatim]
144
+ [#?]!$dyn_verbR[#rb<]$dyn_verbR=0[#?]end
145
+ [#=]::verbR.verbIn[#{verbIn}][#=]::verbR.verbOut[#{verbOut}]
146
+ [#<]{#case]#{verbIn}
147
+ [#when]listings,lst[#>]packageIn[\RequirePackage{listings}
148
+ \usepackage{xcolor}]
149
+ [#rb<]
150
+ headerIn={"language"=>"R",
151
+ "keywordstyle"=>'\bf\color{green}',
152
+ "stringstyle"=>'\color{red}',
153
+ "showstringspaces"=>true,
154
+ "numbers"=>"left",
155
+ "numberstyle"=>'\tiny\bf',
156
+ "stepnumber"=>1,
157
+ "frame"=>"l"
158
+ }
159
+ [#when]Verbatim[#>]packageIn[\RequirePackage{fancyvrb}\RequirePackage{xcolor}]
160
+ [#rb<]
161
+ headerIn={"formatcom"=>'\color{green}',"fontfamily"=>"courier","fontseries"=>"b"
162
+ }
163
+ [#case}
164
+ {#case]#{verbOut}
165
+ [#when]listings,lst[#>]packageOut[\RequirePackage{listings}
166
+ \RequirePackage{xcolor}]
167
+ [#rb<]
168
+ headerOut={"language"=>"R",
169
+ "keywordstyle"=>'\bf\color{green}',
170
+ "stringstyle"=>'\color{red}',
171
+ "showstringspaces"=>true,
172
+ "numbers"=>"right",
173
+ "numberstyle"=>'\tiny\bf',
174
+ "stepnumber"=>1,
175
+ "frame"=>"l"
176
+ }
177
+ [#when]Verbatim[#>]packageOut[\RequirePackage{fancyvrb}\RequirePackage{xcolor}]
178
+ [#rb<]
179
+ headerOut={"formatcom"=>'\color{red}',"fontfamily"=>"courier","fontseries"=>"b"
180
+ }
181
+ [#case}
182
+ [#<]{#document][#package]
183
+ #{packageIn}
184
+ #{packageOut}
185
+ [#}
186
+ [#rb<]
187
+ header2=@vars.extract("optIn")
188
+ headerIn.merge!(header2) if header2 and header2.is_a? Hash
189
+ headerIn=headerIn.map{|k,v| k+"="+v.to_s}.join(",")
190
+ header2=@vars.extract("optOut")
191
+ headerOut.merge!(header2) if header2 and header2.is_a? Hash
192
+ headerOut=headerOut.map{|k,v| k+"="+v.to_s}.join(",")
193
+ [#def}
194
+
195
+
196
+ {#def]verbR_init[#,]optIn[][#,]optOut[]
197
+ [#,]verbIn[Verbatim][#,]verbOut[Verbatim]
198
+ [#?]!$dyn_verbR[#rb<]$dyn_verbR=0[#?]end
199
+ [#=]::verbR.verbIn[#{verbIn}][#=]::verbR.verbOut[#{verbOut}]
200
+ [#<]{#case]#{verbIn}
201
+ [#when]listings,lst[#>]packageIn[\RequirePackage{listings}
202
+ \usepackage{xcolor}]
203
+ [#rb<]
204
+ headerIn={"language"=>"R",
205
+ "keywordstyle"=>'\bf\color{green}',
206
+ "stringstyle"=>'\color{red}',
207
+ "showstringspaces"=>true,
208
+ "numbers"=>"left",
209
+ "numberstyle"=>'\tiny\bf',
210
+ "stepnumber"=>1,
211
+ "frame"=>"l"
212
+ }
213
+ [#when]Verbatim[#>]packageIn[\RequirePackage{fancyvrb}\RequirePackage{xcolor}]
214
+ [#rb<]
215
+ headerIn={"formatcom"=>'\color{green}',"fontfamily"=>"courier","fontseries"=>"b"
216
+ }
217
+ [#case}
218
+ {#case]#{verbOut}
219
+ [#when]listings,lst[#>]packageOut[\RequirePackage{listings}
220
+ \RequirePackage{xcolor}]
221
+ [#rb<]
222
+ headerOut={"language"=>"R",
223
+ "keywordstyle"=>'\bf\color{green}',
224
+ "stringstyle"=>'\color{red}',
225
+ "showstringspaces"=>true,
226
+ "numbers"=>"right",
227
+ "numberstyle"=>'\tiny\bf',
228
+ "stepnumber"=>1,
229
+ "frame"=>"l"
230
+ }
231
+ [#when]Verbatim[#>]packageOut[\RequirePackage{fancyvrb}\RequirePackage{xcolor}]
232
+ [#rb<]
233
+ headerOut={"formatcom"=>'\color{red}',"fontfamily"=>"courier","fontseries"=>"b"
234
+ }
235
+ [#case}
236
+ [#<]{#document][#package]
237
+ #{packageIn}
238
+ #{packageOut}
239
+ [#}
240
+ [#rb<]
241
+ header2=@vars.extract("optIn")
242
+ headerIn.merge!(header2) if header2 and header2.is_a? Hash
243
+ headerIn=headerIn.map{|k,v| k+"="+v.to_s}.join(",")
244
+ header2=@vars.extract("optOut")
245
+ headerOut.merge!(header2) if header2 and header2.is_a? Hash
246
+ headerOut=headerOut.map{|k,v| k+"="+v.to_s}.join(",")
247
+ [#def}
248
+
249
+ {#def]verbR_header[#<]
250
+ {#case]#{verbR.verbIn}
251
+ [#when]listings,lst[#=]::verbR.beginIn[\begin{lstlisting}[name=algoR:{$dyn_verbR},:{headerIn}]]
252
+ [#=]::verbR.endIn[\end{lstlisting}]
253
+ [#when]fancy,Verbatim[#=]::verbR.beginIn[\begin{Verbatim}[:{headerIn}]]
254
+ [#=]::verbR.endIn[\end{Verbatim}]
255
+ [#case}
256
+ {#case]#{verbR.verbOut}
257
+ [#when]listings,lst[#=]::verbR.beginOut[\begin{lstlisting}[name=algoR:{$dyn_verbR},:{headerOut}]]
258
+ [#=]::verbR.endOut[\end{lstlisting}]
259
+ [#when]fancy,Verbatim[#=]::verbR.beginOut[\vspace*{-.5cm}\begin{Verbatim}[:{headerOut}]]
260
+ [#=]::verbR.endOut[\end{Verbatim}]
261
+ [#case}
262
+ [#def}
263
+
264
+ {#def]verbR[#,]rcode[]
265
+ [#<]{#verbR_header#}
266
+ [#rb<]res=CqlsDoc::RServer.inputsAndOutputs(#{=rcode}.strip,$dyn_verbR+=1)
267
+ contIn=nil
268
+ [#>]{#for]line in res[#?]!contIn[#>]#{verbR.beginIn}<\n>[#?]end
269
+ [#rb<][(line[:prompt]==:normal ? ">" : "+")]
270
+ [#rb>][(case line[:prompt];when :normal;">";when :continue;"+";when :none;"";end)]
271
+ [#>][ :{line[:input]}]
272
+ [#?]!(contIn=(line[:output].empty?))[#>]#{verbR.endIn}
273
+ #{verbR.beginOut}
274
+ :{line[:output]}
275
+ #{verbR.endOut}
276
+ [#?]line[:img] and !(line[:img][:opt] and line[:img][:opt]["include"] and line[:img][:opt]["include"]=="ok")[#>]#{verbR.endIn}
277
+ [#>][\includegraphics{:{line[:img][:name]}}<\n>#{verbR.beginIn}]
278
+ [#for}
279
+ [#def}
280
+
281
+ {#def]initScriptLstLang[#,]langs[R,C++,Fortran][#<]{#document][#package]
282
+ \usepackage[formats]{listings}
283
+ \usepackage{textcomp}
284
+ \usepackage{xcolor}
285
+ [#preamble]\lstloadlanguages{#{langs}}
286
+ [#}[#def}
287
+
288
+
289
+ {#hide] CECI est rendu possible grace au escapeinside!
290
+ plot(x,y) {#lstEsc]\label{comment}[#} #toto
291
+ #comment
292
+ [#hide}
293
+ {#def]scriptR[#,]rcode[][#,]exec[true][#>]
294
+ \lstset{framexleftmargin=5mm, frame=shadowbox, rulesepcolor=\color{gray}, escapeinside={\#(*}{*)}, numberstyle=\small, stepnumber=1, numbersep=5pt, keepspaces=true,language=R,name=R, showstringspaces=false,upquote=true,basicstyle=\ttfamily}
295
+ \begin{lstlisting}[numbers=left]
296
+ #{rcode}
297
+ \end{lstlisting}
298
+ [#?]#{exec}[#r<]#{rcode}
299
+ [#def}
300
+
301
+ {#def]scriptCpp[#,]code[][][#>]
302
+ \lstset{framexleftmargin=5mm, frame=shadowbox, rulesepcolor=\color{gray}, escapeinside={\#(*}{*)}, numberstyle=\small, stepnumber=1, numbersep=5pt, keepspaces=true,language=C++,name=Cpp,showstringspaces=false}
303
+ \begin{lstlisting}[numbers=left]
304
+ #{code}
305
+ \end{lstlisting}
306
+ [#def}
307
+
308
+ {#def]scriptFortran[#,]code[][][#>]
309
+ \lstset{framexleftmargin=5mm, frame=shadowbox, rulesepcolor=\color{gray}, escapeinside={\#(*}{*)}, numberstyle=\small, stepnumber=1, numbersep=5pt, keepspaces=true,language=Fortran,name=Fortran, showstringspaces=false}
310
+ \begin{lstlisting}[numbers=left]
311
+ #{code}
312
+ \end{lstlisting}
313
+ [#def}
314
+
315
+ {#def]lstEsc[#,]latex[][#>]#(*#{latex}*)[#}
316
+
317
+ {#def]RWeb_in[#>] \textcolor{beaubleu}{:{line[:input].chomp.gsub(/\'\\t\'/,"'{\\textbackslash}t'").gsub(/\"\\t\"/,"\"{\\textbackslash}t\"")}}<\n>[#}
318
+
319
+ {#def]RWeb_out[#rb>]line[:output].split("\n").map{|l| '\textit{\textcolor{beauvert}{'+l+"}}"}.join("\n")+"\n"[#}
320
+
321
+
322
+ {#def]RWeb_content[#rb<][(line[:prompt]==:normal ? ">" : "+")]
323
+ [#rb>][(case line[:prompt];when :normal;">";when :continue;"+";when :none;"";end)][#rb<]#p line[:img] if line[:img]
324
+ [#>][{#RWeb_in#}]
325
+ [#?]!line[:output].empty?[#>][{#RWeb_out#}]
326
+ [#}
327
+
328
+ {#def]RWeb[#,]rcode[][#,]_optLst[][#,]RDevice[<<type[pdf]<<opt[width=5,height=5,onefile=FALSE]]
329
+ [#,]graph[<<before[]<<after[]]
330
+ [#?]!$dyn_supeR[#rb<]$dyn_supeR=0
331
+ [#?]end
332
+ [#rb<]
333
+ RServer.device(#{=RDevice.type})
334
+ #p #{=rcode}
335
+ res=CqlsDoc::RServer.inputsAndOutputs(#{=rcode}.strip.gsub("\r\n","\n"),$dyn_supeR+=1,#{=RDevice.opt})
336
+ #puts "res";p res
337
+ [#>]\begin{Verbatim}[commandchars=\\\{\},:{header}]<\n>[#rb<]openVerb=true
338
+ [#>]{#for]i in 0...(res.length)[#rb<]line=res[i]
339
+ [#>][{#RWeb_content#}]
340
+ [#?]line[:img] and !(line[:img][:opt] and line[:img][:opt]["include"] and line[:img][:opt]["include"].downcase=="no")[#>]\end{Verbatim}<\n>[#rb<]openVerb=false
341
+ [#>][#{graph.before}\begin{center}\includegraphics{#if]line[:img][:opt] and line[:img][:opt]["opt"][#>][[:{line[:img][:opt]["opt"]}]][#if}{:{line[:img][:name]}}\end{center}#{graph.after}<\n>]
342
+ [#?] & (i < (res.length-1))[#>][\begin{Verbatim}[commandchars=\\\{\},:{header}]<\n>][#rb<]openVerb=true
343
+ [#}[#?]openVerb[#>]\end{Verbatim}
344
+ [#}