metanorma-cc 1.5.6 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d512119733aec0e381d969a3bb23f3908caaa3953cc1ed7524a9d3e727e639c0
4
- data.tar.gz: f26c2d06edb3a888bc8bc2b1214e897eca07e0d3fa6acdc9ae94b745f44fc328
3
+ metadata.gz: a9a16aa57594eeb9bef5c56b9435acf45b50117ffb83ab9ab06cf6d66259f24b
4
+ data.tar.gz: 229912575e2ffcd0eb934f735a1f385379e26da956cbc570ee497101152e58ca
5
5
  SHA512:
6
- metadata.gz: d5187f1fbe65adb3644ae800c8b47be62e7be2c24d8c43266ff50cc01bbb060889cea81c1bd3173d510606ca924fa9054222762d66582974b3226af256dd2078
7
- data.tar.gz: 03c5867a2464256d539ef13936be713653bc512a1cdb447af78de3dc0378508e31d7ab8d52cf34acc71af9f70f6aef9614ddfe55775902bed9b923886e01c8b4
6
+ metadata.gz: a437b86bcf50b69dbab264452d7ca220cf6890752caafab2fa02981903b8ff96e5da5cee23e9e77c19cc35d8ba1583edfcb95dbb40aadc9824c652ac3e95e997
7
+ data.tar.gz: d0fbcc7e60a6238876f028dd857261e083a1aa05751b2fb7bfd0ace712bde1c859e82397f9f1639d756e8ffcb830f2b3a22ba43145199bbe67ce35a649d4522a
@@ -4,7 +4,8 @@ name: rake
4
4
 
5
5
  on:
6
6
  push:
7
- branches: [ master ]
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
8
9
  pull_request:
9
10
 
10
11
  jobs:
@@ -31,14 +32,32 @@ jobs:
31
32
  steps:
32
33
  - uses: actions/checkout@master
33
34
 
34
- - name: Use Ruby
35
- uses: ruby/setup-ruby@v1
35
+ - uses: ruby/setup-ruby@v1
36
36
  with:
37
37
  ruby-version: ${{ matrix.ruby }}
38
- bundler-cache: true
39
38
 
40
- - name: Update gems
41
- run: bundle install --jobs 4 --retry 3
39
+ - uses: actions/cache@v1
40
+ with:
41
+ path: vendor/bundle
42
+ key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
43
+ restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
44
+
45
+ - run: bundle config set path 'vendor/bundle'
46
+
47
+ - run: bundle install --jobs 4 --retry 3
42
48
 
43
- - name: Run specs
44
- run: bundle exec rake
49
+ - run: bundle exec rake
50
+
51
+ notify:
52
+ name: Trigger notify workflow
53
+ needs: rake
54
+ runs-on: ubuntu-latest
55
+ steps:
56
+ - name: Trigger notify workflow
57
+ uses: Sibz/github-status-action@v1
58
+ with:
59
+ authToken: ${{ secrets.GITHUB_TOKEN }}
60
+ context: 'tests-passed-successfully'
61
+ description: 'Tests passed successfully'
62
+ state: 'success'
63
+ sha: ${{ github.event.pull_request.head.sha || github.sha }}
@@ -1,18 +1,14 @@
1
1
  = metanorma-cc: Metanorma processor for CalConnect standards
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-cc.svg["Gem Version", link="https://rubygems.org/gems/metanorma-cc"]
4
- image:https://github.com/metanorma/metanorma-cc/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/metanorma/metanorma-cc/actions?workflow=macos"]
5
- image:https://github.com/metanorma/metanorma-cc/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-cc/actions?workflow=ubuntu"]
6
- image:https://github.com/metanorma/metanorma-cc/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-cc/actions?workflow=windows"]
4
+ image:https://github.com/metanorma/metanorma-cc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-cc/actions?workflow=rake"]
7
5
  image:https://codeclimate.com/github/metanorma/metanorma-cc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-cc"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-cc.svg["Pull Requests", link="https://github.com/metanorma/metanorma-cc/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/metanorma/metanorma-cc/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-cc/releases"]
10
8
 
11
- _Formerly known as_ `asciidoctor-csd`, `metanorma-csd`.
12
-
13
9
  == Functionality
14
10
 
15
- This gem processes http://asciidoctor.org/[Asciidoctor] documents following
11
+ This gem processes https://www.metanorma.com/[Metanorma documents] following
16
12
  the Metanorma model for generating CalConnect Standards.
17
13
 
18
14
  The gem currently inherits from the https://github.com/metanorma/metanorma-standoc
