Skip to content

Commit

Permalink
feat: Add editorial stream
Browse files Browse the repository at this point in the history
Add editorial stream as per #896 and Section 6.3 of RFC 9280.
  • Loading branch information
kesara committed Jan 18, 2023
1 parent ad2e035 commit cfa629f
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 26 deletions.
54 changes: 54 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import xml2rfc
import xml2rfc.utils

from xml2rfc.boilerplate_rfc_7841 import boilerplate_rfc_status_of_memo
from xml2rfc.walkpdf import xmldoc
from xml2rfc.writers.base import default_options

Expand Down Expand Up @@ -582,5 +583,58 @@ def test_set_font_family(self):
self.assertEqual(result, expected_svg)


class PrepToolWriterTest(unittest.TestCase):
'''PrepToolWriter tests'''

def setUp(self):
xml2rfc.log.quiet = True
path = 'tests/input/elements.xml'
self.parser = xml2rfc.XmlRfcParser(path,
quiet=True,
options=default_options,
**options_for_xmlrfcparser)
self.xmlrfc = self.parser.parse()
self.writer = xml2rfc.PrepToolWriter(self.xmlrfc, quiet=True)

def test_rfc_check_attribute_values_editorial(self):
rfc = lxml.etree.fromstring('''
<rfc
submissionType="editorial"
category="info">
</rfc>''')
self.writer.root = rfc

self.writer.check_attribute_values(rfc, None)
self.assertEqual(len(self.writer.errors), 0)

def test_boilerplate_insert_status_of_memo_editorial(self):
rfc = lxml.etree.fromstring('''
<rfc
number="9280"
ipr="trust200902"
submissionType="editorial"
category="info">
</rfc>''')
self.writer.options.rfc = True
self.writer.root = rfc
self.writer.rfcnumber = 9280

self.writer.boilerplate_insert_status_of_memo(rfc, rfc)
self.assertEqual(len(self.writer.errors), 0)
self.assertEqual(len(rfc.xpath('./section/name[text()="Status of This Memo"]')), 1)
paras = rfc.xpath('./section/t')
boilerplate_text = boilerplate_rfc_status_of_memo['editorial']['info']['n/a']
self.assertEqual(len(paras), len(boilerplate_text))
index = 0
for boilerplate in boilerplate_text[-1]:
for line in boilerplate.split('\n')[1:-1]:
self.assertIn(line.strip(), paras[index].text)
index += 1

# test eref element
target = 'https://www.rfc-editor.org/info/rfc9280'
self.assertEqual(target, rfc.xpath('./section/t/eref')[0].get('target'))


if __name__ == '__main__':
unittest.main()
14 changes: 8 additions & 6 deletions tests/valid/docfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -2540,7 +2540,7 @@ <h4 id="name-submissiontype-attribute">
</h4>
<span class="break"></span><dl class="dlCompact dlParallel" id="section-2.49.12-1">
<dt id="section-2.49.12-1.1">Possible values:</dt>
<dd style="margin-left: 1.5em" id="section-2.49.12-1.2">( "IETF" | "IAB" | "IRTF" | "independent" )<a href="#section-2.49.12-1.2" class="pilcrow"></a>
<dd style="margin-left: 1.5em" id="section-2.49.12-1.2">( "IETF" | "IAB" | "IRTF" | "independent" | "editorial" )<a href="#section-2.49.12-1.2" class="pilcrow"></a>
</dd>
<dd class="break"></dd>
<dt id="section-2.49.12-1.3">Default value:</dt>
Expand Down Expand Up @@ -2778,7 +2778,7 @@ <h4 id="name-stream-attribute">
</h4>
<span class="break"></span><dl class="dlCompact dlParallel" id="section-2.51.5-1">
<dt id="section-2.51.5-1.1">Possible values:</dt>
<dd style="margin-left: 1.5em" id="section-2.51.5-1.2">( "IETF" | "IAB" | "IRTF" | "independent" )<a href="#section-2.51.5-1.2" class="pilcrow"></a>
<dd style="margin-left: 1.5em" id="section-2.51.5-1.2">( "IETF" | "IAB" | "IRTF" | "independent" | "editorial" )<a href="#section-2.51.5-1.2" class="pilcrow"></a>
</dd>
<dd class="break"></dd>
</dl>
Expand Down Expand Up @@ -2925,7 +2925,7 @@ <h3 id="name-stream-new">
<p id="section-2.54-2">This element can be a child element of &lt;<a href="#element-reference" class="internal xref">reference</a>&gt;.<a href="#section-2.54-2" class="pilcrow"></a></p>
<span class="break"></span><dl class="dlParallel" id="section-2.54-3">
<dt id="section-2.54-3.1">Content schema:</dt>
<dd style="margin-left: 1.5em" id="section-2.54-3.2"> ( "IETF" | "IAB" | "IRTF" | "independent" )?<a href="#section-2.54-3.2" class="pilcrow"></a>
<dd style="margin-left: 1.5em" id="section-2.54-3.2"> ( "IETF" | "IAB" | "IRTF" | "independent" | "editorial" )?<a href="#section-2.54-3.2" class="pilcrow"></a>
</dd>
<dd class="break"></dd>
</dl>
Expand Down Expand Up @@ -4340,7 +4340,7 @@ <h2 id="name-relax-ng-schema">
attribute iprExtract { xsd:IDREF }?,
[ a:defaultValue = "IETF" ]
attribute submissionType {
"IETF" | "IAB" | "IRTF" | "independent"
"IETF" | "IAB" | "IRTF" | "independent" | "editorial"
}?,
attribute docName { text }?,
[ a:defaultValue = "false" ]
Expand Down Expand Up @@ -5386,7 +5386,7 @@ <h2 id="name-relax-ng-schema">

