metanorma-standoc 1.5.3 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +66 -0
  3. data/README.adoc +1 -3
  4. data/lib/asciidoctor/standoc/base.rb +6 -1
  5. data/lib/asciidoctor/standoc/basicdoc.rng +4 -11
  6. data/lib/asciidoctor/standoc/cleanup.rb +78 -12
  7. data/lib/asciidoctor/standoc/cleanup_block.rb +41 -4
  8. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
  9. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +25 -0
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +6 -2
  11. data/lib/asciidoctor/standoc/cleanup_ref.rb +3 -4
  12. data/lib/asciidoctor/standoc/converter.rb +58 -3
  13. data/lib/asciidoctor/standoc/front.rb +9 -3
  14. data/lib/asciidoctor/standoc/front_contributor.rb +43 -11
  15. data/lib/asciidoctor/standoc/inline.rb +18 -40
  16. data/lib/asciidoctor/standoc/isodoc.rng +27 -50
  17. data/lib/asciidoctor/standoc/lists.rb +4 -2
  18. data/lib/asciidoctor/standoc/macros.rb +28 -2
  19. data/lib/asciidoctor/standoc/ref.rb +46 -48
  20. data/lib/asciidoctor/standoc/ref_sect.rb +16 -8
  21. data/lib/asciidoctor/standoc/section.rb +5 -9
  22. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  23. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  24. data/lib/metanorma/standoc.rb +0 -5
  25. data/lib/metanorma/standoc/version.rb +20 -1
  26. data/metanorma-standoc.gemspec +7 -3
  27. data/spec/asciidoctor-standoc/base_spec.rb +246 -9
  28. data/spec/asciidoctor-standoc/blocks_spec.rb +1 -1
  29. data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1514 -0
  30. data/spec/asciidoctor-standoc/cleanup_spec.rb +384 -1547
  31. data/spec/asciidoctor-standoc/inline_spec.rb +128 -4
  32. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +15 -22
  33. data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
  34. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +1 -1
  35. data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
  36. data/spec/asciidoctor-standoc/macros_spec.rb +258 -0
  37. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +1 -1
  38. data/spec/asciidoctor-standoc/refs_dl_spec.rb +8 -8
  39. data/spec/asciidoctor-standoc/refs_spec.rb +362 -104
  40. data/spec/asciidoctor-standoc/validate_spec.rb +26 -0
  41. data/spec/fixtures/diagram_definitions.lutaml +22 -0
  42. data/spec/fixtures/test.exp +121 -0
  43. data/spec/spec_helper.rb +34 -1
  44. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +201 -3
  45. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +47 -231
  46. data/spec/vcr_cassettes/isobib_get_123.yml +14 -60
  47. data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -116
  48. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  49. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
  50. data/spec/vcr_cassettes/isobib_get_124.yml +12 -58
  51. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  52. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +292 -162
  53. metadata +59 -17
  54. data/.github/workflows/macos.yml +0 -46
  55. data/.github/workflows/ubuntu.yml +0 -49
  56. data/.github/workflows/windows.yml +0 -53
  57. data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +0 -123
  58. data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +0 -43
  59. data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +0 -43
  60. data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
  61. data/lib/metanorma/standoc/requirement.rb +0 -13
@@ -369,4 +369,30 @@ it "err file succesfully created for docfile path" do
369
369
  expect(File.read("test/test.err")).to include "Hanging paragraph in clause"
370
370
  end
371
371
 
372
+ it "Warning if no block for footnoteblock" do
373
+ FileUtils.rm_f "test.err"
374
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
375
+ = Document title
376
+ Author
377
+ :docfile: test.adoc
378
+
379
+ footnoteblock:[id1]
380
+
381
+ [[id2]]
382
+ [NOTE]
383
+ --
384
+ |===
385
+ |a |b
386
+
387
+ |c |d
388
+ |===
389
+
390
+ * A
391
+ * B
392
+ * C
393
+ --
394
+ INPUT
395
+ expect(File.read("test.err")).to include 'Could not resolve footnoteblock:[id1]'
396
+ end
397
+
372
398
  end
