-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapi-eb.rb
1112 lines (1071 loc) · 36.1 KB
/
api-eb.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require 'xmlsimple'
require 'rdiscount'
class Apieb
@@apiName = ""
def self.noproductException(element)
noexception = true
if !element["productException"].nil? && element["productException"] =="eb"
noexception = false
end
return noexception
end
def self.getMDDesc(element)
# will check for presence of DESC_EB to override the default description
desc = ""
if !element["DESC_EB"].nil?
desc = element["DESC_EB"][0]
else
if !element["DESC"].nil?
desc = element["DESC"][0]
end
end
#return "\n" + RDiscount.new(desc.to_s, :smart).to_html
return "#{desc.to_s}"
end
def self.elementHasPlatform(element)
if !element["PLATFORM"].nil? || !element["PLATFORM_EB"].nil?
return true
else
return false
end
end
def self.useModulePlatformOverride(element)
if !element["PLATFORM"].nil? && !element["PLATFORM"][0]["usemodule"].nil?
return true
end
if !element["PLATFORM_EB"].nil? && !element["PLATFORM_EB"][0]["usemodule"].nil?
return true
end
return false
end
def self.getPlatformDesc(element)
# will check for presence of PLATFORM_EB to override the default description
desc = ""
if !element["PLATFORM_EB"].nil?
desc = element["PLATFORM_EB"][0]
else
if !element["PLATFORM"].nil?
desc = element["PLATFORM"][0]
end
end
return "\n#{desc.to_s}"
end
def self.getElementName(element)
if !element["docNameOverride"].nil?
return element["docNameOverride"]
else
return element["name"]
end
end
def self.getAppliesElement(element)
if !element["APPLIES"].nil?
return element["APPLIES"]
end
if !element["APPLIES_EB"].nil?
return element["APPLIES_EB"]
end
return nil
end
def self.appliesMSIOnly(element)
if element[0].is_a?(Hash) && element[0].key?("msiOnly")
if element[0]["msiOnly"] == "true"
return true
end
end
return false
end
def self.appliesRubyOnly(element)
if element[0].is_a?(Hash) && element[0].key?("rubyOnly")
if element[0]["rubyOnly"] == "true"
return true
end
end
return false
end
def self.appliesJSOnly(element)
if element[0].is_a?(Hash) && element[0].key?("jsOnly")
if element[0]["jsOnly"] == "true"
return true
end
end
return false
end
def self.appliesNote(element)
appliescontent = ""
# puts element["APPLIES"]
if element[0].is_a?(Hash) && element[0].key?("content")
appliescontent = element[0]["content"]
end
if element[0].is_a?(String)
appliescontent = element[0]
end
if appliescontent.size >0
return "(" + appliescontent + ")"
end
return ""
end
#returns markdown for the name of the API
def self.getApiName(doc,lang,allowoverride)
md=""
md = doc["MODULE"][0]["name"]
if allowoverride
if !doc["MODULE"][0]["docNameOverride"].nil?
md = doc["MODULE"][0]["docNameOverride"]
else
if lang == 'RUBY'
md = 'Rho::' + doc["MODULE"][0]["name"]
elsif lang =='JS'
md = 'EB.' + doc["MODULE"][0]["name"]
else
md = doc["MODULE"][0]["name"]
end
end
end
@@apiName = md
return md
end
def self.getshortcut(e)
s = e["name"]
if !e["access"].nil?
s += e["access"]
end
return s
end
def self.getApiDesc(doc)
md=""
if !doc["MODULE"][0]["HELP_OVERVIEW_EB"].nil? && !doc["MODULE"][0]["HELP_OVERVIEW_EB"][0].nil? && doc["MODULE"][0]["HELP_OVERVIEW_EB"][0].length >0
md = doc["MODULE"][0]["HELP_OVERVIEW_EB"][0]
else
if !doc["MODULE"][0]["HELP_OVERVIEW"].nil? && !doc["MODULE"][0]["HELP_OVERVIEW"][0].nil? && doc["MODULE"][0]["HELP_OVERVIEW"][0].length >0
md = doc["MODULE"][0]["HELP_OVERVIEW"][0]
end
end
if !doc["MODULE"][0]["MORE_HELP_EB"].nil? && !doc["MODULE"][0]["MORE_HELP_EB"][0].nil? && doc["MODULE"][0]["MORE_HELP_EB"][0].length >0
md +=doc["MODULE"][0]["MORE_HELP_EB"][0]
else
if !doc["MODULE"][0]["MORE_HELP"].nil? && !doc["MODULE"][0]["MORE_HELP"][0].nil? && doc["MODULE"][0]["MORE_HELP"][0].length >0
md +=doc["MODULE"][0]["MORE_HELP"][0]
end
end
return md
end
def self.getpropusagetext(model,property,type,ro,propbag)
defval = ''
if type == 'STRING'
defval = "'some string'"
end
if type == 'BOOLEAN'
defval = "true"
end
if type == 'INTEGER'
defval = "1"
end
if type == 'FLOAT'
defval = "1.0"
end
if ro.nil?
readonly = false
else
if ro=="true"
readonly = true
else
readonly = false
end
end
md += "\n\n"
if !ro
md += "\n\t// Setting directly"
md += "\n\tRho.#{model}.#{property}=#{defval};"
if propbag
md += "\n\t// Setting one property"
md += "\n\tRho.#{model}.setProperty(" + "'#{property}',#{defval});"
md += "\n\t// Setting multiple properties using JSON object"
md += "\n\tRho.#{model}.setProperties({ " + "'#{property}':#{defval} , 'another_property':#{defval}});"
end
end
if propbag
md += "\n\n\t// Getting one property"
md += "\n\tmyvar = Rho.#{model}.getProperty(" + "'#{property}');"
md += "\n\t// Getting multiple properties"
md += "\n\tmyvar = Rho.#{model}.getProperties([" + "'#{property}' , 'another_property']);"
else
md += "\n\n\t// Getting "
md += "\n\tmyvar = Rho.#{model}.#{property};"
end
md += "\n\n"
return md
end
def self.getremarks(doc)
md = ""
if !doc["MODULE"][0]["REMARKS"].nil? && !doc["MODULE"][0]["REMARKS"][0]["REMARK"].nil?
s=doc["MODULE"][0]["REMARKS"][0]["REMARK"]
s.each_with_index() { |element,index|
#EB only show if no exception
if noproductException(element)
md += "\n\n###" + element["title"]
html = getMDDesc(element)
md += "\n"+html
end
}
end
if !doc["MODULE"][0]["REMARKS"].nil? && !doc["MODULE"][0]["REMARKS"][0]["REMARK_EB"].nil?
s=doc["MODULE"][0]["REMARKS"][0]["REMARK_EB"]
s.each_with_index() { |element,index|
#EB only show if no exception
if noproductException(element)
md += "\n\n###" + element["title"]
html = getMDDesc(element)
md += "\n"+html
end
}
end
return md
end
def self.getconstants(doc)
md = ""
if !doc["MODULE"][0]["CONSTANTS"].nil? && !doc["MODULE"][0]["CONSTANTS"][0]["CONSTANT"].nil?
s=doc["MODULE"][0]["CONSTANTS"][0]["CONSTANT"]
s.each_with_index() { |element,index|
#EB only show if no exception
if noproductException(element)
element["name"] = getElementName(element)
md += "\n* " + element["name"]
md += getMDDesc(element)
end
}
end
return md
end
def self.getplatformindicators (platforms,msionly,ruby,javascript,usemoduleplatforms,doc)
if usemoduleplatforms
# puts 'using platform override' + doc["MODULE"][0]["name"]
if elementHasPlatform(doc["MODULE"][0])
platforms = getPlatformDesc(doc["MODULE"][0])
# puts platforms
end
end
indicators = ""
if javascript
# Ignoring for EB
# indicators += "\n* Javascript"
end
if ruby
# Ignoring for EB
# indicators += "\n* Ruby"
end
if !platforms.is_a?(Hash)
if !platforms.downcase.index("android").nil? || !platforms.downcase.index("all").nil?
indicators += "\n* Android"
end
if (!platforms.downcase.index("ios").nil? || !platforms.downcase.index("all").nil?) && !msionly
# Ignoring for EB
# indicators += "\n* iOS"
end
if !platforms.downcase.index("wm").nil? || !platforms.downcase.index("all").nil?
indicators += "\n* Windows Mobile"
end
if !platforms.downcase.index("ce").nil? || !platforms.downcase.index("all").nil?
indicators += "\n* Windows CE"
end
if !platforms.downcase.index("wp8").nil? || !platforms.downcase.index("all").nil?
# Ignoring for EB
# indicators += "\n* Windows Phone 8"
end
if (!platforms.downcase.index("win32").nil? || !platforms.downcase.index("all").nil?) && !msionly
# Ignoring for EB
#indicators += "\n* Windows Desktop"
end
if msionly
indicators += "\n* Symbol Devices Only"
end
end
if indicators !=""
indicators = "\n\n####Platforms\n" + indicators
end
return indicators
end
#returns Markdown for the <Properties section
def self.getparams(element,toplevel)
# @seperator = ""
# puts '***** IN GETPARAMS'
# puts element
methparamsdetails = ""
methsectionparams = ""
# EB show only if no exception
if noproductException(element)
if !element["PARAMS"].nil?
if !toplevel
methsectionparams += "<ul>"
end
element["PARAMS"].each { |params|
params["PARAM"].each { |param|
if noproductException(param)
param["name"] = getElementName(param)
methparamsdetailsdesc = ''
# puts param
if !param["DESC"].nil?
methparamsdetailsdesc=getMDDesc(param)
if methparamsdetailsdesc.to_s == '{}'
methparamsdetailsdesc= ''
end
end
if elementHasPlatform(param) && !toplevel
pdesc= getPlatformDesc(param)
if pdesc.to_s == '{}'
pdesc= ''
else
pdesc = ' Platforms:' + pdesc
end
methparamsdetailsdesc+=pdesc
end
if !param["propertyHash"].nil? && param["propertyHash"] == "true" && param["PARAMS"].nil?
methparamsdetailsdesc += " Valid `properties` for this parameter are the properties available to this API module. Check the <a href='#api-#{@@moduleName}?Properties'>property section</a> for applicable properties."
end
methparamsnil=""
methparamsnildesc=""
if !param["CAN_BE_NIL"].nil?
param["CAN_BE_NIL"].each { |paramsnil|
methparamsnil=" <span class='label label-info'>Optional</span>"
if !paramsnil["DESC"].nil?
methparamsnildesc = getMDDesc(paramsnil)
end
}
end
if !param["default"].nil?
methparamsnil += "<span class='label '> Default: " + param["default"] + "</span>"
end
if param["type"].nil?
param["type"] = "STRING"
end
if param["type"] == "SELF_INSTANCE"
param["type"] = "SELF_INSTANCE: " + @@apiName
end
if toplevel
@methparams += @seperator + '<span class="text-info">' + param["type"] + "</span> " + param["name"]
@seperator = ', '
end
# puts param
if param["name"].nil?
param["name"] = ""
end
methparamsdetails += "<table><tr><td>" + param["name"] + "</td><td>" + param["type"] + "</td><td>\n" + methparamsdetailsdesc + "\n</td><td>" + methparamsnil + "</td></tr></table>"
values = ""
valuetype = param["type"]
if !param["VALUES"].nil?
values = "<dl >"
param["VALUES"].each() { |velement|
velement["VALUE"].each() { |vaelement|
if !vaelement["DESC"].nil?
if !vaelement["DESC"][0].empty?
valdesc = getMDDesc(vaelement)
else
valdesc = ""
end
end
if elementHasPlatform(vaelement)
valdesc += " Platforms: " + getPlatformDesc(vaelement)
end
@seperator = ', '
if !vaelement["type"].nil?
valuetype = vaelement["type"]
end
if !vaelement["constName"].nil?
vaelement["value"] = 'Constant: ' + @@apiName + '.' + vaelement["constName"] + ' <br/> String:' + vaelement["value"] + ''
end
if noproductException(vaelement)
values += "<dt>#{vaelement["value"]}</dt><dd>#{valdesc}</dd>"
end
}
}
values += "</dl>"
end
if values != ""
values = "<p><strong>Possible Values</strong> :</p> " + values
end
methsectionparams += "<li>" + param["name"] + " : <span class='text-info'>" + param["type"] + "</span>#{methparamsnil}<p>" + methparamsdetailsdesc + " " + methparamsnildesc + "</p>#{values}</li>"
methsectionparams += getparams(param,false)
end
}
}
if !toplevel
methsectionparams += "</ul>"
end
end
if !element["PARAM"].nil?
if !toplevel
methsectionparams += "<ul>"
end
element["PARAM"].each { |param|
if noproductException(param)
param["name"] = getElementName(param)
methparamsdetailsdesc = ''
# puts param
if !param["DESC"].nil?
methparamsdetailsdesc=getMDDesc(param)
if methparamsdetailsdesc.to_s == '{}'
methparamsdetailsdesc= ''
end
end
methparamsnil=""
methparamsnildesc=""
if !param["CAN_BE_NIL"].nil?
param["CAN_BE_NIL"].each { |paramsnil|
methparamsnil=" <span class='label label-info'>Optional</span>"
if !paramsnil["DESC"].nil?
methparamsnildesc = getMDDesc(paramsnil)
end
}
end
if !param["default"].nil?
methparamsnil += " <span class='label '> Default: " + param["default"] + "</span>"
end
if param["type"].nil?
param["type"] = "STRING"
end
if param["type"] == "SELF_INSTANCE"
param["type"] = "SELF_INSTANCE: " + @@apiName
end
if param["name"].nil?
param["name"] = "<i>Object</i>"
end
# puts param
if param["name"].nil?
param["name"] = ""
end
methparamsdetails += "<table><tr><td>" + param["name"] + "</td><td>" + param["type"] + "</td><td>" + methparamsdetailsdesc + "</td><td>" + methparamsnil + "</td></tr></table>"
values = ""
valuetype = param["type"]
if !param["VALUES"].nil?
param["VALUES"].each() { |velement|
velement["VALUE"].each() { |vaelement|
valdesc = "<dl >"
if !vaelement["DESC"].nil?
if !vaelement["DESC"][0].empty?
valdesc = getMDDesc(vaelement)
else
valdesc = ""
end
end
if elementHasPlatform(vaelement)
valdesc += " Platforms: " + getPlatformDesc(vaelement)
end
@seperator = ', '
if !vaelement["type"].nil?
valuetype = vaelement["type"]
end
if !vaelement["constName"].nil?
vaelement["value"] = 'Constant: ' + @@apiName + '.' + vaelement["constName"] + ' <br/> String: ' + vaelement["value"] + ' '
end
if noproductException(vaelement)
values += "<dt>#{vaelement["value"]}</dt><dd>#{valdesc}</dd>"
end
}
values += "</dl>"
}
end
if values != ""
values = "<p><strong>Possible Values</strong> :</p> " + values
end
methsectionparams += "<li>" + param["name"] + " : <span class='text-info'>" + param["type"] + "</span>#{methparamsnil}<p>" + methparamsdetailsdesc + " " + methparamsnildesc + "</p>#{values}</li>"
methsectionparams += getparams(param,false)
end
}
if !toplevel
methsectionparams += "</ul>"
end
end
end
return methsectionparams
end
#returns Markdown for the <Properties section
def self.getmethods(doc)
#puts "********************* METHODS *************"
#puts doc["MODULE"][0]["METHODS"][0]
md = ""
@methsectionparams= ""
s=doc["MODULE"][0]["METHODS"][0]["METHOD"].sort {|x,y| x["name"] <=> y["name"]} rescue {}
#puts methodaliases
s.each() { |element|
element["name"] = getElementName(element)
if (element["generateDoc"].nil? || element["generateDoc"] == "true") && noproductException(element)
methname = element["name"]
if !element["DESC"].nil? && !element["DESC"][0].is_a?(Hash)
@methdesc = getMDDesc(element)
else
@methdesc = ""
end
@methparams = ""
@methparamsdetails = ""
@methsectionparams = ""
@theCallbackElement = nil
@seperator = ""
# ****** PARAMS LISTING SECTION
if !element["PARAMS"].nil? || (@methhascallback !="" && @methhascallback != "none")
@methsectionparams = "\n\n"
@methsectionparams += "####Parameters"
@methsectionparams += "\n<ul>"
@methsectionparams += getparams(element,true)
#add generic syntax for callback param
if @methhascallback !="" && @methhascallback != "none"
# puts element["CALLBACK"]
@methcallbackoptional= ""
if @methhascallback == "optional"
@methcallbackoptional = " <span class='label label-info'>Optional</span> "
end
if @methhascallback == "mandatory"
@methcallbackoptional = " <span class='label label-warning'>Mandatory</span> "
end
firstcallbackreturnparam = "calbackreturnparamname"
callbacktype = "CallBackHandler"
callbackreturntype = ""
if !element["CALLBACK"].nil?
@theCallbackElement = element["CALLBACK"]
else
@theCallbackElement = element["RETURN"]
end
# puts @theCallbackElement
if [email protected]? && !@theCallbackElement[0]["type"].nil?
callbackreturntype = @theCallbackElement[0]["type"]
else
callbackreturntype = "OBJECT"
end
if [email protected]? && !@theCallbackElement[0]["PARAMS"].nil?
# puts @theCallbackElement[0]["PARAMS"]
firstcallbackreturnparam = @theCallbackElement[0]["PARAMS"][0]["PARAM"][0]["name"]
end
if !element["PARAMS"].nil?
prevparams = "...,"
else
prevparams = ""
end
@methsectionparams += "<li>callback : <span class='text-info'>#{callbacktype}</span>#{@methcallbackoptional}</li>"
end
@methsectionparams += "</ul>"
end
# **** CALLBACK SECTION
@methsectioncallbackparams = ""
if @methhascallback !="" && @methhascallback != "none"
@methcallbackdetails = ""
if [email protected]? && !@theCallbackElement[0].nil?
@methsectioncallbackparams = "\n\n####Callback"
@methsectioncallbackparams += "\nAsync Callback Returning Parameters: <span class='text-info'>#{callbackreturntype}</span></p><ul>"
@methsectioncallbackparams += getparams(@theCallbackElement[0],false)
@methsectioncallbackparams += "</ul>"
end
end
# ***** RETURN SECTION
@methreturn = "Void"
@methreturndesc=""
methreturnparams = ""
if !element["RETURN"].nil?
element["RETURN"].each() { |relement|
if relement["type"].nil? || relement["type"]==''
@methreturn="Void"
else
@methreturn = relement["type"]
end
# puts relement
if !relement["DESC"].nil? && !relement["DESC"][0].is_a?(Hash)
@methreturndesc=" : " + getMDDesc(relement)
end
methreturnparams = getparams(relement,false)
}
end
@methsectionreturns = "\n\n####Returns"
@methsectionreturns += "\nSynchronous Return:"
@methsectionreturns += "\n\n* #{@methreturn}#{@methreturndesc}#{methreturnparams}"
# *** PLATFORMS SECTION
@methplatforms = "All"
@usemoduleplatforms = false
msionly = false
ruby = true
javascript = true
applieselement = getAppliesElement(element)
if !applieselement.nil?
msionly = appliesMSIOnly(applieselement)
javascript = !appliesRubyOnly(applieselement)
ruby = !appliesJSOnly(applieselement)
methnote= appliesNote(applieselement)
end
if elementHasPlatform(element)
@methplatforms = getPlatformDesc(element)
@usemoduleplatforms = useModulePlatformOverride(element)
else
# puts " #{methname} no platform indicators"
@usemoduleplatforms = true
end
@methplatforms = getplatformindicators(@methplatforms,msionly,ruby,javascript,@usemoduleplatforms,doc)
# *** ACCESS SECTION
templateDefault = false
if !doc["MODULE"][0]["TEMPLATES"].nil? && !doc["MODULE"][0]["TEMPLATES"][0].nil? && !doc["MODULE"][0]["TEMPLATES"][0]["DEFAULT_INSTANCE"].nil?
templateDefault = true
end
if element["access"].nil? && element["scopeOverride"].nil?
#use global PROPERTIES field
masterAccess = doc["MODULE"][0]["METHODS"][0]["access"]
else
if !element["scopeOverride"].nil?
masterAccess = element["scopeOverride"]
else
masterAccess = element["access"]
end
end
constructor = false
constructorLabel = ''
if !element["constructor"].nil?
if element["constructor"] == "true"
constructor = true
constructorLabel = '<span class="label label-inverse"> Constructor</span> '
end
end
destructor = false
destructorLabel = ''
if !element["destructor"].nil?
if element["destructor"] == "true"
destructor = true
destructorLabel = '<span class="label label-inverse"> Destructor</span> '
end
end
if masterAccess.nil? || masterAccess == 'INSTANCE' || masterAccess == ''
accesstype = "\n* Instance Method: This method can be accessed via an instance object of this class: \n\t* <code>myObject." + element["name"] + "(#{@methparams})</code>"
if templateDefault
accesstype += "\n* Default Instance: This method can be accessed via the default instance object of this class. "
if javascript
accesstype += "\n\t* <code>" + getApiName(doc,'JS',true) + '.' + element["name"] + "(#{@methparams})</code> "
end
accesstype += "\n"
end
else
accesstype = "\n* Class Method: This method can only be accessed via the API class object. "
if javascript
accesstype += "\n\t* <code>" + getApiName(doc,'JS',true) + '.' + element["name"] + "(#{@methparams})</code> "
end
accesstype += "\n"
end
if constructor
accesstype = "\n* Class Method: This method is a constructor and can only be accessed via the `new` construct. "
if javascript
accesstype += "\n\t* <code>var myObj = new " + getApiName(doc,'JS',true) + "(#{@methparams})</code>"
end
accesstype += "\n"
end
if destructor
accesstype = "\n* Class Method: This method is a destructor and can only be accessed via the object that was created by the `new` constructor. "
if javascript
accesstype += "\n\t* <code>myObj." + element["name"] + "(#{@methparams})</code>"
end
accesstype += "\n"
end
@methsectionaccess = "\n\n####Method Access:\n#{accesstype}"
#EB : Do not show if not supporting javascript
if javascript
# *** BUILD ORDER OF SECTIONS
if constructor
md += "\n\n### #{constructorLabel} new " + @@apiName + "(#{@methparams})"
else
md += "\n\n### #{destructorLabel}" + methname + "(#{@methparams})"
end
md += "\n" + @methdesc
if @methsectionparams != ''
md += @methsectionparams
end
if @methsectioncallbackparams != ''
md += @methsectioncallbackparams
end
if @methsectionreturns != ''
md += @methsectionreturns
end
if @methplatforms != ''
md += @methplatforms
end
if @methsectionaccess != ''
md += @methsectionaccess
end
end
end
}
return md
end
def self.getproperties(doc)
md = ""
generateAccessors = true
templatePropBag = false
if !doc["MODULE"][0]["TEMPLATES"].nil? && !doc["MODULE"][0]["TEMPLATES"][0].nil? && !doc["MODULE"][0]["TEMPLATES"][0]["PROPERTY_BAG"].nil?
templatePropBag = true
end
if !doc["MODULE"][0]["TEMPLATES"].nil? && doc["MODULE"][0]["TEMPLATES"][0]["PROPERTY_BAG"].nil?
templatePropBag = false
end
if !doc["MODULE"][0]["PROPERTIES"].nil? && !doc["MODULE"][0]["PROPERTIES"][0]["generateAccessors"].nil? && doc["MODULE"][0]["PROPERTIES"][0]["generateAccessors"] == "false"
generateAccessors = false
end
if !doc["MODULE"][0]["PROPERTIES"].nil? && !doc["MODULE"][0]["PROPERTIES"][0]["PROPERTY"].nil?
s=doc["MODULE"][0]["PROPERTIES"][0]["PROPERTY"].sort {|x,y| x["name"] <=> y["name"]}
s.each() { |element|
element["name"] = getElementName(element)
puts element["name"]
if (element["generateDoc"].nil? || element["generateDoc"] == "true") && noproductException(element)
propname = element["name"]
propusage = ""
propver = ""
propnote = ""
# type is optional default is STRING
#puts element
#if !element["VER_INTRODUCED"].nil?
# propver= "<span class='muted pull-right'>" + element["VER_INTRODUCED"][0] + "</span>"
#end
msionly = false
ruby = true
javascript = true
applieselement = getAppliesElement(element)
if !applieselement.nil?
msionly = appliesMSIOnly(applieselement)
javascript = !appliesRubyOnly(applieselement)
ruby = !appliesJSOnly(applieselement)
propnote= appliesNote(applieselement)
end
@propplatforms = "All"
@usemoduleplatforms = false
if elementHasPlatform(element)
@propplatforms = getPlatformDesc(element)
@usemoduleplatforms = useModulePlatformOverride(element)
else
# puts " #{propname} no platform indicators"
@usemoduleplatforms = true
end
@propplatforms = getplatformindicators(@propplatforms,msionly,ruby,javascript,@usemoduleplatforms,doc)
@propsectionplatforms = "#{@propplatforms}"
if element["type"].nil?
proptype= "<span class='text-info'>STRING</span>"
else
proptype= "<span class='text-info'>" + element["type"] + "</span>"
end
# readOnly is optional default is false
if element["readOnly"].nil?
propreadOnly= ""
else
propreadOnly= element["readOnly"]
if propreadOnly=="true"
propreadOnly="<span class='label'>Read Only</span>"
else
propreadOnly=""
end
end
if element["default"].nil?
propdefault= ""
else
# Hack for overriding log api default of file name
if element["default"]=="rholog.txt"
element["default"]=""
end
propdefault= "<p><strong>Default:</strong> " + element["default"] + "</p>"
if propdefault == "<p><strong>Default:</strong> </p>"
propdefault=""
end
end
@propdesc = getMDDesc(element)
#if @propdesc.nil?
# RDiscount.new(@propdesc, :smart).to_html
#end
@propvalues = ""
@propvaluetype = "STRING" #STRING IS DEFAULT IF NO TYPE SPECIFIED FOR propvalue
@seperator = ""
if !element["VALUES"].nil?
@propvalues = ""
element["VALUES"].each() { |velement|
velement["VALUE"].each() { |vaelement|
@propvaldesc = ""
if !vaelement["DESC"].nil?
if !vaelement["DESC"][0].empty?
@propvaldesc = getMDDesc(vaelement)
else
@propvaldesc = ""
end
end
if elementHasPlatform(vaelement)
@propvaldesc += "Platforms: " + getPlatformDesc(vaelement)
end
@seperator = ', '
if !vaelement["type"].nil?
@propvaluetype = !vaelement["type"]
end
if !vaelement["constName"].nil?
vaelement["value"] = "Constant: " + @@apiName + '.' + vaelement["constName"] + " - String: " + vaelement["value"]
end
if noproductException(vaelement)
@propvalues += "\n* #{vaelement["value"]} #{@propvaldesc}"
end
}
@propvalues += ""
}
end
if @propvalues != ""
@propvalues = "\n<strong>Possible Values</strong> (<span class='text-info'>#{@propvaluetype}</span>):\n " + @propvalues
end
propreplaces = ""
#Check to see if need to add to description about this method replacing a deprecated one
if !doc["MODULE"][0]["PROPERTIES"].nil? && !doc["MODULE"][0]["PROPERTIES"][0]["ALIASES"].nil? && !doc["MODULE"][0]["PROPERTIES"][0]["ALIASES"][0].empty?
doc["MODULE"][0]["PROPERTIES"][0]["ALIASES"][0]["ALIAS"].each() { |a|
#puts a
if a["existing"] == element["name"]
propreplaces += a["new"]
end
}
end
propdisplayname = propname
deprecated = ""
if !element["deprecated"].nil?
deprecated = element["deprecated"]
end
if propreplaces != ""
propdisplayname = '<span class="text-info">' + propname + '</span>'
@propdesc = "<span class='label label-info'>Replaces:#{propreplaces}</span> " + @propdesc
end
if deprecated != ""
propdisplayname = '<span class="text-error">' + propname + '</span>'
@propdesc = "<span class='label label-important'>Deprecated</span> " + @propdesc
end
templateDefault = false
if !doc["MODULE"][0]["TEMPLATES"].nil? && !doc["MODULE"][0]["TEMPLATES"][0].nil? && !doc["MODULE"][0]["TEMPLATES"][0]["DEFAULT_INSTANCE"].nil?
templateDefault = true
end
if element["access"].nil? && element["scopeOverride"].nil?
#use global PROPERTIES field
masterAccess = doc["MODULE"][0]["PROPERTIES"][0]["access"]
else
if !element["scopeOverride"].nil?
masterAccess = element["scopeOverride"]
else
masterAccess = element["access"]
end
end
if masterAccess.nil? || masterAccess == 'INSTANCE' || masterAccess == ''
accesstype = "\n* Instance: This property can be accessed via an instance object of this class: <code>myObject." + element["name"] + '</code>'
if templateDefault
accesstype += "\n* Default Instance: This property can be accessed via the default instance object of this class. "
if javascript
accesstype += "\n\t* <code>" + getApiName(doc,'JS',true) + '.' + element["name"] + '</code> '
end
accesstype += "\n"
end
else
accesstype = "\n* Class: This property can only be accessed via the API class object."
if javascript
accesstype +="\n\t* <code>" + getApiName(doc,'JS',true) + '.' + element["name"] + '</code>'
end
accesstype += "\n"
end
@propsectionaccess = "\n#{accesstype}"
propParasDef = getparams(element,true) + propdefault
if !generateAccessors
@propsectionaccess += "\nThis property cannot be accessed via setter or getter methods. It can be used in methods that allow a HASH or Array of properties to be passed in."
end
#EB : Ignore if not javascript supported
if javascript
md += "\n\n###" + propdisplayname
md += "\n\n####Type"
md += "\n#{proptype} #{propreadOnly}"
md += "\n####Description"
md += "\n#{@propdesc}"
if propParasDef != ''
md += "\n####Params"
md += "\n#{propParasDef}"
end
if @propvalues != ''
md += "\n####Values"
md += "\n#{@propvalues}"
end
if @propsectionaccess != ''
md += "\n####Access"
md += "\n#{@propsectionaccess}"
end
if @propsectionplatforms != ''
md += "\n#{@propsectionplatforms}#{propnote}"
end
else
puts "JS not supported"
end
else
puts "product exception"
end
}
end
return md
end
def self.getexamples(doc)
md = ""
# puts doc["MODULE"][0]["EXAMPLES"]
if !doc["MODULE"][0]["EXAMPLES_EB"].nil? && !doc["MODULE"][0]["EXAMPLES_EB"][0]["EXAMPLE"].nil?
s=doc["MODULE"][0]["EXAMPLES_EB"][0]["EXAMPLE"]
s.each_with_index() { |element,index|
examplename = ""
examplesections = ""
examplename = element["title"]
sect=element["SECTIONS"][0]["SECTION"]
sect.each_with_index() { |section,si|
#puts "**********"
#puts section
examplesections += "\n"
# puts section["DESC"][0]
# if section["DESC"][0].class != Hash
# puts section
if !section["DESC"].nil? && !section["DESC"][0].nil?
examplesections += getMDDesc(section)
end
# end
exampleid = "exI#{index.to_s}-S#{si.to_s}"
codelang = 'ruby'
codesnip = section["CODE"]
codejs = ''
coderuby = ''
# puts codesnip
if !codesnip[0]["content"].nil? #uses one code block
# puts codesnip
if !codesnip[0]["lang"].nil?
codelang = codesnip[0]["lang"]
if codelang.empty?
codelang = 'ruby'
end
end
if codelang == 'ruby'
#coderuby = "<pre><code>:::#{codelang}"
#cleanCode = codesnip[0]["content"].gsub('<','<')
#cleanCode = cleanCode.gsub('>','>')
#coderuby += cleanCode
#coderuby += "</code></pre>"
else
codejs = "\n<pre><code>:::javascript"
cleanCode = codesnip[0]["content"].gsub('<','<')
cleanCode = cleanCode.gsub('>','>')
codejs += cleanCode
codejs += "\n</code></pre>"
end
else
if !codesnip[0]["RUBY"].nil?
#coderuby = "<pre><code>:::ruby\n"
#cleanCode = codesnip[0]["RUBY"][0].gsub('<','<')
#cleanCode = cleanCode.gsub('>','>')
#coderuby += cleanCode
#coderuby += "</code></pre>"
end
if !codesnip[0]["JAVASCRIPT"].nil?
codejs = "\n<pre><code>:::javascript"
cleanCode = codesnip[0]["JAVASCRIPT"][0].gsub('<','<')
cleanCode = cleanCode.gsub('>','>')
codejs += cleanCode
codejs += "\n</code></pre>"
end
end
examplesections += codejs
}
md += "\n\n###" + element["title"]
md += examplesections
}
end
return md
end
def self.markdown(topic)