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.
- checksums.yaml +7 -0
- data/.github/workflows/rake.yml +16 -0
- data/.github/workflows/release.yml +25 -0
- data/.gitignore +72 -0
- data/.rspec +3 -0
- data/.rubocop.yml +11 -0
- data/.rubocop_todo.yml +432 -0
- data/CHANGELOG.adoc +446 -0
- data/Gemfile +21 -0
- data/LICENSE.adoc +29 -0
- data/README.adoc +386 -0
- data/Rakefile +11 -0
- data/examples/README.adoc +334 -0
- data/examples/advanced_usage.rb +286 -0
- data/examples/html_generation.rb +167 -0
- data/examples/parser_usage.rb +102 -0
- data/examples/schemas/person.xsd +171 -0
- data/examples/simple_generation.rb +149 -0
- data/exe/xseed +6 -0
- data/lib/xseed/cli.rb +376 -0
- data/lib/xseed/documentation/config.rb +101 -0
- data/lib/xseed/documentation/constants.rb +76 -0
- data/lib/xseed/documentation/generators/hierarchy_table_generator.rb +554 -0
- data/lib/xseed/documentation/generators/instance_sample_generator.rb +723 -0
- data/lib/xseed/documentation/generators/properties_table_generator.rb +983 -0
- data/lib/xseed/documentation/html_generator.rb +836 -0
- data/lib/xseed/documentation/html_generator.rb.bak +723 -0
- data/lib/xseed/documentation/presentation/css_generator.rb +510 -0
- data/lib/xseed/documentation/presentation/javascript_generator.rb +151 -0
- data/lib/xseed/documentation/presentation/navigation_builder.rb +169 -0
- data/lib/xseed/documentation/schema_loader.rb +121 -0
- data/lib/xseed/documentation/utils/helpers.rb +205 -0
- data/lib/xseed/documentation/utils/namespaces.rb +149 -0
- data/lib/xseed/documentation/utils/references.rb +135 -0
- data/lib/xseed/documentation/utils/strings.rb +75 -0
- data/lib/xseed/models/element_declaration.rb +144 -0
- data/lib/xseed/parser/xsd_parser.rb +192 -0
- data/lib/xseed/version.rb +5 -0
- data/lib/xseed.rb +76 -0
- data/xseed.gemspec +39 -0
- metadata +158 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Xseed
|
|
4
|
+
module Documentation
|
|
5
|
+
# Configuration class for HTML documentation generation
|
|
6
|
+
# Ported from xs3p core/parameters.xsl
|
|
7
|
+
class Config
|
|
8
|
+
# Title of HTML document
|
|
9
|
+
attr_accessor :title
|
|
10
|
+
|
|
11
|
+
# If true, sorts the top-level schema components by type, then name
|
|
12
|
+
# Otherwise, displays components in the order they appear in the schema
|
|
13
|
+
attr_accessor :sort_by_component
|
|
14
|
+
|
|
15
|
+
# If true, prints all super-types in the type hierarchy box
|
|
16
|
+
# Otherwise, prints the parent type only
|
|
17
|
+
attr_accessor :print_all_super_types
|
|
18
|
+
|
|
19
|
+
# If true, prints all sub-types in the type hierarchy box
|
|
20
|
+
# Otherwise, prints the direct sub-types only
|
|
21
|
+
attr_accessor :print_all_sub_types
|
|
22
|
+
|
|
23
|
+
# If true, prints out the Glossary section
|
|
24
|
+
attr_accessor :print_glossary
|
|
25
|
+
|
|
26
|
+
# If true, includes SVG diagram references in component sections
|
|
27
|
+
attr_accessor :print_diagrams
|
|
28
|
+
|
|
29
|
+
# Directory for auto-generated SVG diagrams (relative to HTML output directory)
|
|
30
|
+
attr_accessor :diagrams_dir
|
|
31
|
+
|
|
32
|
+
# If true, prints prefix matching namespace of schema components
|
|
33
|
+
# in XML Instance Representation tables
|
|
34
|
+
attr_accessor :print_ns_prefixes
|
|
35
|
+
|
|
36
|
+
# If true, searches 'included' schemas for schema components
|
|
37
|
+
# when generating links and XML Instance Representation tables
|
|
38
|
+
attr_accessor :search_included_schemas
|
|
39
|
+
|
|
40
|
+
# If true, searches 'imported' schemas for schema components
|
|
41
|
+
# when generating links and XML Instance Representation tables
|
|
42
|
+
attr_accessor :search_imported_schemas
|
|
43
|
+
|
|
44
|
+
# File containing the mapping from file locations of external
|
|
45
|
+
# schemas to file locations of their XHTML documentation
|
|
46
|
+
attr_accessor :links_file
|
|
47
|
+
|
|
48
|
+
# Base URL for resolving links
|
|
49
|
+
attr_accessor :base_url
|
|
50
|
+
|
|
51
|
+
# External CSS stylesheet URL (xs3p specific CSS, not Bootstrap)
|
|
52
|
+
attr_accessor :external_css_url
|
|
53
|
+
|
|
54
|
+
# Link to jQuery
|
|
55
|
+
attr_accessor :jquery_url
|
|
56
|
+
|
|
57
|
+
# Link base to Bootstrap CSS and JS
|
|
58
|
+
attr_accessor :bootstrap_url
|
|
59
|
+
|
|
60
|
+
def initialize
|
|
61
|
+
# Set defaults from xs3p parameters
|
|
62
|
+
@title = nil # Use schema filename if nil
|
|
63
|
+
@sort_by_component = true
|
|
64
|
+
@print_all_super_types = true
|
|
65
|
+
@print_all_sub_types = true
|
|
66
|
+
@print_glossary = true
|
|
67
|
+
@print_diagrams = true
|
|
68
|
+
@diagrams_dir = "diagrams"
|
|
69
|
+
@print_ns_prefixes = true
|
|
70
|
+
@search_included_schemas = false
|
|
71
|
+
@search_imported_schemas = false
|
|
72
|
+
@links_file = nil
|
|
73
|
+
@base_url = nil
|
|
74
|
+
@external_css_url = nil
|
|
75
|
+
@jquery_url = "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"
|
|
76
|
+
@bootstrap_url = "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Returns configuration as a hash
|
|
80
|
+
def to_h
|
|
81
|
+
{
|
|
82
|
+
title: @title,
|
|
83
|
+
sort_by_component: @sort_by_component,
|
|
84
|
+
print_all_super_types: @print_all_super_types,
|
|
85
|
+
print_all_sub_types: @print_all_sub_types,
|
|
86
|
+
print_glossary: @print_glossary,
|
|
87
|
+
print_diagrams: @print_diagrams,
|
|
88
|
+
diagrams_dir: @diagrams_dir,
|
|
89
|
+
print_ns_prefixes: @print_ns_prefixes,
|
|
90
|
+
search_included_schemas: @search_included_schemas,
|
|
91
|
+
search_imported_schemas: @search_imported_schemas,
|
|
92
|
+
links_file: @links_file,
|
|
93
|
+
base_url: @base_url,
|
|
94
|
+
external_css_url: @external_css_url,
|
|
95
|
+
jquery_url: @jquery_url,
|
|
96
|
+
bootstrap_url: @bootstrap_url,
|
|
97
|
+
}
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Xseed
|
|
4
|
+
module Documentation
|
|
5
|
+
# Constants used throughout HTML documentation generation
|
|
6
|
+
# Ported from xs3p core/constants.xsl
|
|
7
|
+
module Constants
|
|
8
|
+
# XML Schema Namespace
|
|
9
|
+
XSD_NS = "http://www.w3.org/2001/XMLSchema"
|
|
10
|
+
|
|
11
|
+
# XML Namespace
|
|
12
|
+
XML_NS = "http://www.w3.org/XML/1998/namespace"
|
|
13
|
+
|
|
14
|
+
# Number of spaces to indent from parent element's start tag to
|
|
15
|
+
# child element's start tag
|
|
16
|
+
ELEM_INDENT = 3
|
|
17
|
+
|
|
18
|
+
# Number of spaces to indent from parent element's start tag to
|
|
19
|
+
# attribute's tag
|
|
20
|
+
ATTR_INDENT = 2
|
|
21
|
+
|
|
22
|
+
# Title to use if none provided
|
|
23
|
+
DEFAULT_TITLE = "XML Schema Documentation"
|
|
24
|
+
|
|
25
|
+
# Prefixes used for anchor names
|
|
26
|
+
# Type definitions (both complex and simple)
|
|
27
|
+
TYPE_PREFIX = "type_"
|
|
28
|
+
# Attribute declarations
|
|
29
|
+
ATTR_PREFIX = "attribute_"
|
|
30
|
+
# Attribute group definitions
|
|
31
|
+
ATTR_GROUP_PREFIX = "attributeGroup_"
|
|
32
|
+
# Element declarations
|
|
33
|
+
ELEM_PREFIX = "element_"
|
|
34
|
+
# Key definitions
|
|
35
|
+
KEY_PREFIX = "key_"
|
|
36
|
+
# Group definitions
|
|
37
|
+
GROUP_PREFIX = "group_"
|
|
38
|
+
# Notations
|
|
39
|
+
NOTATION_PREFIX = "notation_"
|
|
40
|
+
# Namespace declarations
|
|
41
|
+
NS_PREFIX = "ns_"
|
|
42
|
+
# Glossary terms
|
|
43
|
+
TERM_PREFIX = "term_"
|
|
44
|
+
|
|
45
|
+
# Help texts used throughout the document
|
|
46
|
+
# Hierarchy table
|
|
47
|
+
HELP_HIERARCHY = "This table shows the schema components type hierarchy."
|
|
48
|
+
|
|
49
|
+
# Properties table
|
|
50
|
+
HELP_PROPERTIES = "This table displays the properties of the schema component."
|
|
51
|
+
|
|
52
|
+
# Documentation panel
|
|
53
|
+
HELP_DOCUMENTATION = "This panel contains the schema components documentation."
|
|
54
|
+
|
|
55
|
+
# Instance table
|
|
56
|
+
HELP_INSTANCE = <<~HELP.strip
|
|
57
|
+
The XML Instance Representation table shows the schema component's content as an XML instance.
|
|
58
|
+
<ul>
|
|
59
|
+
<li>The minimum and maximum occurrence of elements and attributes are provided in square brackets, e.g. [0..1].</li>
|
|
60
|
+
<li>Model group information are shown in gray, e.g. Start Choice ... End Choice.</li>
|
|
61
|
+
<li>For type derivations, the elements and attributes that have been added to or changed from the base type's content are shown in <strong>bold</strong></li>
|
|
62
|
+
<li>If an element/attribute has a fixed value, the fixed value is shown in green.</li>
|
|
63
|
+
<li>If a local element/attribute has documentation, it will be displayed in a window that pops up when the question mark inside the attribute or next to the element is clicked.</li>
|
|
64
|
+
</ul>
|
|
65
|
+
HELP
|
|
66
|
+
|
|
67
|
+
# Representation table
|
|
68
|
+
HELP_REPRESENTATION = "The Schema Component Representation table below displays " \
|
|
69
|
+
"the underlying XML representation of the schema component. " \
|
|
70
|
+
"(Annotations are not shown.)"
|
|
71
|
+
|
|
72
|
+
# Navigation panel width
|
|
73
|
+
NAV_WIDTH = "270px"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|