metanorma-ieee 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/rake.yml +13 -0
  3. data/.rubocop.yml +10 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +11 -0
  6. data/LICENSE +25 -0
  7. data/README.adoc +30 -0
  8. data/Rakefile +8 -0
  9. data/bin/console +14 -0
  10. data/bin/rspec +17 -0
  11. data/bin/setup +8 -0
  12. data/lib/html2doc/ieee.rb +89 -0
  13. data/lib/isodoc/ieee/base_convert.rb +33 -0
  14. data/lib/isodoc/ieee/html/header.html +146 -0
  15. data/lib/isodoc/ieee/html/html_ieee_intro.html +12 -0
  16. data/lib/isodoc/ieee/html/html_ieee_titlepage.html +44 -0
  17. data/lib/isodoc/ieee/html/htmlstyle.css +1027 -0
  18. data/lib/isodoc/ieee/html/htmlstyle.scss +736 -0
  19. data/lib/isodoc/ieee/html/ieee.css +3603 -0
  20. data/lib/isodoc/ieee/html/ieee.scss +3418 -0
  21. data/lib/isodoc/ieee/html/scripts.html +70 -0
  22. data/lib/isodoc/ieee/html/word_ieee_intro.html +70 -0
  23. data/lib/isodoc/ieee/html/word_ieee_titlepage.html +28 -0
  24. data/lib/isodoc/ieee/html/wordstyle.css +5310 -0
  25. data/lib/isodoc/ieee/html/wordstyle.scss +5026 -0
  26. data/lib/isodoc/ieee/html_convert.rb +52 -0
  27. data/lib/isodoc/ieee/i18n-en.yaml +28 -0
  28. data/lib/isodoc/ieee/i18n.rb +19 -0
  29. data/lib/isodoc/ieee/ieee.amendment.xsl +11177 -0
  30. data/lib/isodoc/ieee/ieee.rb +11 -0
  31. data/lib/isodoc/ieee/ieee.standard.xsl +11177 -0
  32. data/lib/isodoc/ieee/init.rb +28 -0
  33. data/lib/isodoc/ieee/metadata.rb +136 -0
  34. data/lib/isodoc/ieee/pdf_convert.rb +24 -0
  35. data/lib/isodoc/ieee/presentation_terms.rb +181 -0
  36. data/lib/isodoc/ieee/presentation_xml_convert.rb +89 -0
  37. data/lib/isodoc/ieee/word_authority.rb +160 -0
  38. data/lib/isodoc/ieee/word_cleanup.rb +134 -0
  39. data/lib/isodoc/ieee/word_convert.rb +75 -0
  40. data/lib/isodoc/ieee/xref.rb +77 -0
  41. data/lib/isodoc/ieee.rb +11 -0
  42. data/lib/metanorma/ieee/basicdoc.rng +1150 -0
  43. data/lib/metanorma/ieee/biblio.rng +1385 -0
  44. data/lib/metanorma/ieee/boilerplate.xml +298 -0
  45. data/lib/metanorma/ieee/cleanup.rb +160 -0
  46. data/lib/metanorma/ieee/converter.rb +81 -0
  47. data/lib/metanorma/ieee/front.rb +120 -0
  48. data/lib/metanorma/ieee/ieee.rng +97 -0
  49. data/lib/metanorma/ieee/isodoc.rng +2776 -0
  50. data/lib/metanorma/ieee/processor.rb +56 -0
  51. data/lib/metanorma/ieee/reqt.rng +226 -0
  52. data/lib/metanorma/ieee/validate.rb +198 -0
  53. data/lib/metanorma/ieee/validate_section.rb +119 -0
  54. data/lib/metanorma/ieee/validate_style.rb +108 -0
  55. data/lib/metanorma/ieee/version.rb +5 -0
  56. data/lib/metanorma/ieee.rb +11 -0
  57. data/lib/metanorma-ieee.rb +8 -0
  58. data/metanorma-itu.gemspec +41 -0
  59. metadata +284 -0