@@ -59,3 +55,6 @@ See https://www.metanorma.com/author/cc/[Author CalConnect documents with Metano
59
55
  * Example documents are avalable at the https://github.com/metanorma/mn-samples-cc[mn-samples-cc] repository.
60
56
  * Document templates are available at the https://github.com/metanorma/mn-templates-cc[mn-templates-cc] repository.
61
57
 
58
+ == Notes
59
+
60
+ Metanorma-CC was formerly published as `asciidoctor-csd` and `metanorma-csd`.
@@ -86,7 +86,7 @@
86
86
  </element>
87
87
  </define>
88
88
  <define name="technical-committee">
89
- <element name="technical-committee">
89
+ <element name="committee">
90
90
  <optional>
91
91
  <attribute name="type"/>
92
92
  </optional>
@@ -4,24 +4,33 @@ require "isodoc/cc/word_convert"
4
4
  require "isodoc/cc/presentation_xml_convert"
5
5
  require "metanorma/cc"
6
6
  require "asciidoctor/standoc/converter"
7
- require "fileutils"
8
- require_relative "validate"
7
+ require 'asciidoctor/generic/converter'
9
8
  require_relative "validate_section"
10
- require_relative "front"
11
9
 
12
10
  module Asciidoctor
13
11
  module CC
14
-
15
- # A {Converter} implementation that generates CC output, and a document
16
- # schema encapsulation of the document for validation
17
- class Converter < Standoc::Converter
12
+ class Converter < Asciidoctor::Generic::Converter
18
13
  XML_ROOT_TAG = "csd-standard".freeze
19
14
  XML_NAMESPACE = "https://www.metanorma.org/ns/csd".freeze
20
15
 
21
16
  register_for "cc"
22
17
 
23
- def initialize(backend, opts)
24
- super
18
+ def configuration
19
+ Metanorma::CC.configuration
20
+ end
21
+
22
+ def metadata_committee(node, xml)
23
+ return unless node.attr("technical-committee")
24
+ xml.editorialgroup do |a|
25
+ a.committee node.attr("technical-committee"),
26
+ **attr_code(type: node.attr("technical-committee-type"))
27
+ i = 2
28
+ while node.attr("technical-committee_#{i}") do
29
+ a.committee node.attr("technical-committee_#{i}"),
30
+ **attr_code(type: node.attr("technical-committee-type_#{i}"))
31
+ i += 1
32
+ end
33
+ end
25
34
  end
26
35
 
27
36
  def outputs(node, ret)
@@ -35,23 +44,6 @@ module Asciidoctor
35
44
  nil, false, "#{@filename}.pdf")
36
45
  end
37
46
 
38
- def validate(doc)
39
- content_validate(doc)
40
- schema_validate(formattedstr_strip(doc.dup),
41
- File.join(File.dirname(__FILE__), "cc.rng"))
42
- end
43
-
44
- def sections_cleanup(x)
45
- super
46
- x.xpath("//*[@inline-header]").each do |h|
47
- h.delete("inline-header")
48
- end
49
- end
50
-
51
- def style(n, t)
52
- return
53
- end
54
-
55
47
  def html_converter(node)
56
48
  IsoDoc::CC::HtmlConvert.new(html_extract_attributes(node))
57
49
  end
@@ -24,6 +24,14 @@
24
24
  <start>
25
25
  <ref name="standard-document"/>
26
26
  </start>
27
+ <define name="doctype">
28
+ <element name="doctype">
29
+ <optional>
30
+ <attribute name="abbreviation"/>
31
+ </optional>
32
+ <ref name="DocumentType"/>
33
+ </element>
34
+ </define>
27
35
  <define name="hyperlink">
28
36
  <element name="link">
29
37
  <attribute name="target">
@@ -141,6 +149,11 @@
141
149
  <data type="boolean"/>
142
150
  </attribute>
143
151
  </optional>
152
+ <optional>
153
+ <attribute name="key">
154
+ <data type="boolean"/>
155
+ </attribute>
156
+ </optional>
144
157
  <oneOrMore>
145
158
  <ref name="dt"/>
146
159
  <ref name="dd"/>
@@ -1,8 +1,9 @@
1
1
  require "nokogiri"
2
+ require "metanorma-generic"
2
3
 
3
4
  module Asciidoctor
4
5
  module CC
5
- class Converter < Standoc::Converter
6
+ class Converter < Asciidoctor::Generic::Converter
6
7
  def section_validate(doc)
7
8
  advisory = doc.root.at("//bibdata/ext[doctype = 'advisory']")
8
9
  symbols_validate(doc.root) unless advisory
@@ -3,18 +3,8 @@ require "isodoc"
3
3
  module IsoDoc
