suma 0.2.5 → 0.3.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 +4 -4
- data/.github/workflows/rake.yml +3 -0
- data/.github/workflows/release.yml +5 -1
- data/.gitignore +10 -1
- data/.rubocop_todo.yml +237 -28
- data/CLAUDE.md +102 -0
- data/Gemfile +3 -1
- data/README.adoc +188 -1
- data/exe/suma +1 -1
- data/lib/suma/cli/build.rb +2 -8
- data/lib/suma/cli/check_svg_quality.rb +172 -0
- data/lib/suma/cli/compare.rb +6 -158
- data/lib/suma/cli/convert_jsdai.rb +0 -2
- data/lib/suma/cli/core.rb +119 -0
- data/lib/suma/cli/export.rb +1 -10
- data/lib/suma/cli/extract_terms.rb +10 -654
- data/lib/suma/cli/generate_register.rb +34 -0
- data/lib/suma/cli/generate_schemas.rb +8 -124
- data/lib/suma/cli/reformat.rb +0 -1
- data/lib/suma/cli/validate.rb +0 -2
- data/lib/suma/cli/validate_links.rb +14 -291
- data/lib/suma/cli.rb +12 -102
- data/lib/suma/collection_config.rb +0 -2
- data/lib/suma/collection_manifest.rb +7 -111
- data/lib/suma/eengine/wrapper.rb +0 -1
- data/lib/suma/eengine.rb +8 -0
- data/lib/suma/express_schema.rb +43 -31
- data/lib/suma/jsdai/figure.rb +0 -3
- data/lib/suma/jsdai/figure_xml.rb +12 -9
- data/lib/suma/jsdai.rb +5 -8
- data/lib/suma/link_validator.rb +211 -0
- data/lib/suma/manifest_traverser.rb +92 -0
- data/lib/suma/processor.rb +76 -105
- data/lib/suma/register_manifest_generator.rb +163 -0
- data/lib/suma/schema_category.rb +83 -0
- data/lib/suma/schema_collection.rb +28 -63
- data/lib/suma/schema_comparer.rb +117 -0
- data/lib/suma/schema_compiler.rb +86 -0
- data/lib/suma/schema_discovery.rb +75 -0
- data/lib/suma/schema_exporter.rb +7 -35
- data/lib/suma/schema_index.rb +53 -0
- data/lib/suma/schema_manifest_generator.rb +113 -0
- data/lib/suma/schema_naming.rb +111 -0
- data/lib/suma/schema_template/document.rb +141 -0
- data/lib/suma/schema_template/plain.rb +46 -0
- data/lib/suma/schema_template.rb +19 -0
- data/lib/suma/svg_quality/batch_report.rb +78 -0
- data/lib/suma/svg_quality/formatters/json_formatter.rb +30 -0
- data/lib/suma/svg_quality/formatters/terminal_formatter.rb +168 -0
- data/lib/suma/svg_quality/formatters/yaml_formatter.rb +32 -0
- data/lib/suma/svg_quality/formatters.rb +12 -0
- data/lib/suma/svg_quality/report.rb +52 -0
- data/lib/suma/svg_quality.rb +30 -0
- data/lib/suma/term_extractor.rb +466 -0
- data/lib/suma/urn.rb +61 -0
- data/lib/suma/utils.rb +10 -2
- data/lib/suma/version.rb +1 -1
- data/lib/suma.rb +34 -5
- data/suma.gemspec +3 -2
- metadata +53 -9
- data/lib/suma/export_standalone_schema.rb +0 -14
- data/lib/suma/schema_attachment.rb +0 -130
- data/lib/suma/schema_document.rb +0 -132
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "thor"
|
|
4
|
+
require "expressir"
|
|
5
|
+
require "expressir/cli"
|
|
6
|
+
|
|
7
|
+
module Suma
|
|
8
|
+
module Cli
|
|
9
|
+
# Top-level CLI entrypoint.
|
|
10
|
+
#
|
|
11
|
+
# Each command delegates to a dedicated Thor class under +Suma::Cli::+,
|
|
12
|
+
# which reparses ARGV and therefore owns the canonical +option+
|
|
13
|
+
# declarations. Re-declaring options here would duplicate the inner
|
|
14
|
+
# classes' declarations and cause help text and validation logic to
|
|
15
|
+
# drift. Options are declared in exactly one place (the inner class).
|
|
16
|
+
#
|
|
17
|
+
# The exception is +check_svg_quality+, which constructs its analyzer
|
|
18
|
+
# inline (no inner Thor class), so its options belong here.
|
|
19
|
+
class Core < Thor
|
|
20
|
+
extend ThorExt::Start
|
|
21
|
+
|
|
22
|
+
desc "build METANORMA_SITE_MANIFEST",
|
|
23
|
+
"Build collection specified in site manifest (`metanorma*.yml`)"
|
|
24
|
+
def build(_site_manifest)
|
|
25
|
+
Cli::Build.start
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc "generate-schemas METANORMA_MANIFEST_FILE SCHEMA_MANIFEST_FILE",
|
|
29
|
+
"Generate EXPRESS schema manifest file from Metanorma site manifest"
|
|
30
|
+
def generate_schemas(_metanorma_manifest_file, _schema_manifest_file)
|
|
31
|
+
Cli::GenerateSchemas.start
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
desc "reformat EXPRESS_FILE_PATH",
|
|
35
|
+
"Reformat EXPRESS files"
|
|
36
|
+
def reformat(_express_file_path)
|
|
37
|
+
Cli::Reformat.start
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
desc "extract-terms SCHEMA_MANIFEST_FILE GLOSSARIST_OUTPUT_PATH",
|
|
41
|
+
"Extract terms from SCHEMA_MANIFEST_FILE into " \
|
|
42
|
+
"Glossarist v3 format"
|
|
43
|
+
def extract_terms(_schema_manifest_file, _glossarist_output_path)
|
|
44
|
+
Cli::ExtractTerms.start
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
desc "generate-register SCHEMA_MANIFEST_FILE OUTPUT_PATH",
|
|
48
|
+
"Generate a Glossarist register.yaml with hierarchical sections"
|
|
49
|
+
def generate_register(_schema_manifest_file, _output_path)
|
|
50
|
+
Cli::GenerateRegister.start
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
desc "convert-jsdai XML_FILE IMAGE_FILE OUTPUT_DIR",
|
|
54
|
+
"Convert JSDAI XML and image files to SVG and EXP files"
|
|
55
|
+
def convert_jsdai(_xml_file, _image_file, _output_dir)
|
|
56
|
+
Cli::ConvertJsdai.start
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
desc "export *FILES",
|
|
60
|
+
"Export EXPRESS schemas from manifest files or " \
|
|
61
|
+
"standalone EXPRESS files"
|
|
62
|
+
def export(*_files)
|
|
63
|
+
Cli::Export.start
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
desc "compare TRIAL_SCHEMA REFERENCE_SCHEMA",
|
|
67
|
+
"Compare EXPRESS schemas using eengine and generate Change YAML"
|
|
68
|
+
def compare(_trial_schema, _reference_schema)
|
|
69
|
+
Cli::Compare.start
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
desc "validate SUBCOMMAND ...ARGS", "Validate express documents"
|
|
73
|
+
subcommand "validate", Cli::Validate
|
|
74
|
+
|
|
75
|
+
desc "check_svg_quality [PATH]",
|
|
76
|
+
"Check SVG quality and sort by severity (critical files first)"
|
|
77
|
+
option :pattern, type: :string, default: Cli::CheckSvgQuality::DEFAULT_PATTERN,
|
|
78
|
+
desc: "Glob pattern for finding SVG files"
|
|
79
|
+
option :profile, type: :string,
|
|
80
|
+
default: Cli::CheckSvgQuality::DEFAULT_PROFILE,
|
|
81
|
+
desc: "Validation profile to use (metanorma, svg_1_2_rfc, etc.)"
|
|
82
|
+
option :format, type: :string, default: "terminal",
|
|
83
|
+
desc: "Output format: terminal, yaml, json"
|
|
84
|
+
option :output, type: :string, aliases: "-o",
|
|
85
|
+
desc: "Output file path"
|
|
86
|
+
option :min_errors, type: :numeric,
|
|
87
|
+
desc: "Minimum error count threshold"
|
|
88
|
+
option :limit, type: :numeric, default: nil,
|
|
89
|
+
desc: "Maximum number of files to show (default: unlimited)"
|
|
90
|
+
option :sort, type: :string, default: "errors",
|
|
91
|
+
desc: "Sort by: errors (most errors first) or quality (lowest scores first)"
|
|
92
|
+
option :progress, type: :boolean, default: false,
|
|
93
|
+
desc: "Show progress during processing"
|
|
94
|
+
option :summary_only, type: :boolean, default: false,
|
|
95
|
+
desc: "Show only summary"
|
|
96
|
+
def check_svg_quality(path = Cli::CheckSvgQuality::DATA_PATH)
|
|
97
|
+
analyzer = Cli::CheckSvgQuality.new(
|
|
98
|
+
pattern: options[:pattern],
|
|
99
|
+
profile: options[:profile],
|
|
100
|
+
format: options[:format],
|
|
101
|
+
output: options[:output],
|
|
102
|
+
min_errors: options[:min_errors],
|
|
103
|
+
summary_only: options[:summary_only],
|
|
104
|
+
progress: options[:progress],
|
|
105
|
+
limit: options[:limit],
|
|
106
|
+
sort: options[:sort],
|
|
107
|
+
)
|
|
108
|
+
analyzer.run(path)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
desc "expressir SUBCOMMAND ...ARGS", "Expressir commands"
|
|
112
|
+
subcommand "expressir", Expressir::Cli
|
|
113
|
+
|
|
114
|
+
def self.exit_on_failure?
|
|
115
|
+
true
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
data/lib/suma/cli/export.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "thor"
|
|
4
|
-
require_relative "../thor_ext"
|
|
5
|
-
require_relative "../export_standalone_schema"
|
|
6
4
|
|
|
7
5
|
module Suma
|
|
8
6
|
module Cli
|
|
@@ -19,8 +17,6 @@ module Suma
|
|
|
19
17
|
desc: "Create ZIP archive of exported schemas"
|
|
20
18
|
|
|
21
19
|
def export(*files)
|
|
22
|
-
require_relative "../schema_exporter"
|
|
23
|
-
require_relative "../utils"
|
|
24
20
|
require "expressir"
|
|
25
21
|
|
|
26
22
|
validate_files(files)
|
|
@@ -85,12 +81,7 @@ module Suma
|
|
|
85
81
|
end
|
|
86
82
|
|
|
87
83
|
def create_schema_from_exp_file(exp_file)
|
|
88
|
-
|
|
89
|
-
# The id will be determined during parsing
|
|
90
|
-
ExportStandaloneSchema.new(
|
|
91
|
-
id: nil,
|
|
92
|
-
path: File.expand_path(exp_file),
|
|
93
|
-
)
|
|
84
|
+
Struct.new(:id, :path).new(nil, File.expand_path(exp_file))
|
|
94
85
|
end
|
|
95
86
|
|
|
96
87
|
def self.exit_on_failure?
|