@@ -0,0 +1,22 @@
1
+ diagram MyView {
2
+ title "my diagram"
3
+
4
+ enum AddressClassProfile {
5
+ imlicistAttributeProfile: CharacterString [0..1] {
6
+ definition
7
+ this is multiline with `ascidoc`
8
+ comments
9
+ and list
10
+ end definition
11
+ }
12
+ }
13
+
14
+ class AttributeProfile {
15
+ +addressClassProfile: CharacterString [0..1]
16
+ imlicistAttributeProfile: CharacterString [0..1] {
17
+ definition this is attribute definition
18
+ with multiply lines
19
+ end definition
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,121 @@
1
+ (*
2
+ $Id: test.exp,v 1.3 2020/07/30 05:18:54 ftanaka Exp $
3
+ ISO 10303 TC184/SC4/WG12 N10658
4
+
5
+ EXPRESS Source:
6
+ ISO 10303-59 ed3 Quality of product shape data - Annotated 3d model data quality criteria schema
7
+
8
+ The following permission notice and disclaimer shall be included in all copies of this EXPRESS schema ("the Schema"),
9
+ and derivations of the Schema:
10
+
11
+ Copyright ISO 2020 All rights reserved
12
+ Permission is hereby granted, free of charge in perpetuity, to any person obtaining a copy of the Schema,
13
+ to use, copy, modify, merge and distribute free of charge, copies of the Schema for the purposes of developing,
14
+ implementing, installing and using software based on the Schema, and to permit persons to whom the Schema is furnished to do so,
15
+ subject to the following conditions:
16
+
17
+ THE SCHEMA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SCHEMA OR THE
22
+ USE OR OTHER DEALINGS IN THE SCHEMA.
23
+
24
+ In addition, any modified copy of the Schema shall include the following notice:
25
+
26
+ THIS SCHEMA HAS BEEN MODIFIED FROM THE SCHEMA DEFINED IN
27
+ ISO 10303-59 ed3 Quality of product shape data - Annotated 3d model data quality criteria schema
28
+ AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD
29
+ *)
30
+
31
+ SCHEMA annotated_3d_model_data_quality_criteria_schema '{iso standard 10303 part(59) version(3) object(1) annotated_3d_model_data_quality_criteria_schema(6)}';
32
+
33
+ (* Need select eleemnts for measure_value *)
34
+ REFERENCE FROM measure_schema
35
+ (measure_value);
36
+
37
+ REFERENCE FROM product_data_quality_criteria_schema
38
+ (data_quality_criteria_representation,
39
+ data_quality_criterion,
40
+ data_quality_measurement_requirement,
41
+ detailed_report_request_with_number_of_data,
42
+ summary_report_request);
43
+
44
+ REFERENCE FROM representation_schema
45
+ (representation,
46
+ representation_item);
47
+
48
+ REFERENCE FROM shape_data_quality_criteria_schema
49
+ (shape_data_quality_assessment_specification_select,
50
+ shape_measurement_accuracy);
51
+
52
+ REFERENCE FROM support_resource_schema
53
+ (identifier,
54
+ label,
55
+ text);
56
+
57
+ TYPE a3m_accuracy_associated_target_select = EXTENSIBLE SELECT;
58
+ END_TYPE;
59
+
60
+ TYPE a3m_data_quality_accuracy_type_name = EXTENSIBLE ENUMERATION;
61
+ END_TYPE;
62
+
63
+ TYPE a3m_data_quality_inspected_element_type_name = EXTENSIBLE ENUMERATION;
64
+ END_TYPE;
65
+
66
+ TYPE a3m_data_quality_measured_data_type_name = EXTENSIBLE ENUMERATION;
67
+ END_TYPE;
68
+
69
+ TYPE a3m_data_quality_type_name_for_location_of_extreme_value = EXTENSIBLE ENUMERATION;
70
+ END_TYPE;
71
+
72
+ TYPE summary_stats_value_type = ENUMERATION OF
73
+ (average_value,
74
+ max_value,
75
+ min_value);
76
+ END_TYPE;
77
+
78
+ ENTITY a3m_data_quality_criteria_representation
79
+ SUBTYPE OF (data_quality_criteria_representation);
80
+ WHERE
81
+ WR1: SIZEOF( QUERY( q <* SELF\representation.items|
82
+ 'ANNOTATED_3D_MODEL_DATA_QUALITY_CRITERIA_SCHEMA.' +
83
+ 'A3M_DATA_QUALITY_CRITERION' IN TYPEOF(q))) > 0;
84
+ END_ENTITY;
85
+
86
+ ENTITY a3m_data_quality_criterion
87
+ ABSTRACT SUPERTYPE
88
+ SUBTYPE OF(data_quality_criterion, data_quality_measurement_requirement);
89
+ assessment_specification : shape_data_quality_assessment_specification_select;
90
+ measured_data_type : a3m_data_quality_measured_data_type_name;
91
+ inspected_elements_types: LIST[1:?] OF a3m_data_quality_inspected_element_type_name;
92
+ accuracy_types : LIST [0:?] OF a3m_data_quality_accuracy_type_name;
93
+ location_of_extreme_value_types: LIST[0:?] OF a3m_data_quality_type_name_for_location_of_extreme_value;
94
+ END_ENTITY;
95
+
96
+ ENTITY a3m_data_quality_criterion_specific_applied_value
97
+ ABSTRACT SUPERTYPE
98
+ SUBTYPE OF(representation_item);
99
+ criterion_to_assign_the_value: a3m_data_quality_criterion;
100
+ applied_value : measure_value;
101
+ END_ENTITY;
102
+
103
+ ENTITY a3m_data_quality_target_accuracy_association;
104
+ id : identifier;
105
+ name : label;
106
+ description : OPTIONAL text;
107
+ accuracy_specification : shape_measurement_accuracy;
108
+ target_to_associate : a3m_accuracy_associated_target_select;
109
+ END_ENTITY;
110
+
111
+ ENTITY a3m_detailed_report_request
112
+ SUBTYPE OF(detailed_report_request_with_number_of_data);
113
+ value_type_requested : summary_stats_value_type;
114
+ END_ENTITY;
115
+
116
+ ENTITY a3m_summary_report_request_with_representative_value
117
+ SUBTYPE OF(summary_report_request);
118
+ value_type_requested : summary_stats_value_type;
119
+ END_ENTITY;
120
+
121
+ END_SCHEMA;
@@ -3,6 +3,11 @@ require "vcr"
3
3
  VCR.configure do |config|
4
4
  config.cassette_library_dir = "spec/vcr_cassettes"
5
5
  config.hook_into :webmock
6
+ config.default_cassette_options = {
7
+ clean_outdated_http_interactions: true,
8
+ re_record_interval: 1512000,
9
+ record: :once,
10
+ }
6
11
  end
7
12
 
8
13
  require "simplecov"
@@ -135,7 +140,25 @@ HDR
135
140
 
136
141
  BLANK_HDR = <<~"HDR".freeze
137
142
  <?xml version="1.0" encoding="UTF-8"?>
138
- <standard-document xmlns="https://www.metanorma.org/ns/standoc">
143
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" version="#{Metanorma::Standoc::VERSION}" type="semantic">
144
+ <bibdata type="standard">
145
+ <title language="en" format="text/plain">Document title</title>
146
+ <language>en</language>
147
+ <script>Latn</script>
148
+ <status><stage>published</stage></status>
149
+ <copyright>
150
+ <from>#{Time.new.year}</from>
151
+ </copyright>
152
+ <ext>
153
+ <doctype>article</doctype>
154
+ </ext>
155
+ </bibdata>
156
+ HDR
157
+
158
+ BLANK_METANORMA_HDR = <<~"HDR".freeze
159
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
160
+ <?xml version="1.0" encoding="UTF-8"?><html><body>
161
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" version="#{Metanorma::Standoc::VERSION}" type="semantic">
139
162
  <bibdata type="standard">
140
163
  <title language="en" format="text/plain">Document title</title>
141
164
  <language>en</language>
@@ -248,3 +271,13 @@ def mock_open_uri(code)
248
271
  File.read file, encoding: "utf-8"
249
272
  end.at_least :once
250
273
  end
274
+
275
+ def metanorma_process(input)
276
+ Metanorma::Input::Asciidoc
277
+ .new
278
+ .process(input, "test.adoc", :standoc)
279
+ end
280
+
281
+ def xml_string_conent(xml)
282
+ strip_guid(Nokogiri::HTML(xml).to_s)
283
+ end
@@ -17,7 +17,8 @@ RSpec.shared_examples "structured data 2 text preprocessor" do
17
17
  [{ "name" => "spaghetti",
18
18
  "desc" => "wheat noodles of 9mm diameter",
19
19
  "symbol" => "SPAG",
20
- "symbol_def" => "the situation is message like spaghetti at a kid's meal" }]
20
+ "symbol_def" =>
21
+ "the situation is message like spaghetti at a kid's meal" }]
21
22
  end
22
23
  let(:input) do
23
24
  <<~TEXT
@@ -449,8 +450,10 @@ RSpec.shared_examples "structured data 2 text preprocessor" do
449
450
  "target_script" => "Latn",
450
451
  "system" =>
451
452
  { "id" => "2002",
452
- "specification" => "Academica Sinica -- Chinese Tongyong Pinyin (2002)" },
453
- "notes" => "NOTE: OGC 11-122r1 code `zho_Hani2Latn_AcadSin_2002`" } } }
453
+ "specification" =>
454
+ "Academica Sinica -- Chinese Tongyong Pinyin (2002)" },
455
+ "notes" =>
456
+ "NOTE: OGC 11-122r1 code `zho_Hani2Latn_AcadSin_2002`" } } }
454
457
  end