4
4
  module CC
5
5
  module BaseConvert
6
- def cleanup(docxml)
7
- super
8
- term_cleanup(docxml)
9
- end
10
-
11
- def term_cleanup(docxml)
12
- docxml.xpath("//p[@class = 'Terms']").each do |d|
13
- h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
14
- h2.add_child("&nbsp;")
15
- h2.add_child(d.remove)
16
- end
17
- docxml
6
+ def configuration
7
+ Metanorma::CC.configuration
18
8
  end
19
9
  end
20
10
  end
@@ -853,13 +853,22 @@
853
853
  <title-part lang="en">
854
854
 
855
855
 
856
+
856
857
  </title-part>
857
858
  <title-part lang="fr">
858
859
 
859
860
 
861
+
860
862
  </title-part>
861
863
  <title-part lang="zh">第 # 部分:</title-part>
862
864
 
865
+ <title-subpart lang="en">
866
+
867
+ </title-subpart>
868
+ <title-subpart lang="fr">
869
+
870
+ </title-subpart>
871
+
863
872
  <title-modified lang="en">modified</title-modified>
864
873
  <title-modified lang="fr">modifiée</title-modified>
865
874
 
@@ -1328,7 +1337,9 @@
1328
1337
 
1329
1338
 
1330
1339
 
1331
-
1340
+ <!-- <xsl:if test="$namespace = 'bipm'">
1341
+ <fo:block>&#xA0;</fo:block>
1342
+ </xsl:if> -->
1332
1343
 
1333
1344
  <!-- $namespace = 'iso' or -->
1334
1345
 
@@ -1493,6 +1504,7 @@
1493
1504
  <xsl:if test="normalize-space() != ''">
1494
1505
  <fo:block xsl:use-attribute-sets="table-name-style">
1495
1506
 
1507
+
1496
1508
  <xsl:apply-templates/>
1497
1509
  </fo:block>
1498
1510
  </xsl:if>
@@ -1846,6 +1858,7 @@
1846
1858
 
1847
1859
 
1848
1860
 
1861
+
1849
1862
  <!-- <xsl:if test="$namespace = 'bipm'">
1850
1863
  <xsl:attribute name="height">8mm</xsl:attribute>
1851
1864
  </xsl:if> -->
@@ -1931,7 +1944,8 @@
1931
1944
  </xsl:attribute>
1932
1945
  </xsl:if>
1933
1946
  <xsl:call-template name="display-align"/>
1934
- <fo:block>
1947
+ <fo:block>
1948
+
1935
1949
  <xsl:apply-templates/>
1936
1950
  </fo:block>
1937
1951
  </fo:table-cell>
@@ -2143,7 +2157,11 @@
2143
2157
  <xsl:apply-templates/>
2144
2158
  </fo:inline>
2145
2159
  </xsl:template><xsl:template match="*[local-name()='dl']">
2146
- <fo:block-container margin-left="0mm">
2160
+ <fo:block-container>
2161
+
2162
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2163
+
2164
+
2147
2165
  <xsl:if test="parent::*[local-name() = 'note']">
2148
2166
  <xsl:attribute name="margin-left">
2149
2167
  <xsl:choose>
@@ -2153,8 +2171,11 @@
2153
2171
  </xsl:attribute>
2154
2172
 
2155
2173
  </xsl:if>
2156
- <fo:block-container margin-left="0mm">
2157
-
2174
+ <fo:block-container>
2175
+
2176
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2177
+
2178
+
2158
2179
  <xsl:variable name="parent" select="local-name(..)"/>
2159
2180
 
2160
2181
  <xsl:variable name="key_iso">
@@ -2168,9 +2189,12 @@
2168
2189
  <fo:block margin-bottom="12pt" text-align="left">
2169
2190
 
2170
2191
  <xsl:variable name="title-where">
2171
- <xsl:call-template name="getTitle">
2172
- <xsl:with-param name="name" select="'title-where'"/>
2173
- </xsl:call-template>
2192
+
2193
+
2194
+ <xsl:call-template name="getTitle">
2195
+ <xsl:with-param name="name" select="'title-where'"/>
2196
+ </xsl:call-template>
2197
+
2174
2198
  </xsl:variable>
2175
2199
  <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
2176
2200
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
@@ -2186,9 +2210,12 @@
2186
2210
 
2187
2211
 
2188
2212
  <xsl:variable name="title-where">
