Skip to content

Commit

Permalink
Update Formatter output to follow ISO/TC 184/SC 4 Supplementary Direc…
Browse files Browse the repository at this point in the history
…tives (#65) (#70)
  • Loading branch information
zakjan authored Mar 9, 2021
1 parent 89ab515 commit 37015c9
Show file tree
Hide file tree
Showing 49 changed files with 5,412 additions and 4,384 deletions.
64 changes: 51 additions & 13 deletions exe/format
Original file line number Diff line number Diff line change
@@ -1,27 +1,65 @@
#!/usr/bin/env ruby

require "yaml"
require "expressir/express_exp/parser"
require "expressir/express_exp/formatter"
require "expressir/express_exp/schema_head_formatter"
require "expressir/express_exp/hyperlink_formatter"

input_files = [
exp_files = [
# basic test
# '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
# cyclic reference test
# '../iso-10303-stepmod/data/modules/analysis/mim_annotated.exp',
# '../iso-10303-stepmod/data/modules/analysis_product_relationships/mim_annotated.exp',
# cyclic reference test 2
# '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp'
# renamed reference test
'../iso-10303-stepmod/ballots/ballots/ap210_wg12/express/resources/mathematical_functions_schema.exp',
'../iso-10303-stepmod/data/resources/iso13584_expressions_schema/iso13584_expressions_schema.exp',
# all valid iso-10303-stepmod files (takes 10 min)
# *`bundle exec ../stepmod-utils/exe/stepmod-find-express-files ../iso-10303-stepmod`.strip.split("\n").map{|file| File.exists?(file.sub(/\.exp$/, '_annotated.exp')) ? file.sub(/\.exp$/, '_annotated.exp') : file}
# '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp',
# renamed reference test (36s)
# '../iso-10303-stepmod/ballots/ballots/ap210_wg12/express/resources/mathematical_functions_schema.exp',
# '../iso-10303-stepmod/data/resources/iso13584_expressions_schema/iso13584_expressions_schema.exp',
# annotated-express test (12s)
# see https://github.com/metanorma/annotated-express/blob/master/data/documents/resources/fundamentals_of_product_description_and_support/sections/04-schemas.adoc
# '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/application_context_schema/application_context_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/approval_schema/approval_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/certification_schema/certification_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/contract_schema/contract_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/date_time_schema/date_time_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/document_schema/document_schema.exp',
# '../iso-10303-stepmod/data/resources/effectivity_schema/effectivity_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/experience_schema/experience_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/external_reference_schema/external_reference_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/group_schema/group_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/language_schema/language_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/location_schema/location_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/management_resources_schema/management_resources_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/measure_schema/measure_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/person_organization_schema/person_organization_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/process_property_schema/process_property_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/product_definition_schema/product_definition_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/qualifications_schema/qualifications_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/security_classification_schema/security_classification_schema_annotated.exp',
# '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
# full test (6m18s + 8s = 6m26s)
*`bundle exec ../stepmod-utils/exe/stepmod-find-express-files ../iso-10303-stepmod`.strip.split("\n").map{|file| File.exists?(file.sub(/\.exp$/, '_annotated.exp')) ? file.sub(/\.exp$/, '_annotated.exp') : file}
]

repo = Expressir::ExpressExp::Parser.from_files(input_files)
# schema = repo.schemas.find{|x| x.id == 'action_schema'}
# schema = repo.schemas.find{|x| x.id == 'product_property_definition_schema'}
schema = repo.schemas.find{|x| x.id == 'mathematical_functions_schema'}
result = Expressir::ExpressExp::HyperlinkFormatter.format(schema)
start = Time.now
repository = Expressir::ExpressExp::Parser.from_files(exp_files)
puts "Parsing time: #{Time.now - start}"
start2 = Time.now
formatter = Class.new(Expressir::ExpressExp::Formatter) do
include Expressir::ExpressExp::SchemaHeadFormatter
include Expressir::ExpressExp::HyperlinkFormatter
end
result = repository.to_hash(formatter: formatter, skip_empty: true)
puts "Formatting & serializing time: #{Time.now - start2}"
puts "Total time: #{Time.now - start}"

puts result
# puts YAML.dump(result)
Loading

0 comments on commit 37015c9

Please sign in to comment.