stream =
element stream {
( "IETF" | "IAB" | "IRTF" | "independent" )?
( "IETF" | "IAB" | "IRTF" | "independent" | "editorial" )?
}

referencegroup =
Expand All @@ -5408,7 +5408,9 @@ <h2 id="name-relax-ng-schema">
attribute asciiName { text }?,
attribute asciiValue { text }?,
attribute status { text }?,
attribute stream { "IETF" | "IAB" | "IRTF" | "independent" }?,
attribute stream {
"IETF" | "IAB" | "IRTF" | "independent" | "editorial"
}?,
empty
}

Expand Down
17 changes: 11 additions & 6 deletions tests/valid/manpage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,8 @@ Table of Contents

2.49.12. "submissionType" Attribute

Possible values: ( "IETF" | "IAB" | "IRTF" | "independent" )
Possible values: ( "IETF" | "IAB" | "IRTF" | "independent" |
"editorial" )
Default value: "IETF"

The document stream, as described in [RFC7841]. (The RFC Series
Expand Down Expand Up @@ -1648,7 +1649,8 @@ Table of Contents

2.51.5. "stream" Attribute

Possible values: ( "IETF" | "IAB" | "IRTF" | "independent" )
Possible values: ( "IETF" | "IAB" | "IRTF" | "independent" |
"editorial" )

Deprecated. Use the <stream (Section 2.54)> element instead.

Expand Down Expand Up @@ -1765,7 +1767,8 @@ Table of Contents

This element can be a child element of <reference>.

Content schema: ( "IETF" | "IAB" | "IRTF" | "independent" )?
Content schema: ( "IETF" | "IAB" | "IRTF" | "independent" |
"editorial" )?

2.55. <street>

Expand Down Expand Up @@ -2753,7 +2756,7 @@ Appendix A. RELAX NG Schema
attribute iprExtract { xsd:IDREF }?,
[ a:defaultValue = "IETF" ]
attribute submissionType {
"IETF" | "IAB" | "IRTF" | "independent"
"IETF" | "IAB" | "IRTF" | "independent" | "editorial"
}?,
attribute docName { text }?,
[ a:defaultValue = "false" ]
Expand Down Expand Up @@ -3799,7 +3802,7 @@ Appendix A. RELAX NG Schema

stream =
element stream {
( "IETF" | "IAB" | "IRTF" | "independent" )?
( "IETF" | "IAB" | "IRTF" | "independent" | "editorial" )?
}

referencegroup =
Expand All @@ -3821,7 +3824,9 @@ Appendix A. RELAX NG Schema
attribute asciiName { text }?,
attribute asciiValue { text }?,
attribute status { text }?,
attribute stream { "IETF" | "IAB" | "IRTF" | "independent" }?,
attribute stream {
"IETF" | "IAB" | "IRTF" | "independent" | "editorial"
}?,
empty
}