2189
- <xsl:call-template name="getTitle">
2190
- <xsl:with-param name="name" select="'title-where'"/>
2191
- </xsl:call-template>
2213
+
2214
+
2215
+ <xsl:call-template name="getTitle">
2216
+ <xsl:with-param name="name" select="'title-where'"/>
2217
+ </xsl:call-template>
2218
+
2192
2219
  </xsl:variable>
2193
2220
  <xsl:value-of select="$title-where"/>
2194
2221
  </fo:block>
@@ -2199,9 +2226,12 @@
2199
2226
 
2200
2227
 
2201
2228
  <xsl:variable name="title-key">
2202
- <xsl:call-template name="getTitle">
2203
- <xsl:with-param name="name" select="'title-key'"/>
2204
- </xsl:call-template>
2229
+
2230
+
2231
+ <xsl:call-template name="getTitle">
2232
+ <xsl:with-param name="name" select="'title-key'"/>
2233
+ </xsl:call-template>
2234
+
2205
2235
  </xsl:variable>
2206
2236
  <xsl:value-of select="$title-key"/>
2207
2237
  </fo:block>
@@ -2774,7 +2804,18 @@
2774
2804
  <xsl:with-param name="previousRow" select="$newRow"/>
2775
2805
  </xsl:apply-templates>
2776
2806
  </xsl:template><xsl:template name="getLang">
2777
- <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/>
2807
+ <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
2808
+ <xsl:variable name="language">
2809
+ <xsl:choose>
2810
+ <xsl:when test="$language_current != ''">
2811
+ <xsl:value-of select="$language_current"/>
2812
+ </xsl:when>
2813
+ <xsl:otherwise>
2814
+ <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
2815
+ </xsl:otherwise>
2816
+ </xsl:choose>
2817
+ </xsl:variable>
2818
+
2778
2819
  <xsl:choose>
2779
2820
  <xsl:when test="$language = 'English'">en</xsl:when>
2780
2821
  <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
@@ -2809,6 +2850,7 @@
2809
2850
  <xsl:value-of select="substring($str, 2)"/>
2810
2851
  </xsl:template><xsl:template match="mathml:math">
2811
2852
  <fo:inline font-family="STIX Two Math"> <!-- -->
2853
+
2812
2854
  <xsl:variable name="mathml">
2813
2855
  <xsl:apply-templates select="." mode="mathml"/>
2814
2856
  </xsl:variable>
@@ -2891,10 +2933,14 @@
2891
2933
  </fo:inline>
2892
2934
  </xsl:template><xsl:template match="*[local-name() = 'modification']">
2893
2935
  <xsl:variable name="title-modified">
2894
- <xsl:call-template name="getTitle">
2895
- <xsl:with-param name="name" select="'title-modified'"/>
2896
- </xsl:call-template>
2936
+
2937
+
2938
+ <xsl:call-template name="getTitle">
2939
+ <xsl:with-param name="name" select="'title-modified'"/>
2940
+ </xsl:call-template>
2941
+
2897
2942
  </xsl:variable>
2943
+
2898
2944
  <xsl:choose>
2899
2945
  <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:text>—</xsl:text></xsl:when>
2900
2946
  <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:text> — </xsl:text></xsl:otherwise>
@@ -3619,9 +3665,14 @@
3619
3665
 
3620
3666
  <fo:inline>
3621
3667
 
3622
- <xsl:call-template name="getTitle">
3623
- <xsl:with-param name="name" select="'title-source'"/>
3624
- </xsl:call-template>
3668
+
3669
+
3670
+
3671
+ <xsl:call-template name="getTitle">
3672
+ <xsl:with-param name="name" select="'title-source'"/>
3673
+ </xsl:call-template>
3674
+
3675
+
3625
3676
  <xsl:text>: </xsl:text>
3626
3677
  </fo:inline>
3627
3678
 
@@ -3774,9 +3825,12 @@
3774
3825
  </fo:block>
3775
3826
  </xsl:template><xsl:template match="*[local-name() = 'deprecates']">
3776
3827
  <xsl:variable name="title-deprecated">
3777
- <xsl:call-template name="getTitle">
3778
- <xsl:with-param name="name" select="'title-deprecated'"/>
3779
- </xsl:call-template>
3828
+
3829
+
3830
+ <xsl:call-template name="getTitle">
3831
+ <xsl:with-param name="name" select="'title-deprecated'"/>
3832
+ </xsl:call-template>
3833
+
3780
3834
  </xsl:variable>
3781
3835
  <fo:block xsl:use-attribute-sets="deprecates-style">
3782
3836
  <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
@@ -4142,13 +4196,22 @@
4142
4196
  </xsl:template><xsl:template name="split">
4143
4197
  <xsl:param name="pText" select="."/>