455
458
  let(:input) do
456
459
  <<~TEXT
@@ -579,5 +582,200 @@ RSpec.shared_examples "structured data 2 text preprocessor" do
579
582
  ).to(be_equivalent_to(xmlpp(output)))
580
583
  end
581
584
  end
585
+
586
+ context "Date time objects support" do
587
+ let(:example_content) do
588
+ {
589
+ "date" => Date.parse("1889-09-28"),
590
+ "time" => Time.gm(2020, 10, 15, 5, 34),
591
+ }
592
+ end
593
+ let(:input) do
594
+ <<~TEXT
595
+ = Document title
596
+ Author
597
+ :docfile: test.adoc
598
+ :nodoc:
599
+ :novalid:
600
+ :no-isobib:
601
+ :imagesdir: spec/assets
602
+
603
+ [#{extention}2text,#{example_file},my_context]
604
+ ----
605
+ {{my_context.time}}
606
+
607
+ {{my_context.date}}
608
+ ----
609
+ TEXT
610
+ end
611
+ let(:output) do
612
+ <<~TEXT
613
+ #{BLANK_HDR}
614
+ <sections>
615
+ <p id='_'>1889-09-28</p>
616
+ <p id='_'>2020-10-15 05:34:00 UTC</p>
617
+ </sections>
618
+ </standard-document>
619
+ TEXT
620
+ end
621
+
622
+ it "renders liquid markup" do
623
+ expect(
624
+ xmlpp(
625
+ strip_guid(
626
+ Asciidoctor.convert(input,
627
+ backend: :standoc,
628
+ header_footer: true)
629
+ )
630
+ )
631
+ ).to(be_equivalent_to(xmlpp(output)))
632
+ end
633
+ end
634
+
635
+ context "Nested files support" do
636
+ let(:example_content) do
637
+ {
638
+ "date" => Date.parse("1889-09-28"),
639
+ "time" => Time.gm(2020, 10, 15, 5, 34),
640
+ }
641
+ end
642
+ let(:parent_file) { "parent_file.#{extention}" }
643
+ let(:parent_file_content) { [nested_file, nested_file_2] }
644
+ let(:parent_file_2) { "parent_file_2.#{extention}" }
645
+ let(:parent_file_2_content) { ["name", "description"] }
646
+ let(:parent_file_3) { "parent_file_3.#{extention}" }
647
+ let(:parent_file_3_content) { ["one", "two"] }
648
+ let(:nested_file) { "nested_file.#{extention}" }
649
+ let(:nested_file_content) do
650
+ {
651
+ "name" => "nested file-main",
652
+ "description" => "nested description-main",
653
+ "one" => "nested one-main",
654
+ "two" => "nested two-main",
655
+ }
656
+ end
657
+ let(:nested_file_2) { "nested_file_2.#{extention}" }
658
+ let(:nested_file_2_content) do
659
+ {
660
+ "name" => "nested2 name-main",
661
+ "description" => "nested2 description-main",
662
+ "one" => "nested2 one-main",
663
+ "two" => "nested2 two-main",
664
+ }
665
+ end
666
+ let(:input) do
667
+ <<~TEXT
668
+ = Document title
669
+ Author
670
+ :docfile: test.adoc
671
+ :nodoc:
672
+ :novalid:
673
+ :no-isobib:
674
+ :imagesdir: spec/assets
675
+
676
+ [#{extention}2text,#{parent_file},paths]
677
+ ----
678
+ {% for path in paths %}
679
+
680
+ [#{extention}2text,#{parent_file_2},attribute_names]
681
+ ---
682
+ {% for name in attribute_names %}
683
+
684
+ [#{extention}2text,{{ path }},data]
685
+ --
686
+
687
+ == {{ data[name] | split: "-" | last }}: {{ data[name] }}
688
+
689
+ --
690
+
691
+ {% endfor %}
692
+ ---
693
+
694
+ [#{extention}2text,#{parent_file_3},attribute_names]
695
+ ---
696
+ {% for name in attribute_names %}
697
+
698
+ [#{extention}2text,{{ path }},data]
699
+ --
700
+
701
+ == {{ data[name] }}
702
+
703
+ --
704
+
705
+ {% endfor %}
706
+ ---
707
+
708
+ {% endfor %}
709
+ ----
710
+ TEXT
711
+ end
712
+ let(:output) do
713
+ <<~TEXT
714
+ #{BLANK_HDR}
715
+ <sections>
716
+ <clause id='_' inline-header='false' obligation='normative'>
717
+ <title>main: nested file-main</title>
718
+ </clause>
719
+ <clause id='_' inline-header='false' obligation='normative'>
720
+ <title>main: nested description-main</title>
721
+ </clause>
722
+ <clause id='_' inline-header='false' obligation='normative'>
723
+ <title>nested one-main</title>
724
+ </clause>
725
+ <clause id='_' inline-header='false' obligation='normative'>
726
+ <title>nested two-main</title>
727
+ </clause>
728
+ <clause id='_' inline-header='false' obligation='normative'>
729
+ <title>main: nested2 name-main</title>
730
+ </clause>
731
+ <clause id='_' inline-header='false' obligation='normative'>
732
+ <title>main: nested2 description-main</title>
733
+ </clause>
734
+ <clause id='_' inline-header='false' obligation='normative'>
735
+ <title>nested2 one-main</title>
736
+ </clause>
737
+ <clause id='_' inline-header='false' obligation='normative'>
738
+ <title>nested2 two-main</title>
739
+ </clause>
740
+ </sections>
741
+ </standard-document>
742
+ TEXT
743
+ end
744
+ let(:file_list) do
745
+ {
746
+ parent_file => parent_file_content,
747
+ parent_file_2 => parent_file_2_content,
748
+ parent_file_3 => parent_file_3_content,
749
+ nested_file => nested_file_content,
750
+ nested_file_2 => nested_file_2_content,
751
+ }
752
+ end
753
+
754
+ before do
755
+ file_list.each_pair do |file, content|
756
+ File.open(file, "w") do |n|
757
+ n.puts(transform_to_type(content))
758
+ end
759
+ end
760
+ end
761
+
762
+ after do
763
+ file_list.keys.each do |file|
764
+ FileUtils.rm_rf(file)
765
+ end
766
+ end
767
+
768
+ it "renders liquid markup" do
769
+ expect(
770
+ xmlpp(
771
+ strip_guid(
772
+ Asciidoctor.convert(input,
773
+ backend: :standoc,
774
+ header_footer: true)
775
+ )
776
+ )
777
+ ).to(be_equivalent_to(xmlpp(output)))
778
+ end
779
+ end
582
780
  end
583
781
  end