Expand Down
23 changes: 23 additions & 0 deletions xml2rfc/boilerplate_rfc_7841.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,27 @@
],
},
},
'editorial': {
'info': {
'n/a' : [ """<t>
This document is not an Internet Standards Track specification; it is
published for informational purposes.
</t>""",

"""<t>
This document is a product of the RFC Series Policy Definition
Process. It represents the consensus of the RFC Series Working
Group approved by the RFC Series Approval Board. Such documents
are not candidates for any level of Internet Standard; see
Section 2 of RFC 7841.
</t>""",

"""<t>
Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
<eref target="{scheme}://www.rfc-editor.org/info/rfc{rfc_number}" />.
</t>""",
],
},
},
}
6 changes: 4 additions & 2 deletions xml2rfc/data/reference.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@

stream =
element stream {
( "IETF" | "IAB" | "IRTF" | "independent" )?
( "IETF" | "IAB" | "IRTF" | "independent" | "editorial" )?
}


Expand All @@ -898,7 +898,9 @@
attribute asciiName { text }?,
attribute asciiValue { text }?,
attribute status { text }?,
attribute stream { "IETF" | "IAB" | "IRTF" | "independent" }?,
attribute stream {
"IETF" | "IAB" | "IRTF" | "independent" | "editorial"
}?,
empty
}

Expand Down
2 changes: 2 additions & 0 deletions xml2rfc/data/reference.rng
Original file line number Diff line number Diff line change
Expand Up @@ -2026,6 +2026,7 @@
<value>IAB</value>
<value>IRTF</value>
<value>independent</value>
<value>editorial</value>
</choice>
</optional>
</element>
Expand Down Expand Up @@ -2056,6 +2057,7 @@
<value>IAB</value>
<value>IRTF</value>
<value>independent</value>
<value>editorial</value>
</choice>
</attribute>
</optional>
Expand Down
2 changes: 2 additions & 0 deletions xml2rfc/data/referencegroup.rng
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,7 @@
<value>IAB</value>
<value>IRTF</value>
<value>independent</value>
<value>editorial</value>
</choice>
</optional>
</element>
Expand Down Expand Up @@ -2078,6 +2079,7 @@
<value>IAB</value>
<value>IRTF</value>
<value>independent</value>
<value>editorial</value>
</choice>
</attribute>
</optional>
Expand Down
8 changes: 5 additions & 3 deletions xml2rfc/data/v3.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
attribute iprExtract { xsd:IDREF }?,
[ a:defaultValue = "IETF" ]
attribute submissionType {
"IETF" | "IAB" | "IRTF" | "independent"
"IETF" | "IAB" | "IRTF" | "independent" | "editorial"
}?,
attribute docName { text }?,
[ a:defaultValue = "false" ]
Expand Down Expand Up @@ -1066,7 +1066,7 @@

stream =
element stream {
( "IETF" | "IAB" | "IRTF" | "independent" )?
( "IETF" | "IAB" | "IRTF" | "independent" | "editorial" )?
}

referencegroup =
Expand All @@ -1088,7 +1088,9 @@
attribute asciiName { text }?,
attribute asciiValue { text }?,
attribute status { text }?,
attribute stream { "IETF" | "IAB" | "IRTF" | "independent" }?,
attribute stream {
"IETF" | "IAB" | "IRTF" | "independent" | "editorial"
}?,
empty
}