4144
4198
  <xsl:param name="sep" select="','"/>
4199
+ <xsl:param name="normalize-space" select="'true'"/>
4145
4200
  <xsl:if test="string-length($pText) &gt;0">
4146
4201
  <item>
4147
- <xsl:value-of select="normalize-space(substring-before(concat($pText, ','), $sep))"/>
4202
+ <xsl:choose>
4203
+ <xsl:when test="$normalize-space = 'true'">
4204
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
4205
+ </xsl:when>
4206
+ <xsl:otherwise>
4207
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
4208
+ </xsl:otherwise>
4209
+ </xsl:choose>
4148
4210
  </item>
4149
4211
  <xsl:call-template name="split">
4150
4212
  <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
4151
4213
  <xsl:with-param name="sep" select="$sep"/>
4214
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
4152
4215
  </xsl:call-template>
4153
4216
  </xsl:if>
4154
4217
  </xsl:template><xsl:template name="getDocumentId">
@@ -4214,4 +4277,23 @@
4214
4277
  <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
4215
4278
  </xsl:call-template>
4216
4279
  </xsl:if>
4280
+ </xsl:template><xsl:template name="repeat">
4281
+ <xsl:param name="char" select="'*'"/>
4282
+ <xsl:param name="count"/>
4283
+ <xsl:if test="$count &gt; 0">
4284
+ <xsl:value-of select="$char"/>
4285
+ <xsl:call-template name="repeat">
4286
+ <xsl:with-param name="char" select="$char"/>
4287
+ <xsl:with-param name="count" select="$count - 1"/>
4288
+ </xsl:call-template>
4289
+ </xsl:if>
4290
+ </xsl:template><xsl:template name="getLocalizedString">
4291
+ <xsl:param name="key"/>
4292
+
4293
+ <xsl:variable name="curr_lang">
4294
+ <xsl:call-template name="getLang"/>
4295
+ </xsl:variable>
4296
+
4297
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
4298
+
4217
4299
  </xsl:template></xsl:stylesheet>
@@ -1,4 +1,5 @@
1
1
  require_relative "base_convert"
2
+ require "isodoc/generic/html_convert"
2
3
  require_relative "init"
3
4
  require "isodoc"
4
5
 
@@ -6,44 +7,7 @@ module IsoDoc
6
7
  module CC
7
8
  # A {Converter} implementation that generates CC output, and a document
8
9
  # schema encapsulation of the document for validation
9
- class HtmlConvert < IsoDoc::HtmlConvert
10
- def initialize(options)
11
- @libdir = File.dirname(__FILE__)
12
- super
13
- end
14
-
15
- def default_fonts(options)
16
- {
17
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Source Sans Pro",sans-serif'),
18
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Source Sans Pro",sans-serif'),
19
- monospacefont: '"Source Code Pro",monospace'
20
- }
21
- end
22
-
23
- def default_file_locations(options)
24
- {
25
- htmlstylesheet: html_doc_path("htmlstyle.scss"),
26
- htmlcoverpage: html_doc_path("html_cc_titlepage.html"),
27
- htmlintropage: html_doc_path("html_cc_intro.html"),
28
- scripts: html_doc_path("scripts.html"),
29
- }
30
- end
31
-
32
- def googlefonts()
33
- <<~HEAD.freeze
34
- <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,700&display=swap" rel="stylesheet">
35
- <link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
36
- HEAD
37
- end
38
-
39
- def make_body(xml, docxml)
40
- body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
41
- xml.body **body_attr do |body|
42
- make_body1(body, docxml)
43
- make_body2(body, docxml)
44
- make_body3(body, docxml)
45
- end
46
- end
10
+ class HtmlConvert < IsoDoc::Generic::HtmlConvert
47
11
 
48
12
  include BaseConvert
49
13
  include Init
@@ -1,9 +1,8 @@
1
1
  module IsoDoc
2
2
  module CC
3
- class I18n < IsoDoc::I18n
4
- def load_yaml1(lang, script)
5
- y = YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
6
- super.merge(y)
3
+ class I18n < IsoDoc::Generic::I18n
4
+ def configuration
5
+ Metanorma::CC.configuration
7
6
  end
8
7
  end
9
8
  end
@@ -11,7 +11,8 @@ module IsoDoc
11
11
  end
12
12
 
13
13
  def xref_init(lang, script, klass, i18n, options)
14
- @xrefs = Xref.new(lang, script, HtmlConvert.new(language: lang, script: script), i18n, options)
14
+ html = HtmlConvert.new(language: lang, script: script)
15
+ @xrefs = Xref.new(lang, script, html, i18n, options)
15
16
  end