@@ -0,0 +1,298 @@
1
+ <boilerplate>
2
+ <copyright-statement>
3
+ <clause>
4
+ <p id="copyright" align="left">Copyright © {{ docyear }} by The Institute of Electrical and Electronics Engineers, Inc.<br/>Three Park Avenue<br/>New York, New York 10016-5997, USA</p>
5
+ <p>All rights reserved.</p>
6
+ </clause>
7
+ </copyright-statement>
8
+ <license-statement>
9
+ <clause>
10
+ <p>This document is an unapproved draft of a proposed IEEE Standard. As such, this document is subject to change. USE AT YOUR OWN RISK! IEEE copyright statements SHALL NOT BE REMOVED from draft or approved IEEE standards, or modified in any way. Because this is an unapproved draft, this document must not be utilized for any conformance/compliance purposes. Permission is hereby granted for officers from each IEEE Standards Working Group or Committee to reproduce the draft document developed by that Working Group for purposes of international standardization consideration. IEEE Standards Department must be informed of the submission for consideration prior to any reproduction for international standardization consideration (<link target="mailto:stds-ipr@ieee.org"/>). Prior to adoption of this document, in whole or in part, by another standards development organization, permission must first be obtained from the IEEE Standards Department (<link target="mailto:stds-ipr@ieee.org"/>). When requesting permission, IEEE Standards Department will require a copy of the standard development organization's document highlighting the use of IEEE content. Other entities seeking permission to reproduce this document, in whole or in part, must also obtain permission from the IEEE Standards Department.</p>
11
+ <p align="left">IEEE Standards Department<br/> 445 Hoes Lane<br/> Piscataway, NJ 08854, USA</p>
12
+ </clause>
13
+ </license-statement>
14
+ <legal-statement>
15
+ <clause id="boilerplate-disclaimers">
16
+ <title>Important Notices and Disclaimers Concerning IEEE Standards Documents</title>
17
+
18
+ <p id="_DV_M4">IEEE Standards
19
+ documents are made available for use subject to important notices and legal
20
+ disclaimers. These notices and disclaimers, or a reference to this page (<link target="https://standards.ieee.org/ipr/disclaimers.html"/>),
21
+ appear in all standards and may be found under the heading “Important Notices
22
+ and Disclaimers Concerning IEEE Standards Documents.”</p>
23
+
24
+ <clause>
25
+ <title>Notice
26
+ and Disclaimer of Liability Concerning the Use of IEEE Standards Documents</title>
27
+
28
+ <p>IEEE Standards documents are
29
+ developed within the IEEE Societies and the Standards Coordinating Committees
30
+ of the IEEE Standards Association (IEEE SA) Standards Board. IEEE develops its
31
+ standards through an accredited consensus development process, which brings
32
+ together volunteers representing varied viewpoints and interests to achieve the
33
+ final product. IEEE Standards are documents developed by volunteers with
34
+ scientific, academic, and industry-based expertise in technical working groups.
35
+ Volunteers are not necessarily members of IEEE or IEEE SA, and participate
36
+ without compensation from IEEE. While IEEE administers the process and
37
+ establishes rules to promote fairness in the consensus development process,
38
+ IEEE does not independently evaluate, test, or verify the accuracy of any of
39
+ the information or the soundness of any judgments contained in its standards.</p>
40
+
41
+ <p>IEEE makes no warranties or
42
+ representations concerning its standards, and expressly disclaims all
43
+ warranties, express or implied, concerning this standard, including but not
44
+ limited to the warranties of merchantability, fitness for a particular purpose
45
+ and non-infringement. In addition, IEEE
46
+ does not warrant or represent that the use of the material contained in its
47
+ standards is free from patent infringement. IEEE standards documents are
48
+ supplied “AS IS” and “WITH ALL FAULTS.”</p>
49
+
50
+ <p>Use of an IEEE standard is wholly
51
+ voluntary. The existence of an IEEE Standard does not imply that there are no
52
+ other ways to produce, test, measure, purchase, market, or provide other goods
53
+ and services related to the scope of the IEEE standard. Furthermore, the
54
+ viewpoint expressed at the time a standard is approved and issued is subject to
55
+ change brought about through developments in the state of the art and comments
56
+ received from users of the standard.</p>
57
+
58
+ <p>In publishing and
59
+ making its standards available, IEEE is not suggesting or rendering
60
+ professional or other services for, or on behalf of, any person or entity, nor
61
+ is IEEE undertaking to perform any duty owed by any other person or entity to
62
+ another. Any person utilizing any IEEE Standards document, should rely upon his
63
+ or her own independent judgment in the exercise of reasonable care in any given
64
+ circumstances or, as appropriate, seek the advice of a competent professional
65
+ in determining the appropriateness of a given IEEE standard.</p>
66
+
67
+ <p>IN NO EVENT SHALL IEEE
68
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
69
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO: THE NEED TO PROCURE
70
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
71
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
72
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
73
+ IN ANY WAY OUT OF THE PUBLICATION, USE OF, OR RELIANCE UPON ANY STANDARD, EVEN
74
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE AND REGARDLESS OF WHETHER SUCH
75
+ DAMAGE WAS FORESEEABLE.</p>
76
+
77
+ </clause>
78
+ <clause><title>Translations</title>
79
+
80
+ <p>The IEEE consensus
81
+ development process involves the review of documents in English only. In the
82
+ event that an IEEE standard is translated, only the English version published
83
+ by IEEE is the approved IEEE standard.</p>
84
+ </clause>
85
+
86
+ <clause><title>Official statements</title>
87
+
88
+ <p>A statement, written
89
+ or oral, that is not processed in accordance with the IEEE SA Standards Board
90
+ Operations Manual shall not be considered or inferred to be the official
91
+ position of IEEE or any of its committees and shall not be considered to be,
92
+ nor be relied upon as, a formal position of IEEE. At lectures, symposia,
93
+ seminars, or educational courses, an individual presenting information on IEEE
94
+ standards shall make it clear that the presenter’s views should be considered
95
+ the personal views of that individual rather than the formal position of IEEE,
96
+ IEEE SA, the Standards Committee, or the Working Group.</p>
97
+ </clause>
98
+
99
+ <clause><title>Comments on standards</title>
100
+
101
+ <p>Comments for revision of IEEE
102
+ Standards documents are welcome from any interested party, regardless of membership
103
+ affiliation with IEEE or IEEE SA. However, <strong>IEEE does not provide interpretations, consulting information, or advice pertaining to IEEE Standards documents</strong>.</p>
104
+
105
+ <p>Suggestions for changes in
106
+ documents should be in the form of a proposed change of text, together with
107
+ appropriate supporting comments. Since IEEE standards represent a consensus of
108
+ concerned interests, it is important that any responses to comments and
109
+ questions also receive the concurrence of a balance of interests. For this
110
+ reason, IEEE and the members of its Societies and Standards Coordinating
111
+ Committees are not able to provide an instant response to comments, or
112
+ questions except in those cases where the matter has previously been addressed.
113
+ For the same reason, IEEE does not respond to interpretation requests. Any
114
+ person who would like to participate in evaluating comments or in revisions to
115
+ an IEEE standard is welcome to join the relevant IEEE working group. You can
116
+ indicate interest in a working group using the Interests tab in the Manage
117
+ Profile &#x26; Interests area of the <link target="https://development.standards.ieee.org/myproject-web/public/view.html#landing">IEEE
118
+ SA myProject system</link>.<fn><p>Available at: <link target="https://development.standards.ieee.org/myproject-web/public/view.html#landing"/>.</p></fn>
119
+ An IEEE Account is needed to access the application.</p>
120
+
121
+ <p>Comments on standards should be submitted using the <link target="https://standards.ieee.org/content/ieee-standards/en/about/contact/index.html">Contact Us</link> form.<fn><p>Available at: <link target="https://standards.ieee.org/content/ieee-standards/en/about/contact/index.html"/>.</p></fn></p>
122
+ </clause>
123
+
124
+ <clause><title>Laws and regulations</title>
125
+
126
+ <p>Users of IEEE
127
+ Standards documents should consult all applicable laws and regulations.
128
+ Compliance with the provisions of any IEEE Standards document does not
129
+ constitute compliance to any applicable regulatory requirements. Implementers
130
+ of the standard are responsible for observing or referring to the applicable
131
+ regulatory requirements. IEEE does not, by the publication of its standards,
132
+ intend to urge action that is not in compliance with applicable laws, and these
133
+ documents may not be construed as doing so.</p>
134
+ </clause>
135
+
136
+ <clause><title>Data privacy</title>
137
+
138
+ <p>Users of IEEE Standards documents
139
+ should evaluate the standards for considerations of data privacy and data
140
+ ownership in the context of assessing and using the standards in compliance
141
+ with applicable laws and regulations.</p>
142
+ </clause>
143
+
144
+ <clause><title>Copyrights</title>
145
+
146
+ <p>IEEE draft and
147
+ approved standards are copyrighted by IEEE under US and international copyright
148
+ laws. They are made available by IEEE and are adopted for a wide variety of
149
+ both public and private uses. These include both use, by reference, in laws and
150
+ regulations, and use in private self-regulation, standardization, and the
151
+ promotion of engineering practices and methods. By making these documents
152
+ available for use and adoption by public authorities and private users, IEEE
153
+ does not waive any rights in copyright to the documents.</p>
154
+ </clause>
155
+
156
+ <clause><title>Photocopies</title>
157
+
158
+ <p>Subject to payment of
159
+ the appropriate licensing fees, IEEE will grant users a limited, non-exclusive
160
+ license to photocopy portions of any individual standard for company or
161
+ organizational internal use or individual, non-commercial use only. To arrange
162
+ for payment of licensing fees, please contact Copyright Clearance Center,
163
+ Customer Service, 222 Rosewood Drive, Danvers, MA 01923 USA; +1 978 750 8400;
164
+ https://www.copyright.com/. Permission to photocopy portions of any individual
165
+ standard for educational classroom use can also be obtained through the
166
+ Copyright Clearance Center.</p>
167
+ </clause>
168
+
169
+ <clause><title>Updating of IEEE Standards documents</title>
170
+
171
+ <p>Users
172
+ of IEEE Standards documents should be aware that these documents may be
173
+ superseded at any time by the issuance of new editions or may be amended from
174
+ time to time through the issuance of amendments, corrigenda, or errata. An
175
+ official IEEE document at any point in time consists of the current edition of
176
+ the document together with any amendments, corrigenda, or errata then in
177
+ effect.</p>
178
+
179
+ <p>Every
180
+ IEEE standard is subjected to review at least every 10 years. When a document
181
+ is more than 10 years old and has not undergone a revision process, it is
182
+ reasonable to conclude that its contents, although still of some value, do not
183
+ wholly reflect the present state of the art. Users are cautioned to check to
184
+ determine that they have the latest edition of any IEEE standard.</p>
185
+
186
+ <p>In
187
+ order to determine whether a given document is the current edition and whether
188
+ it has been amended through the issuance of amendments, corrigenda, or errata,
189
+ visit <link target="https://ieeexplore.ieee.org/browse/standards/collection/ieee/">IEEE
190
+ Xplore</link> or <link target="https://standards.ieee.org/content/ieee-standards/en/about/contact/index.html">contact IEEE</link>.<fn><p>Available at <link target="https://ieeexplore.ieee.org/browse/standards/collection/ieee"/>.</p></fn>
191
+ For more information about the IEEE SA or IEEE’s standards development process,
192
+ visit the IEEE SA Website.</p>
193
+ </clause>
194
+
195
+ <clause>
196
+ <title>Errata</title>
197
+
198
+ <p>Errata, if any, for all IEEE standards can be accessed on the <link target="https://standards.ieee.org/standard/index.html">IEEE SA Website</link>.<fn><p>Available at: <link target="https://standards.ieee.org/standard/index.html"/>.</p></fn> Search for standard number and year of approval to access the web page of the published standard. Errata links are located under the Additional Resources Details section. Errata are also available in <link target="https://ieeexplore.ieee.org/browse/standards/collection/ieee/">IEEE Xplore</link>. Users are encouraged to periodically check for errata.</p>
199
+ </clause>
200
+
201
+ <clause><title>Patents</title>
202
+
203
+ <p>IEEE Standards are developed in compliance with the <link target="https://standards.ieee.org/about/sasb/patcom/materials.html">IEEE SA Patent Policy</link>.<fn><p>Available at: <link target="https://standards.ieee.org/about/sasb/patcom/materials.html"/>.</p></fn></p>
204
+ <p>Attention is called to
205
+ the possibility that implementation of this standard may require use of subject
206
+ matter covered by patent rights. By publication of this standard, no position
207
+ is taken by the IEEE with respect to the existence or validity of any patent
208
+ rights in connection therewith. If a patent holder or patent applicant has
209
+ filed a statement of assurance via an Accepted Letter of Assurance, then the
210
+ statement is listed on the IEEE SA Website at <link target="https://standards.ieee.org/about/sasb/patcom/patents.html"/>. Letters of Assurance may
211
+ indicate whether the Submitter is willing or unwilling to grant licenses under
212
+ patent rights without compensation or under reasonable rates, with reasonable
213
+ terms and conditions that are demonstrably free of any unfair discrimination to
214
+ applicants desiring to obtain such licenses.</p>
215
+
216
+ <p>Essential Patent
217
+ Claims may exist for which a Letter of Assurance has not been received. The
218
+ IEEE is not responsible for identifying Essential Patent Claims for which a
219
+ license may be required, for conducting inquiries into the legal validity or
220
+ scope of Patents Claims, or determining whether any licensing terms or
221
+ conditions provided in connection with submission of a Letter of Assurance, if
222
+ any, or in any licensing agreements are reasonable or non-discriminatory. Users
223
+ of this standard are expressly advised that determination of the validity of
224
+ any patent rights, and the risk of infringement of such rights, is entirely
225
+ their own responsibility. Further information may be obtained from the IEEE
226
+ Standards Association.</p>
227
+ </clause>
228
+
229
+ <clause><title>IMPORTANT NOTICE</title>
230
+
231
+ <p>IEEE Standards do not
232
+ guarantee or ensure safety, security, health, or environmental protection, or
233
+ ensure against interference with or from other devices or networks. IEEE
234
+ Standards development activities consider research and information presented to
235
+ the standards development group in developing any safety recommendations. Other
236
+ information about safety practices, changes in technology or technology implementation,
237
+ or impact by peripheral systems also may be pertinent to safety considerations
238
+ during implementation of the standard. Implementers and users of IEEE Standards
239
+ documents are responsible for determining and complying with all appropriate
240
+ safety, security, environmental, health, and interference protection practices
241
+ and all applicable laws and regulations.</p>
242
+ </clause>
243
+ </clause>
244
+ <clause id="boilerplate-participants">
245
+ <title>Participants</title>
246
+ <p>At the time this draft {{ doctype }} was completed, the {{ working_group }} Working Group had the following membership:</p>
247
+ <p align="center" type="officeholder"><strong>{{ wg_members["chair"] }}</strong>, <em>Chair</em></p>
248
+ <p align="center" type="officeholder"><strong>{{ wg_members["vice-chair"] }}</strong>, <em>Vice Chair</em></p>
249
+ {% if wg_members["secretary"] %}<p align="center" type="officeholder"><strong>{{ wg_members["secretary"] }}</strong>, <em>Secretary</em></p>{% endif %}
250
+ {% for m in wg_members["members"] %}
251
+ <p type="officemember">{{ m }}</p>
252
+ {% endfor %}
253
+ <p>The following members of the {{ balloting_group }} Standards Association balloting group voted on this {{ doctype }}. Balloters may have voted for approval, disapproval, or abstention.</p>
254
+ {% for m in balloting_group_members %}
255
+ <p type="officemember">{{ m }}</p>
256
+ {% endfor %}
257
+ <p>When the IEEE SA Standards Board approved this {{ doctype }} on {{ confirmed_date }}, it had the following membership:</p>
258
+ <p align="center" type="officeholder"><strong>{{ std_board["chair"] }}</strong>, <em>Chair</em></p>
259
+ <p align="center" type="officeholder"><strong>{{ std_board["vice-chair"] }}</strong>, <em>Vice Chair</em></p>
260
+ <p align="center" type="officeholder"><strong>{{ std_board["past-chair"] }}</strong>, <em>Past Chair</em></p>
261
+ <p align="center" type="officeholder"><strong>{{ std_board["secretary"] }}</strong>, <em>Secretary</em></p>
262
+ {% for m in std_board["members"] %}
263
+ <p type="officemember">{{ m }}</p>
264
+ {% endfor %}
265
+ <p type="emeritus_sign">*Member Emeritus</p>
266
+ </clause>
267
+ </legal-statement>
268
+ <feedback-statement>
269
+ <clause>
270
+ <p align="left">The Institute of Electrical and Electronics Engineers, Inc.<br/> 3 Park Avenue, New York, NY 10016-5997, USA</p>
271
+ </clause>
272
+
273
+ <clause>
274
+ <p>Copyright © {{ docyear }} by The Institute of Electrical and Electronics Engineers, Inc.</p>
275
+ <p>All rights reserved. Published {{ issued_date }}. Printed in the United States of America.</p>
276
+ </clause>
277
+
278
+ <clause>
279
+ <p>IEEE is a registered trademark in the U.S. Patent &#x26; Trademark Office, owned by The Institute of Electrical and Electronics Engineers, Incorporated.</p>
280
+ </clause>
281
+
282
+ <clause>
283
+ <table unnumbered="true">
284
+ <tbody>
285
+ <tr><td>PDF:</td> <td>ISBN {{ isbn_pdf }}</td> <td>{{ stdid_pdf}}</td></tr>
286
+ <tr><td>Print:</td> <td>ISBN {{ isbn_print}}</td> <td>{{ stdid_print}}</td></tr>
287
+ </tbody>
288
+ </table>
289
+ </clause>
290
+
291
+ <clause>
292
+ <p>IEEE prohibits discrimination, harassment, and bullying.</p>
293
+ <p>For more information, visit <link target="https://www.ieee.org/about/corporate/governance/p9-26.html"/>.</p>
294
+ <p>No part of this publication may be reproduced in any form, in an electronic retrieval system or otherwise, without the prior written permission of the publisher.</p>
295
+ </clause>
296
+ </feedback-statement>
297
+ </boilerplate>
298
+
@@ -0,0 +1,160 @@
1
+ module Metanorma
2
+ module IEEE
3
+ class Converter < Standoc::Converter
4
+ BIBLIO =
5
+ "//bibliography/references[@normative = 'false'][not(@hidden)] | "\
6
+ "//bibliography/clause[.//references[@normative = 'false']] | "\
7
+ "//annex//references[@normative = 'false'][not(@hidden)]".freeze
8
+
9
+ def boilerplate_cleanup(xmldoc)
10
+ f = xmldoc.at(BIBLIO) and biblio_preface(f)
11
+ super
12
+ end
13
+
14
+ def biblio_preface(ref)
15
+ if ref.at("./note[@type = 'boilerplate']")
16
+ unwrap_boilerplate_clauses(ref, ".")
17
+ else
18
+ pref = @i18n.biblio_pref
19
+ ref.at("./title").next = "<p>#{pref}</p>"
20
+ end
21
+ end
22
+
23
+ def initial_boilerplate(xml, isodoc)
24
+ intro_boilerplate(xml, isodoc)
25
+ super
26
+ end
27
+
28
+ def intro_boilerplate(xml, isodoc)
29
+ return unless intro = xml.at("//introduction/title")
30
+
31
+ template = <<~ADM
32
+ This introduction is not part of P{{ docnumeric }}{% if draft %}/D{{ draft }}{% endif %}, {{ doctitle }}
33
+ ADM
34
+ adm = isodoc.populate_template(template)
35
+ intro.next = "<admonition>#{adm}</admonition>"
36
+ end
37
+
38
+ def obligations_cleanup_norm(xml)
39
+ super
40
+ xml.xpath("//sections/clause").each do |r|
41
+ r["obligation"] = "normative"
42
+ end
43
+ end
44
+
45
+ def sections_cleanup(xml)
46
+ super
47
+ overview_cleanup(xml)
48
+ end
49
+
50
+ def overview_cleanup(xml)
51
+ %w(scope purpose word-usage).each do |x|
52
+ (xml.xpath("//clause[@type = '#{x}']") -
53
+ xml.xpath("//sections/clause[1][@type = 'overview']"\
54
+ "//clause[@type = '#{x}']"))
55
+ .each { |c| c.delete("type") }
56
+ end
57
+ (xml.xpath("//clause[@type = 'overview']") -
58
+ xml.xpath("//sections/clause[1]"))
59
+ .each { |c| c.delete("type") }
60
+ end
61
+
62
+ def note_cleanup(xmldoc)
63
+ super
64
+ n = xmldoc.at("//preface//note[not(@type = 'boilerplate')]"\
65
+ "[not(./ancestor::abstract)] | "\
66
+ "//sections//note[not(@type = 'boilerplate')] | "\
67
+ "//annex//note[not(@type = 'boilerplate')]") or
68
+ return
69
+ ins = n.at("./p[last()]")
70
+ ins << "<fn><p>#{@i18n.note_inform_fn}</p></fn>"
71
+ end
72
+
73
+ def sort_biblio(bib)
74
+ bib.sort do |a, b|
75
+ sort_biblio_key(a) <=> sort_biblio_key(b)
76
+ end
77
+ end
78
+
79
+ OTHERIDS = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or "\
80
+ "@type = 'ISBN'".freeze
81
+
82
+ def sort_biblio_key(bib)
83
+ id = bib.at("./docidentifier[not(#{OTHERIDS})]")
84
+ title = bib.at("./title[@type = 'main']") ||
85
+ bib.at("./title") || bib.at("./formattedref")
86
+ "#{id&.text || 'ZZZZZ'} :: #{title&.text}"
87
+ end
88
+
89
+ def normref_cleanup(xmldoc)
90
+ super
91
+ normref_reorder(xmldoc)
92
+ end
93
+
94
+ def normref_reorder(xmldoc)
95
+ xmldoc.xpath("//references[@normative = 'true']").each do |r|
96
+ biblio_reorder1(r)
97
+ end
98
+ end
99
+
100
+ # end of citeas generation
101
+ def quotesource_cleanup(xmldoc)
102
+ super
103
+ trademark_ieee_erefs(xmldoc)
104
+ end
105
+
106
+ # Style manual 12.3.5
107
+ def trademark_ieee_erefs(xmldoc)
108
+ ieee = xmldoc.xpath("//references/bibitem")
109
+ .each_with_object({}) do |b, m|
110
+ n = b.at("./contributor[role/@type = 'publisher']/organization/name")
111
+ n&.text == "Institute of Electrical and Electronics Engineers" and
112
+ m[b["id"]] = true
113
+ end
114
+ trademark_ieee_erefs1(xmldoc, "//preface//eref", ieee)
115
+ trademark_ieee_erefs1(xmldoc, "//sections//eref | //annex//eref", ieee)
116
+ end
117
+
118
+ def trademark_ieee_erefs1(xmldoc, path, ieee)
119
+ xmldoc.xpath(path).each_with_object({}) do |e, m|
120
+ ieee[e["bibitemid"]] or next
121
+ m[e["bibitemid"]] or e["citeas"] += "\u2122"
122
+ m[e["bibitemid"]] = true
123
+ end
124
+ end
125
+
126
+ def termdef_cleanup(xmldoc)
127
+ term_reorder(xmldoc)
128
+ super
129
+ end
130
+
131
+ def term_reorder(xmldoc)
132
+ xmldoc.xpath("//terms").each do |t|
133
+ term_reorder1(t)
134
+ end
135
+ end
136
+
137
+ def term_reorder1(terms)
138
+ ins = terms.at("./term")&.previous_element or return
139
+ coll = terms.xpath("./term")
140
+ ret = sort_terms(coll)
141
+ coll.each(&:remove)
142
+ ret.reverse.each { |t| ins.next = t }
143
+ end
144
+
145
+ def sort_terms(terms)
146
+ terms.sort do |a, b|
147
+ sort_terms_key(a) <=> sort_terms_key(b)
148
+ end
149
+ end
150
+
151
+ def sort_terms_key(term)
152
+ d = term.at("./preferred/expression/name | "\
153
+ "./preferred/letter-designation/name | "\
154
+ "./preferred/graphical-symbol/figure/name | "\
155
+ "./preferred/graphical-symbol/figure/@id")
156
+ d.text.downcase
157
+ end
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,81 @@
1
+ require "asciidoctor"
2
+ require "metanorma/standoc/converter"
3
+ require "fileutils"
4
+ require "metanorma-utils"
5
+ require_relative "front"
6
+ require_relative "cleanup"
7
+ require_relative "validate"
8
+
9
+ module Metanorma
10
+ module IEEE
11
+ class Converter < Standoc::Converter
12
+ XML_ROOT_TAG = "ieee-standard".freeze
13
+ XML_NAMESPACE = "https://www.metanorma.org/ns/ieee".freeze
14
+
15
+ register_for "ieee"
16
+
17
+ def init(node)
18
+ super
19
+ @hierarchical_assets = node.attr("hierarchical-object-numbering")
20
+ end
21
+
22
+ def sectiontype_streamline(ret)
23
+ case ret
24
+ when "definitions", "definitions, acronyms and abbreviations"
25
+ "terms and definitions"
26
+ when "acronyms and abbreviations" then "symbols and abbreviated terms"
27
+ else super
28
+ end
29
+ end
30
+
31
+ def clause_parse(attrs, xml, node)
32
+ case node.title
33
+ when "Purpose" then attrs[:type] = "purpose"
34
+ when "Overview" then attrs[:type] = "overview"
35
+ when "Scope" then attrs[:type] = "scope"
36
+ when "Word Usage" then attrs[:type] = "word-usage"
37
+ end
38
+ super
39
+ end
40
+
41
+ def outputs(node, ret)
42
+ File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
43
+ presentation_xml_converter(node).convert("#{@filename}.xml")
44
+ html_converter(node).convert("#{@filename}.presentation.xml",
45
+ nil, false, "#{@filename}.html")
46
+ doc_converter(node).convert("#{@filename}.presentation.xml",
47
+ nil, false, "#{@filename}.doc")
48
+ node.attr("no-pdf") or
49
+ pdf_converter(node)&.convert("#{@filename}.presentation.xml",
50
+ nil, false, "#{@filename}.pdf")
51
+ end
52
+
53
+ def html_extract_attributes(node)
54
+ super.merge(hierarchical_assets:
55
+ node.attr("hierarchical-object-numbering"))
56
+ end
57
+
58
+ def doc_extract_attributes(node)
59
+ super.merge(hierarchical_assets:
60
+ node.attr("hierarchical-object-numbering"),
61
+ ulstyle: "l11", olstyle: "l16")
62
+ end
63
+
64
+ def presentation_xml_converter(node)
65
+ IsoDoc::IEEE::PresentationXMLConvert.new(html_extract_attributes(node))
66
+ end
67
+
68
+ def html_converter(node)
69
+ IsoDoc::IEEE::HtmlConvert.new(html_extract_attributes(node))
70
+ end
71
+
72
+ def pdf_converter(node)
73
+ IsoDoc::IEEE::PdfConvert.new(pdf_extract_attributes(node))
74
+ end
75
+
76
+ def doc_converter(node)
77
+ IsoDoc::IEEE::WordConvert.new(doc_extract_attributes(node))
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,120 @@
1
+ module Metanorma
2
+ module IEEE
3
+ class Converter < Standoc::Converter
4
+ def metadata_committee(node, xml)
5
+ return unless node.attr("committee") || node.attr("society")
6
+
7
+ xml.editorialgroup do |a|
8
+ committee_component("society", node, a)
9
+ committee_component("balloting-group", node, a)
10
+ committee_component("working-group", node, a)
11
+ committee_component("committee", node, a)
12
+ end
13
+ end
14
+
15
+ def metadata_other_id(node, xml)
16
+ a = node.attr("isbn-pdf") and
17
+ xml.docidentifier a, type: "ISBN", scope: "PDF"
18
+ a = node.attr("isbn-print") and
19
+ xml.docidentifier a, type: "ISBN", scope: "print"
20
+ end
21
+
22
+ def metadata_id(node, xml)
23
+ id = node.attr("docnumber") || ""
24
+ xml.docidentifier id, type: "IEEE"
25
+ id = node.attr("stdid-pdf") and
26
+ xml.docidentifier id, type: "IEEE", scope: "PDF"
27
+ id = node.attr("stdid-print") and
28
+ xml.docidentifier id, type: "IEEE", scope: "print"
29
+ xml.docnumber node.attr("docnumber")
30
+ end
31
+
32
+ def metadata_author(node, xml)
33
+ super
34
+ wg_members(node, xml)
35
+ bg_members(node, xml)
36
+ std_board_members(node, xml)
37
+ end
38
+
39
+ def metadata_editor(name, role, xml)
40
+ xml.contributor do |c|
41
+ c.role role, **{ type: "editor" }
42
+ c.person do |p|
43
+ p.name do |n|
44
+ n.completename name
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ def metadata_multi_editors(names, role, xml)
51
+ csv_split(names).each do |n|
52
+ metadata_editor(n, role, xml)
53
+ end
54
+ end
55
+
56
+ def wg_members(node, xml)
57
+ a = node.attr("wg_chair") and
58
+ metadata_editor(a, "Working Group Chair", xml)
59
+ a = node.attr("wg_vicechair") and
60
+ metadata_editor(a, "Working Group Vice-Chair", xml)
61
+ a = node.attr("wg_secretary") and
62
+ metadata_editor(a, "Working Group Secretary", xml)
63
+ a = node.attr("wg_members") and
64
+ metadata_multi_editors(a, "Working Group Member", xml)
65
+ end
66
+
67
+ def bg_members(node, xml)
68
+ a = node.attr("balloting_group_members") and
69
+ metadata_multi_editors(a, "Balloting Group Member", xml)
70
+ end
71
+
72
+ def std_board_members(node, xml)
73
+ a = node.attr("std_board_chair") and
74
+ metadata_editor(a, "Standards Board Chair", xml)
75
+ a = node.attr("std_board_vicechair") and
76
+ metadata_editor(a, "Standards Board Vice-Chair", xml)
77
+ a = node.attr("std_board_pastchair") and
78
+ metadata_editor(a, "Standards Board Past Chair", xml)
79
+ a = node.attr("std_board_secretary") and
80
+ metadata_editor(a, "Standards Board Secretary", xml)
81
+ a = node.attr("balloting_group_members") and
82
+ metadata_multi_editors(a, "Standards Board Member", xml)
83
+ end
84
+
85
+ def metadata_publisher(node, xml)
86
+ publishers = node.attr("publisher") || "IEEE"
87
+ csv_split(publishers).each do |p|
88
+ xml.contributor do |c|
89
+ c.role **{ type: "publisher" }
90
+ c.organization do |a|
91
+ organization(a, p, true, node, !node.attr("publisher"))
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ def metadata_copyright(node, xml)
98
+ publishers = node.attr("copyright-holder") || node.attr("publisher") ||
99
+ "IEEE"
100
+ csv_split(publishers).each do |p|
101
+ xml.copyright do |c|
102
+ c.from (node.attr("copyright-year") || Date.today.year)
103
+ c.owner do |owner|
104
+ owner.organization do |o|
105
+ organization(
106
+ o, p, true, node,
107
+ !(node.attr("copyright-holder") || node.attr("publisher"))
108
+ )
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+
115
+ def org_abbrev
116
+ { "Institute of Electrical and Electronic Engineers" => "IEEE" }
117
+ end
118
+ end
119
+ end
120
+ end