Expand Down
3 changes: 3 additions & 0 deletions xml2rfc/data/v3.rng
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<value>IAB</value>
<value>IRTF</value>
<value>independent</value>
<value>editorial</value>
</choice>
</attribute>
</optional>
Expand Down Expand Up @@ -2383,6 +2384,7 @@
<value>IAB</value>
<value>IRTF</value>
<value>independent</value>
<value>editorial</value>
</choice>
</optional>
</element>
Expand Down Expand Up @@ -2435,6 +2437,7 @@
<value>IAB</value>
<value>IRTF</value>
<value>independent</value>
<value>editorial</value>
</choice>
</attribute>
</optional>
Expand Down
1 change: 1 addition & 0 deletions xml2rfc/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
'IAB': 'Internet Architecture Board (IAB)',
'IRTF': 'Internet Research Task Force (IRTF)',
'independent': 'Independent Submission',
'editorial': 'Editorial Stream',
}
18 changes: 9 additions & 9 deletions xml2rfc/writers/preptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def prep(self):
'./front;insert_boilerplate()', # 5.4.2. <boilerplate> Insertion
'./front;insert_toc()',
'.;check_series_and_submission_type()', # 5.4.2.1. Compare <rfc> "submissionType" and <seriesInfo> "stream"
'.//boilerplate;insert_status_of_memo()', # 5.4.2.2. "Status of this Memo" Insertion
'.//boilerplate;insert_status_of_memo()', # 5.4.2.2. "Status of This Memo" Insertion
'.//boilerplate;insert_copyright_notice()', # 5.4.2.3. "Copyright Notice" Insertion
'.//boilerplate//section', # 5.2.7. Section "toc" attribute
'.//reference;insert_target()', # 5.4.3. <reference> "target" Insertion
Expand Down Expand Up @@ -476,9 +476,9 @@ def check_attribute_values(self, e, p):
if consensus:
self.err(self.root, "Expected no consensus setting for IRTF stream and no workgroup, but found '%s'. Ignoring it." % consensus)
consensus = 'n/a'
elif stream == 'independent':
elif stream == 'independent' or stream == 'editorial':
if consensus:
self.err(self.root, "Expected no consensus setting for independent stream, but found '%s'. Ignoring it." % consensus)
self.err(self.root, "Expected no consensus setting for %s stream, but found '%s'. Ignoring it." % (stream, consensus))
consensus = 'n/a'
elif consensus != None:
pass
Expand Down Expand Up @@ -1023,9 +1023,9 @@ def check_series_and_submission_type(self, e, p):
for i in series_info_list:
i.set('stream', stream)

# 5.4.2.2. "Status of this Memo" Insertion
# 5.4.2.2. "Status of This Memo" Insertion
#
# Add the "Status of this Memo" section to the <boilerplate> element
# Add the "Status of This Memo" section to the <boilerplate> element
# with current values. The application will use the "submissionType",
# and "consensus" attributes of the <rfc> element, the <workgroup>
# element, and the "status" and "stream" attributes of the <seriesInfo>
Expand All @@ -1036,10 +1036,10 @@ def boilerplate_insert_status_of_memo(self, e, p):
return
if self.root.get('ipr') == 'none':
return
# submissionType: "IETF" | "IAB" | "IRTF" | "independent"
# submissionType: "IETF" | "IAB" | "IRTF" | "independent" | "editorial"
# consensus: "false" | "true"
# category: "std" | "bcp" | "exp" | "info" | "historic"
b = e.xpath('./section/name[text()="Status of this Memo"]')
b = e.xpath('./section/name[text()="Status of This Memo"]')
existing_status_of_memo = b[0] if b else None
if existing_status_of_memo:
if self.liberal:
Expand Down Expand Up @@ -1070,7 +1070,7 @@ def boilerplate_insert_status_of_memo(self, e, p):
#
if stream == 'IRTF' and workgroup == None:
consensus = 'n/a'
elif stream == 'independent':
elif stream == 'independent' or stream == 'editorial':
consensus = 'n/a'
try:
for para in boilerplate_rfc_status_of_memo[stream][category][consensus]:
Expand All @@ -1080,7 +1080,7 @@ def boilerplate_insert_status_of_memo(self, e, p):
except KeyError as exception:
if str(exception) in ["'rfc_number'", "'group_name'"]:
# Error in string expansion
self.die(p, 'Expected to have a value for %s when expanding the "Status of this Memo" boilerplate, but found none.' % str(exception))
self.die(p, 'Expected to have a value for %s when expanding the "Status of This Memo" boilerplate, but found none.' % str(exception))
else:
# Error in boilerplate dictionary indexes
self.die(self.root, 'Unexpected attribute combination(%s): <rfc submissionType="%s" category="%s" consensus="%s">' % (exception, stream, category, consensus))
Expand Down

0 comments on commit cfa629f

Please sign in to comment.