16
17
 
17
18
  def i18n_init(lang, script, i18nyaml = nil)
@@ -3,9 +3,11 @@ require "metanorma/cc"
3
3
 
4
4
  module IsoDoc
5
5
  module CC
6
- # A {Converter} implementation that generates CC output, and a document
7
- # schema encapsulation of the document for validation
8
- class Metadata < IsoDoc::Metadata
6
+ class Metadata < IsoDoc::Generic::Metadata
7
+ def configuration
8
+ Metanorma::CC.configuration
9
+ end
10
+
9
11
  def initialize(lang, script, labels)
10
12
  super
11
13
  set(:tc, "XXXX")
@@ -21,7 +23,7 @@ module IsoDoc
21
23
  end
22
24
 
23
25
  def author(isoxml, _out)
24
- tc = isoxml.at(ns("//bibdata/ext/editorialgroup/technical-committee"))
26
+ tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
25
27
  set(:tc, tc.text) if tc
26
28
  super
27
29
  end
@@ -38,24 +40,6 @@ module IsoDoc
38
40
  set(:roles_authors_affiliations, persons)
39
41
  super
40
42
  end
41
-
42
- def docid(isoxml, _out)
43
- docnumber = isoxml.at(ns("//bibdata/docidentifier"))
44
- prefix = "CC"
45
- if docnumber.nil?
46
- set(:docnumber, prefix)
47
- else
48
- set(:docnumber, docnumber.text)
49
- end
50
- end
51
-
52
- def stage_abbr(status)
53
- ::Metanorma::CC::DOCSTATUS[status] || ""
54
- end
55
-
56
- def unpublished(status)
57
- !%w(published withdrawn).include? status.downcase
58
- end
59
43
  end
60
44
  end
61
45
  end
@@ -1,4 +1,5 @@
1
1
  require_relative "base_convert"
2
+ require "metanorma-generic"
2
3
  require "isodoc"
3
4
 
4
5
  module IsoDoc
@@ -1,9 +1,10 @@
1
1
  require_relative "init"
2
+ require "metanorma-generic"
2
3
  require "isodoc"
3
4
 
4
5
  module IsoDoc
5
6
  module CC
6
- class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
7
+ class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
7
8
  def annex1(f)
8
9
  lbl = @xrefs.anchor(f['id'], :label)
9
10
  if t = f.at(ns("./title"))
@@ -1,4 +1,5 @@
1
1
  require_relative "base_convert"
2
+ require "isodoc/generic/word_convert"
2
3
  require_relative "init"
3
4
  require "isodoc"
4
5
 
@@ -6,31 +7,7 @@ module IsoDoc
6
7
  module CC
7
8
  # A {Converter} implementation that generates CSD output, and a document
8
9
  # schema encapsulation of the document for validation
9
- class WordConvert < IsoDoc::WordConvert
10
- def initialize(options)
11
- @libdir = File.dirname(__FILE__)
12
- super
13
- end
14
-
15
- def default_fonts(options)
16
- {
17
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Source Sans Pro","Arial",sans-serif'),
18
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Source Sans Pro","Arial",sans-serif'),
19
- monospacefont: '"Source Code Pro","Courier New",monospace'
20
- }
21
- end
22
-
23
- def default_file_locations(options)
24
- {
25
- wordstylesheet: html_doc_path("wordstyle.scss"),
26
- standardstylesheet: html_doc_path("cc.scss"),
27
- header: html_doc_path("header.html"),
28
- wordcoverpage: html_doc_path("word_cc_titlepage.html"),
29
- wordintropage: html_doc_path("word_cc_intro.html"),
30
- ulstyle: "l3",
31
- olstyle: "l2",
32
- }
33
- end
10
+ class WordConvert < IsoDoc::Generic::WordConvert
34
11
 
35
12
  include BaseConvert
36
13
  include Init
@@ -1,6 +1,6 @@
1
1
  module IsoDoc
2
2
  module CC
3
- class Xref < IsoDoc::Xref
3
+ class Xref < IsoDoc::Generic::Xref
4
4
  end
5
5
  end
6
6
  end
@@ -1,29 +1,32 @@
1
+ require "metanorma"
2
+ require "metanorma-generic"
1
3
  require_relative "./cc/processor"
2
4
 
3
5
  module Metanorma
4
6
  module CC
7
+ class Configuration < Metanorma::Generic::Configuration
8
+ def initialize(*args)
9
+ super
10
+ end
11
+ end
5
12
 
