xseed 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 (41) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/rake.yml +16 -0
  3. data/.github/workflows/release.yml +25 -0
  4. data/.gitignore +72 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +11 -0
  7. data/.rubocop_todo.yml +432 -0
  8. data/CHANGELOG.adoc +446 -0
  9. data/Gemfile +21 -0
  10. data/LICENSE.adoc +29 -0
  11. data/README.adoc +386 -0
  12. data/Rakefile +11 -0
  13. data/examples/README.adoc +334 -0
  14. data/examples/advanced_usage.rb +286 -0
  15. data/examples/html_generation.rb +167 -0
  16. data/examples/parser_usage.rb +102 -0
  17. data/examples/schemas/person.xsd +171 -0
  18. data/examples/simple_generation.rb +149 -0
  19. data/exe/xseed +6 -0
  20. data/lib/xseed/cli.rb +376 -0
  21. data/lib/xseed/documentation/config.rb +101 -0
  22. data/lib/xseed/documentation/constants.rb +76 -0
  23. data/lib/xseed/documentation/generators/hierarchy_table_generator.rb +554 -0
  24. data/lib/xseed/documentation/generators/instance_sample_generator.rb +723 -0
  25. data/lib/xseed/documentation/generators/properties_table_generator.rb +983 -0
  26. data/lib/xseed/documentation/html_generator.rb +836 -0
  27. data/lib/xseed/documentation/html_generator.rb.bak +723 -0
  28. data/lib/xseed/documentation/presentation/css_generator.rb +510 -0
  29. data/lib/xseed/documentation/presentation/javascript_generator.rb +151 -0
  30. data/lib/xseed/documentation/presentation/navigation_builder.rb +169 -0
  31. data/lib/xseed/documentation/schema_loader.rb +121 -0
  32. data/lib/xseed/documentation/utils/helpers.rb +205 -0
  33. data/lib/xseed/documentation/utils/namespaces.rb +149 -0
  34. data/lib/xseed/documentation/utils/references.rb +135 -0
  35. data/lib/xseed/documentation/utils/strings.rb +75 -0
  36. data/lib/xseed/models/element_declaration.rb +144 -0
  37. data/lib/xseed/parser/xsd_parser.rb +192 -0
  38. data/lib/xseed/version.rb +5 -0
  39. data/lib/xseed.rb +76 -0
  40. data/xseed.gemspec +39 -0
  41. metadata +158 -0