6
- DOCSUFFIX = {
7
- "standard" => "",
8
- "directive" => "DIR",
9
- "guide" => "Guide",
10
- "specification" => "S",
11
- "report" => "R",
12
- "amendment" => "Amd",
13
- "technical-corrigendum" => "Cor",
14
- "administrative" => "A",
15
- "advisory" => "Adv",
16
- }
13
+ class << self
14
+ extend Forwardable
17
15
 
18
- DOCSTATUS = {
19
- "working-draft" => "WD",
20
- "committee-draft" => "CD",
21
- "draft-standard" => "DS",
22
- "final-draft" => "FDS",
23
- "published" => "",
24
- "cancelled" => "",
25
- "withdrawn" => "",
26
- }
16
+ attr_accessor :configuration
27
17
 
18
+ Configuration::CONFIG_ATTRS.each do |attr_name|
19
+ def_delegator :@configuration, attr_name
20
+ end
21
+
22
+ def configure
23
+ self.configuration ||= Configuration.new
24
+ yield(configuration)
25
+ end
26
+ end
27
+
28
+ configure {}
28
29
  end
29
30
  end
31
+ Metanorma::Registry.instance.register(Metanorma::CC::Processor)
32
+
@@ -10,7 +10,7 @@ module Metanorma
10
10
  }
11
11
  end
12
12
 
13
- class Processor < Metanorma::Processor
13
+ class Processor < Metanorma::Generic::Processor
14
14
 
15
15
  def initialize
16
16
  @short = [:csd, :cc]
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module CC
3
- VERSION = "1.5.6"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
30
30
 
31
- spec.add_dependency "metanorma-standoc", "~> 1.6.0"
31
+ spec.add_dependency "metanorma-generic", "~> 1.7.0"
32
32
  spec.add_dependency "isodoc", "~> 1.2.0"
33
33
 
34
34
  spec.add_development_dependency "byebug", "~> 9.1"
@@ -0,0 +1,52 @@
1
+ metanorma_name: cc
2
+ organization_name_short: CalConnect
3
+ organization_name_long: CalConnect
4
+ document_namespace: https://www.metanorma.org/ns/csd
5
+ xml_root_tag: csd-standard
6
+ html_bodyfont: '"Source Sans Pro",sans-serif'
7
+ html_headerfont: '"Source Sans Pro",sans-serif'
8
+ html_monospacefont: '"Source Code Pro",monospace'
9
+ validate_rng_file: lib/asciidoctor/cc/cc.rng
10
+ htmlcoverpage: lib/isodoc/cc/html/html_cc_titlepage.html
11
+ htmlintropage: lib/isodoc/cc/html/html_cc_intro.html
12
+ htmlstylesheet: lib/isodoc/cc/html/htmlstyle.scss
13
+ scripts: lib/isodoc/cc/html/scripts.html
14
+ i18nyaml: lib/isodoc/cc/i18n-en.yaml
15
+ word_bodyfont: '"Source Sans Pro","Arial",sans-serif'
16
+ word_headerfont: '"Source Sans Pro","Arial",sans-serif'
17
+ word_monospacefont: '"Source Code Pro","Courier New",monospace'
18
+ standardstylesheet: lib/isodoc/cc/html/cc.scss
19
+ header: lib/isodoc/cc/html/header.html
20
+ wordcoverpage: lib/isodoc/cc/html/word_cc_titlepage.html
21
+ wordintropage: lib/isodoc/cc/html/word_cc_intro.html
22
+ wordstylesheet: lib/isodoc/cc/html/wordstyle.scss
23
+ webfont:
24
+ - "https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,700"
25
+ - "https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,700;1,400;1,700"
26
+ docid_template: "CC{% if doctype_abbr %}/{{ doctype_abbr }}{%endif%}{% if stageabbr %}/{{ stageabbr }}{%endif%} {{ docnumeric }}{% if docyear %}:{{docyear}}{%endif%}"
27
+ doctypes:
28
+ standard:
29
+ directive: DIR
30
+ guide: Guide
31
+ specification: S
32
+ report: R
33
+ amendment: Amd
34
+ technical-corrigendum: Cor
35
+ administrative: A
36
+ advisory: Adv
37
+ default_doctype: standard
38
+ published_stages:
39
+ - published
40
+ - cancelled
41
+ - withdrawn
42
+ default_stage: published
43
+ stage_abbreviations:
44
+ working-draft: WD
45
+ committee-draft: CD
46
+ draft-standard: DS
47
+ final-draft: FDS
48
+ published:
49
+ cancelled:
50
+ withdrawn:
51
+ logo_path: ""
52
+
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-cc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.6
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-25 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: metanorma-standoc
14
+ name: metanorma-generic
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.6.0
19
+ version: 1.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.6.0
26
+ version: 1.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: isodoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -210,10 +210,8 @@ files:
210
210
  - lib/asciidoctor/cc/boilerplate.xml