@@ -0,0 +1,510 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xseed
4
+ module Documentation
5
+ module Presentation
6
+ # Generates CSS stylesheets for HTML documentation
7
+ # Ports styles from XS3P css-styles.xsl
8
+ class CssGenerator
9
+ NAV_WIDTH = "298px"
10
+
11
+ def initialize(config)
12
+ @config = config
13
+ end
14
+
15
+ def generate
16
+ <<~CSS
17
+ /* XSD Documentation Styles */
18
+ /* Ported from XS3P css-styles.xsl */
19
+
20
+ nav, section {
21
+ display: block;
22
+ }
23
+
24
+ table {
25
+ border-collapse: collapse;
26
+ border-spacing: 0;
27
+ }
28
+
29
+ body {
30
+ margin-left: auto;
31
+ margin-right: auto;
32
+ max-width: 100%;
33
+ font-size: 16px;
34
+ font-weight: 300;
35
+ line-height: 1.4em;
36
+ color: -internal-root-color;
37
+ background-color: #ffffff;
38
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
39
+ }
40
+
41
+ body main {
42
+ margin: 0 3em 0 6em;
43
+ }
44
+
45
+ body main {
46
+ margin: 0;
47
+ }
48
+
49
+ /* HTML5 display-role reset for older browsers */
50
+ article, aside, details, figcaption, figure,
51
+ footer, header, hgroup, menu, nav, section {
52
+ display: block;
53
+ }
54
+
55
+ body {
56
+ line-height: 1.3;
57
+ }
58
+
59
+ body {
60
+ margin-left: #{NAV_WIDTH};
61
+ margin-right: 2em;
62
+ }
63
+
64
+ main {
65
+ padding-left: 4em;
66
+ padding-right: 2em;
67
+ }
68
+
69
+ .title-section {
70
+ padding-left: 4em;
71
+ padding-top: 2em;
72
+ }
73
+
74
+ h2 p {
75
+ display: inline;
76
+ }
77
+
78
+ /* Navigation */
79
+ #toc {
80
+ font-weight: 400;
81
+ }
82
+
83
+ #toc a {
84
+ color: black;
85
+ text-decoration-color: black;
86
+ }
87
+
88
+ #toc ul {
89
+ margin: 0;
90
+ padding: 0;
91
+ list-style: none;
92
+ }
93
+
94
+ #toc ul li a {
95
+ padding: 5px 10px;
96
+ }
97
+
98
+ #toc ul a {
99
+ text-decoration: none;
100
+ display: block;
101
+ }
102
+
103
+ #toc ul a:hover {
104
+ box-shadow: none;
105
+ color: black;
106
+ }
107
+
108
+ #toc .h2 {
109
+ padding-left: 30px;
110
+ }
111
+
112
+ #toc .h3 {
113
+ padding-left: 50px;
114
+ }
115
+
116
+ #toc .toc-active, #toc li:hover {
117
+ background: #f7f7f7;
118
+ box-shadow: inset -5px 0px 10px -5px #f7f7f7 !important;
119
+ }
120
+
121
+ #toc .toc-active a, #toc li:hover a {
122
+ color: black;
123
+ }
124
+
125
+ @media print {
126
+ #toc .toc-active, #toc li:hover {
127
+ background: white;
128
+ box-shadow: none !important;
129
+ }
130
+
131
+ #toc li:hover a {
132
+ color: black;
133
+ }
134
+ }
135
+
136
+ @media screen and (max-width: 768px) {
137
+ #toc {
138
+ padding: 0 1.5em;
139
+ overflow: visible;
140
+ }
141
+ }
142
+
143
+ #toc .toc-active,
144
+ #toc li:hover {
145
+ box-shadow: 0px 1px 0px 0px black !important;
146
+ background: none;
147
+ }
148
+
149
+ #toc li:before {
150
+ content: " ";
151
+ display: none;
152
+ }
153
+
154
+ nav {
155
+ line-height: 1.2em;
156
+ }
157
+
158
+ @media screen and (min-width: 768px) {
159
+ nav {
160
+ position: fixed;
161
+ top: 0;
162
+ bottom: 0;
163
+ left: 0;
164
+ width: #{NAV_WIDTH};
165
+ font-size: 0.9em;
166
+ overflow: auto;
167
+ padding: 0 0 0 0px;
168
+ background-color: #fefefe;
169
+ }
170
+ }
171
+
172
+ @media print {
173
+ nav {
174
+ position: relative;
175
+ width: auto;
176
+ font-size: 0.9em;
177
+ overflow: auto;
178
+ padding: 0;
179
+ margin-right: 0;
180
+ background-color: white;
181
+ }
182
+ }
183
+
184
+ #toggle {
185
+ margin-top: 0;
186
+ }
187
+
188
+ @media screen and (min-width: 768px) {
189
+ #toggle {
190
+ position: fixed;
191
+ height: 100%;
192
+ width: 20px;
193
+ font-weight: bold;
194
+ background-color: #d8e4ff;
195
+ color: black !important;
196
+ cursor: pointer;
197
+ z-index: 100;
198
+ }
199
+
200
+ #toggle span {
201
+ text-align: center;
202
+ width: 100%;
203
+ position: absolute;
204
+ top: 50%;
205
+ transform: translate(0, -50%);
206
+ }
207
+ }
208
+
209
+ @media screen and (max-width: 768px) {
210
+ #toggle {
211
+ display: none;
212
+ }
213
+ }
214
+
215
+ @media print {
216
+ #toggle {
217
+ display: none;
218
+ }
219
+ }
220
+
221
+ @media screen and (min-width: 768px) {
222
+ .container {
223
+ padding-left: 360px;
224
+ }
225
+
226
+ .rule.toc {
227
+ display: none;
228
+ }
229
+
230
+ h1.toc-contents {
231
+ margin-top: 1em;
232
+ }
233
+
234
+ ul#toc-list {
235
+ padding: 0;
236
+ margin: 0;
237
+ }
238
+ }
239
+
240
+ ul, ol {
241
+ margin-left: 2em;
242
+ }
243
+
244
+ #toc-list ul {
245
+ margin-bottom: 0.25em;
246
+ }
247
+
248
+ #toc-list ol li {
249
+ list-style-type: none;
250
+ }
251
+
252
+ /* XS3P specific CSS */
253
+ body {
254
+ background-color: #FFF;
255
+ }
256
+
257
+ .nav > li.active {
258
+ background-color: #FFF;
259
+ }
260
+
261
+ .nav > li > a:hover {
262
+ background-color: rgb(0,0,0, 0.05);
263
+ }
264
+
265
+ .nav-sub-item > a {
266
+ padding-left: 30px !important;
267
+ }
268
+
269
+ .nav-sub-item strong {
270
+ font-weight: normal;
271
+ }
272
+
273
+ .nav {
274
+ background-color: #e4ecff;
275
+ }
276
+
277
+ .xs3p-sidenav {
278
+ background-color: #e4ecff;
279
+ }
280
+
281
+ code {
282
+ color: #333;
283
+ }
284
+
285
+ a.name {
286
+ padding-top: 65px;
287
+ }
288
+
289
+ a:not([href]) {
290
+ color:#1c476c;
291
+ }
292
+
293
+ a:not([href]):hover {
294
+ text-decoration: none;
295
+ }
296
+
297
+ h3.xs3p-subsection-heading {
298
+ margin-bottom: 30px;
299
+ }
300
+
301
+ section, #top {
302
+ margin-top: -65px;
303
+ padding-top: 65px;
304
+ }
305
+
306
+ pre {
307
+ padding: 5px;
308
+ }
309
+
310
+ .xs3p-in-panel-table {
311
+ margin-bottom: 0px;
312
+ }
313
+
314
+ .xs3p-collapse-button {
315
+ font-size: 8pt;
316
+ }
317
+
318
+ .panel-heading .xs3p-panel-title:after {
319
+ font-family: 'Glyphicons Halflings';
320
+ content: "\\e114";
321
+ float: left;
322
+ color: grey;
323
+ margin-right: 10px;
324
+ }
325
+
326
+ .panel-heading .xs3p-panel-title.collapsed:after {
327
+ content: "\\e080";
328
+ }
329
+
330
+ .panel-info > .panel-heading .xs3p-panel-title:after {
331
+ color: white;
332
+ }
333
+
334
+ .xs3p-panel-help {
335
+ color: #888888;
336
+ cursor: pointer;
337
+ }
338
+
339
+ .panel-group {
340
+ margin-bottom: 20px;
341
+ }
342
+
343
+ .btn-doc {
344
+ padding: 0px;
345
+ border: 0px none;
346
+ background: none repeat scroll 0% 0% transparent;
347
+ line-height: 1;
348
+ font-size: 12px;
349
+ }
350
+
351
+ .unpre {
352
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
353
+ font-size: 14px;
354
+ white-space: normal;
355
+ word-break: normal;
356
+ word-wrap: normal;
357
+ }
358
+
359
+ .popover {
360
+ max-width: 400px;
361
+ }
362
+
363
+ /* Syntax highlighting */
364
+ .codehilite .err {
365
+ color: #FFF;
366
+ background-color: #D2322D;
367
+ font-weight: bold;
368
+ }
369
+
370
+ .codehilite .c {
371
+ color: #999;
372
+ }
373
+
374
+ .codehilite .cs {
375
+ color: #999;
376
+ font-style: italic;
377
+ }
378
+
379
+ .codehilite .nt {
380
+ color: #2F6F9F;
381
+ }
382
+
383
+ .codehilite .nn {
384
+ color: #39B3D7;
385
+ }
386
+
387
+ .codehilite .na {
388
+ color: #47A447;
389
+ }
390
+
391
+ .codehilite .s {
392
+ color: #D2322D;
393
+ }
394
+
395
+ .codehilite a {
396
+ color: inherit !important;
397
+ text-decoration: underline !important;
398
+ }
399
+
400
+ .codehilite a:hover {
401
+ opacity: 0.7 !important;
402
+ }
403
+
404
+ dl {
405
+ margin-bottom: 10px;
406
+ }
407
+
408
+ dt {
409
+ font-weight: normal;
410
+ margin-bottom: 10px;
411
+ }
412
+
413
+ dt.header {
414
+ font-weight: 700;
415
+ }
416
+
417
+ .dl-horizontal dt {
418
+ white-space: normal;
419
+ }
420
+
421
+ dd.header {
422
+ font-weight: 700;
423
+ }
424
+
425
+ dd ul {
426
+ margin-left: 0em;
427
+ }
428
+
429
+ .bs-callout {
430
+ padding: 20px;
431
+ padding-top: 10px;
432
+ padding-bottom: 5px;
433
+ margin: 20px 0;
434
+ border: 1px solid #eee;
435
+ border-left-width: 5px;
436
+ border-radius: 3px;
437
+ }
438
+
439
+ .bs-callout-danger {
440
+ border-left-color: #d9534f;
441
+ }
442
+
443
+ .bs-callout-warning {
444
+ border-left-color: #f0ad4e;
445
+ }
446
+
447
+ .bs-callout-info {
448
+ border-left-color: #5bc0de;
449
+ }
450
+
451
+ .bs-callout h4 {
452
+ margin-top: 0;
453
+ margin-bottom: 5px;
454
+ }
455
+
456
+ .bs-callout-danger h4 {
457
+ color: #d9534f;
458
+ }
459
+
460
+ .bs-callout-warning h4 {
461
+ color: #f0ad4e;
462
+ }
463
+
464
+ .bs-callout-info h4 {
465
+ color: black;
466
+ font-size: 11pt;
467
+ }
468
+
469
+ /* Table styles */
470
+ .properties {
471
+ border-collapse: collapse;
472
+ width: 100%;
473
+ }
474
+
475
+ .properties th {
476
+ background: #f0f0f0;
477
+ text-align: left;
478
+ padding: 8px;
479
+ }
480
+
481
+ .properties td {
482
+ border: 1px solid #ddd;
483
+ padding: 8px;
484
+ }
485
+
486
+ /* Content display */
487
+ .hierarchy {
488
+ margin: 10px 0;
489
+ }
490
+
491
+ .instance-sample {
492
+ background: #f5f5f5;
493
+ padding: 10px;
494
+ overflow-x: auto;
495
+ }
496
+
497
+ .xml-code {
498
+ font-family: monospace;
499
+ white-space: pre;
500
+ }
501
+ CSS
502
+ end
503
+
504
+ def external_css_url
505
+ @config.external_css_url
506
+ end
507
+ end
508
+ end
509
+ end
510
+ end
@@ -0,0 +1,151 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xseed
4
+ module Documentation
5
+ module Presentation
6
+ # Generates JavaScript code for HTML documentation
7
+ # Ports functionality from XS3P javascript.xsl
8
+ class JavascriptGenerator
9
+ NAV_WIDTH = "298px"
10
+
11
+ def initialize(config)
12
+ @config = config
13
+ end
14
+
15
+ def generate
16
+ <<~JAVASCRIPT
17
+ // XSD Documentation JavaScript
18
+ // Ported from XS3P javascript.xsl
19
+
20
+ document.addEventListener('DOMContentLoaded', function() {
21
+ // TOC toggle
22
+ initializeTOC();
23
+
24
+ // Tooltips and popovers
25
+ initializeTooltips();
26
+
27
+ // Smooth scrolling
28
+ initializeSmoothScroll();
29
+
30
+ // Bootstrap initialization
31
+ initializeBootstrap();
32
+
33
+ // Markdown processing
34
+ initializeMarkdown();
35
+
36
+ // Sidebar scrolling
37
+ initializeSidebarScrolling();
38
+ });
39
+
40
+ function initializeTOC() {
41
+ var duration = 400;
42
+ $('#toggle').on('click', function(){
43
+ if( $('nav').is(':visible') ) {
44
+ $('nav').animate({ 'left': '-353px' }, duration, function(){
45
+ $('nav').hide();
46
+ });
47
+ $('body').animate({ 'margin-left': '0' }, duration);
48
+ $('#toggle > span').text('>');
49
+ }
50
+ else {
51
+ $('nav').show();
52
+ $('nav').animate({ 'left': '0px' }, duration);
53
+ $('body').animate({ 'margin-left': '#{NAV_WIDTH}' }, duration);
54
+ $('#toggle > span').text('<');
55
+ }
56
+ });
57
+ }
58
+
59
+ function initializeTooltips() {
60
+ $("[data-toggle='tooltip']").tooltip();
61
+ }
62
+
63
+ function initializeSmoothScroll() {
64
+ // Smooth scrolling for anchor links
65
+ $('a[href^="#"]').on('click', function(e) {
66
+ var target = $(this.getAttribute('href'));
67
+ if (target.length) {
68
+ e.preventDefault();
69
+ $('html, body').stop().animate({
70
+ scrollTop: target.offset().top - 65
71
+ }, 500);
72
+ }
73
+ });
74
+ }
75
+
76
+ function initializeBootstrap() {
77
+ // Initialize popovers
78
+ $("[data-toggle='popover']").popover({ trigger: "hover" });
79
+
80
+ // Modal handling
81
+ $("[data-toggle='modal']").click(function() { return false; });
82
+
83
+ $("[data-toggle='modal']").popover({
84
+ trigger: "hover",
85
+ html: true,
86
+ content: function () {
87
+ var targetId = $(this).attr('data-target');
88
+ return $(targetId).html();
89
+ }
90
+ });
91
+ }
92
+
93
+ function initializeMarkdown() {
94
+ if (typeof Markdown !== 'undefined' && Markdown.Converter) {
95
+ var c = new Markdown.Converter();
96
+ $('.xs3p-doc').each(function(i, obj) {
97
+ var rawDocID = '#' + $(this).attr('id') + '-raw';
98
+ var indent = $(rawDocID).html().match("^\\n[\\t ]*");
99
+ var normalized;
100
+ if (!(indent === null)) {
101
+ normalized = $(rawDocID).html().replace(new RegExp(indent[0], "gm"), "\\n");
102
+ } else {
103
+ normalized = $(rawDocID).html();
104
+ }
105
+ $(this).html(c.makeHtml(normalized));
106
+ $(this).find('code,pre').each(function(i, block) {
107
+ $(this).html($(this).text());
108
+ });
109
+ });
110
+ }
111
+ }
112
+
113
+ function initializeSidebarScrolling() {
114
+ $(window).scroll(function() {
115
+ if ($(".xs3p-sidebar").css("position") == "fixed" && $(window).height() < $(".xs3p-sidebar").height()) {
116
+ var perc = $(window).scrollTop() / $("#xs3p-content").height();
117
+ var overflow = $(".xs3p-sidebar").height() + 105 - $(window).height();
118
+ $(".xs3p-sidebar").css("top", (65 - Math.round(overflow * perc)) + "px");
119
+ }
120
+ });
121
+
122
+ $(window).resize(function() {
123
+ if ($(".xs3p-sidebar").css("position") == "fixed") {
124
+ $(".xs3p-sidebar").css("top", "65px");
125
+ }
126
+ });
127
+ }
128
+ JAVASCRIPT
129
+ end
130
+
131
+ def jquery_url
132
+ @config.jquery_url || default_jquery_url
133
+ end
134
+
135
+ def bootstrap_url
136
+ @config.bootstrap_url || default_bootstrap_url
137
+ end
138
+
139
+ private
140
+
141
+ def default_jquery_url
142
+ "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"
143
+ end
144
+
145
+ def default_bootstrap_url
146
+ "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1"
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end