211
211
  - lib/asciidoctor/cc/cc.rng
212
212
  - lib/asciidoctor/cc/converter.rb
213
- - lib/asciidoctor/cc/front.rb
214
213
  - lib/asciidoctor/cc/isodoc.rng
215
214
  - lib/asciidoctor/cc/reqt.rng
216
- - lib/asciidoctor/cc/validate.rb
217
215
  - lib/asciidoctor/cc/validate_section.rb
218
216
  - lib/isodoc/cc/base_convert.rb
219
217
  - lib/isodoc/cc/csd.standard.xsl
@@ -247,6 +245,7 @@ files:
247
245
  - lib/metanorma/cc/processor.rb
248
246
  - lib/metanorma/cc/version.rb
249
247
  - metanorma-cc.gemspec
248
+ - metanorma.yml
250
249
  homepage: https://github.com/metanorma/metanorma-cc
251
250
  licenses:
252
251
  - BSD-2-Clause
@@ -1,67 +0,0 @@
1
- require "asciidoctor"
2
- require "asciidoctor/standoc/converter"
3
- require "fileutils"
4
-
5
- module Asciidoctor
6
- module CC
7
- class Converter < Standoc::Converter
8
- def default_publisher
9
- "CalConnect"
10
- end
11
-
12
- def metadata_committee(node, xml)
13
- return unless node.attr("technical-committee")
14
- xml.editorialgroup do |a|
15
- a.technical_committee node.attr("technical-committee"),
16
- **attr_code(type: node.attr("technical-committee-type"))
17
- i = 2
18
- while node.attr("technical-committee_#{i}") do
19
- a.technical_committee node.attr("technical-committee_#{i}"),
20
- **attr_code(type: node.attr("technical-committee-type_#{i}"))
21
- i += 1
22
- end
23
- end
24
- end
25
-
26
- def metadata_status(node, xml)
27
- status = node.attr("status")
28
- unless status && ::Metanorma::CC::DOCSTATUS.keys.include?(status)
29
- @log.add("Document Attributes", nil, "#{status} is not a legal status")
30
- end
31
- super
32
- end
33
-
34
- def prefix_id(node)
35
- prefix = "CC"
36
- typesuffix = ::Metanorma::CC::DOCSUFFIX[doctype(node)] || ""
37
- prefix += "/#{typesuffix}" unless typesuffix.empty?
38
- status = ::Metanorma::CC::DOCSTATUS[node.attr("status")] || ""
39
- prefix += "/#{status}" unless status.empty?
40
- prefix
41
- end
42
-
43
- def metadata_id(node, xml)
44
- id = node.attr("docnumber") || "???"
45
- prefix = prefix_id(node)
46
- id = "#{prefix} #{id}"
47
- year = node.attr("copyright-year")
48
- id += ":#{year}" if year
49
- xml.docidentifier id, **{type: "CalConnect"}
50
- xml.docnumber node.attr("docnumber")
51
- end
52
-
53
- @log_doctype = false
54
-
55
- def doctype(node)
56
- d = super
57
- unless ::Metanorma::CC::DOCSUFFIX.keys.include?(d) && !@log_doctype
58
- @log.add("Document Attributes", nil,
59
- "#{d} is not a legal document type: reverting to 'standard'")
60
- @log_doctype = true
61
- d = "standard"
62
- end
63
- d
64
- end
65
- end
66
- end
67
- end
@@ -1,29 +0,0 @@
1
- module Asciidoctor
2
- module CC
3
- class Converter < Standoc::Converter
4
- def content_validate(doc)
5
- super
6
- bibdata_validate(doc.root)
7
- end
8
-
9
- def bibdata_validate(doc)
10
- doctype_validate(doc)
11
- stage_validate(doc)
12
- end
13
-
14
- def doctype_validate(xmldoc)
15
- doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
16
- %w(directive guide specification standard report administrative amendment
17
- technical-corrigendum advisory).include?(doctype) or
18
- @log.add("Document Attributes", nil, "#{doctype} is not a recognised document type")
19
- end
20
-
21
- def stage_validate(xmldoc)
22
- stage = xmldoc&.at("//bibdata/status/stage")&.text
23
- %w(proposal working-draft committee-draft draft-standard final-draft
24
- published withdrawn).include?(stage) or
25
- @log.add("Document Attributes", nil, "#{stage} is not a recognised status")
26
- end
27
- end
28
- end
29
- end