Skip to content

Commit c555673

Browse files
committed
Merge branch 'master' into 528-standalone-sdpi---editorial-content-update
2 parents add0cbe + 549db9c commit c555673

49 files changed

Lines changed: 7410 additions & 70 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ci/asciidoc-converter/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
66
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
77

8+
images
9+
810
# User-specific stuff
911
.idea/**/workspace.xml
1012
.idea/**/tasks.xml
@@ -134,4 +136,5 @@ gradle-app.setting
134136
### Gradle Patch ###
135137
**/build/
136138

137-
# End of https://www.toptal.com/developers/gitignore/api/kotlin,gradle,intellij+all
139+
# End of https://www.toptal.com/developers/gitignore/api/kotlin,gradle,intellij+all
140+
/sdpi-supplement/

.ci/asciidoc-converter/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ kotlin {
6868
compilerOptions {
6969
jvmTarget = JvmTarget.JVM_17
7070
}
71+
sourceSets.all {
72+
// Must be explicitly enabled!
73+
languageSettings.enableLanguageFeature("ExplicitBackingFields")
74+
}
7175
}
7276

7377
application {

.ci/asciidoc-converter/images/target=puml-sdpi-p-managed-discovery-option-sequence-diagram.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

.ci/asciidoc-converter/src/main/kotlin/org/sdpi/AsciidocConverter.kt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,20 @@ class AsciidocConverter(
7474
private val profileContentModuleCollector = ContentModuleIncludeProcessor()
7575
private val profileUseCaseSupportCollector = SupportUseCaseIncludeProcessor()
7676
private val externalStandardsProcessor = ExternalStandardProcessor()
77+
private val deprecatedRequirementsProcessor = DeprecateRequirementProcessor()
78+
private val deprecatedTransactionsProcessor = DeprecateTransactionProcessor()
79+
private val deprecatedOidProcessor = DeprecateProcessor()
7780

7881
val infoCollector = SdpiInformationCollector(
7982
bibliographyCollector,
8083
transactionActorsProcessor,
8184
profileTransactionCollector,
8285
profileUseCaseSupportCollector,
8386
profileContentModuleCollector,
84-
externalStandardsProcessor
87+
externalStandardsProcessor,
88+
deprecatedRequirementsProcessor,
89+
deprecatedTransactionsProcessor,
90+
deprecatedOidProcessor
8591
)
8692

8793
override fun run() {
@@ -121,6 +127,10 @@ class AsciidocConverter(
121127

122128
asciidoctor.javaExtensionRegistry().blockMacro(profileContentModuleCollector)
123129

130+
asciidoctor.javaExtensionRegistry().blockMacro(deprecatedOidProcessor)
131+
asciidoctor.javaExtensionRegistry().blockMacro(deprecatedRequirementsProcessor)
132+
asciidoctor.javaExtensionRegistry().blockMacro(deprecatedTransactionsProcessor)
133+
124134
// Gather SDPI specific information from the document such as
125135
// requirements and use-cases.
126136

@@ -209,6 +219,24 @@ class AsciidocConverter(
209219
"sdpi-requirements",
210220
jsonFormatter.encodeToString(infoCollector.requirements().values)
211221
)
222+
223+
writeArtifact(
224+
"sdpi-requirements-deprecated",
225+
jsonFormatter.encodeToString(deprecatedRequirementsProcessor.entries.values)
226+
)
227+
228+
writeArtifact(
229+
"sdpi-transactions-deprecated",
230+
jsonFormatter.encodeToString(deprecatedTransactionsProcessor.entries.values)
231+
)
232+
233+
writeArtifact(
234+
"sdpi-deprecated",
235+
jsonFormatter.encodeToString(
236+
deprecatedOidProcessor.entries.values
237+
+ deprecatedRequirementsProcessor.entries.values
238+
+ deprecatedTransactionsProcessor.entries.values)
239+
)
212240
}
213241

214242
asciidoctor.shutdown()

.ci/asciidoc-converter/src/main/kotlin/org/sdpi/asciidoc/BlockAttribute.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ enum class BlockAttribute(val key: String) {
2222
LEAF_ARC("oid-arcs")
2323
}
2424

25+
/**
26+
* Attributes for deprecation inline block macros.
27+
*/
28+
enum class DeprecationAttributes(val key: String) {
29+
// The version when a requirement, transaction, &c became deprecated.
30+
VERSION("version"),
31+
}
32+
2533
/**
2634
* Defines attribute keywords for sdpi_requirement blocks
2735
*/

.ci/asciidoc-converter/src/main/kotlin/org/sdpi/asciidoc/Util.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.sdpi.asciidoc
33
import org.apache.logging.log4j.kotlin.loggerOf
44
import org.asciidoctor.ast.ContentNode
55
import org.asciidoctor.ast.StructuralNode
6-
import org.jruby.util.ResourceException.InvalidArguments
76
import org.sdpi.asciidoc.extension.Roles
87
import org.sdpi.asciidoc.model.BlockOwner
98
import org.sdpi.asciidoc.model.RequirementLevel
@@ -155,7 +154,7 @@ fun getTitleFrom(block: StructuralNode): String {
155154

156155
fun makeLink(strAnchor: String, strText: String, strClass: String? = null): String {
157156
if (strAnchor.contains(" ")) {
158-
throw InvalidArguments("Anchor '$strAnchor' contains spaces")
157+
throw IllegalArgumentException("Anchor '$strAnchor' contains spaces")
159158
}
160159

161160
return if (strClass == null) {
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package org.sdpi.asciidoc.extension
2+
3+
import org.apache.logging.log4j.kotlin.Logging
4+
import org.asciidoctor.ast.StructuralNode
5+
import org.asciidoctor.extension.BlockMacroProcessor
6+
import org.asciidoctor.extension.Name
7+
import org.sdpi.asciidoc.DeprecationAttributes
8+
import org.sdpi.asciidoc.model.DeprecatedOid
9+
import org.sdpi.asciidoc.model.WellKnownOid
10+
import org.sdpi.asciidoc.model.makeConformityVersionOid
11+
12+
const val BLOCK_MACRO_NAME_DEPRECATE = "Deprecate"
13+
const val BLOCK_MACRO_NAME_DEPRECATE_REQUIREMENT = "DeprecateRequirement"
14+
const val BLOCK_MACRO_NAME_DEPRECATE_TRANSACTION = "DeprecateTransaction"
15+
16+
@Name(BLOCK_MACRO_NAME_DEPRECATE_REQUIREMENT)
17+
class DeprecateRequirementProcessor : BlockMacroProcessor(BLOCK_MACRO_NAME_DEPRECATE_REQUIREMENT) {
18+
private companion object : Logging
19+
20+
val entries: Map<String, DeprecatedOid>
21+
field = mutableMapOf()
22+
23+
fun isDeprecated(strRequirementOid: String) : DeprecatedOid? {
24+
return entries[strRequirementOid]
25+
}
26+
27+
override fun process(parent: StructuralNode, strTarget: String, attributes: MutableMap<String, Any>): Any? {
28+
29+
val strVersion = attributes[DeprecationAttributes.VERSION.key]?.toString()
30+
checkNotNull(strVersion) {
31+
logger.error("$BLOCK_MACRO_NAME_DEPRECATE_REQUIREMENT missing required attribute '${DeprecationAttributes.VERSION.key}'")
32+
}
33+
34+
val strVersionOid = makeConformityVersionOid(strVersion)
35+
36+
val requirementNumber = parseRequirementNumber(strTarget)
37+
val strRequirementId = getRequirementOid(requirementNumber)
38+
39+
checkNotNull(!entries.containsKey(strRequirementId)) {
40+
logger.error("Requirement $strRequirementId is already marked deprecated")
41+
}
42+
43+
entries[strRequirementId] = DeprecatedOid(strRequirementId, strVersionOid)
44+
45+
return null
46+
}
47+
}
48+
@Name(BLOCK_MACRO_NAME_DEPRECATE)
49+
class DeprecateProcessor : BlockMacroProcessor(BLOCK_MACRO_NAME_DEPRECATE) {
50+
private companion object : Logging
51+
52+
val entries: Map<String, DeprecatedOid>
53+
field = mutableMapOf()
54+
55+
fun isDeprecated(strOid: String) : DeprecatedOid? {
56+
return entries[strOid]
57+
}
58+
59+
override fun process(parent: StructuralNode, strTarget: String, attributes: MutableMap<String, Any>): Any? {
60+
61+
val strVersion = attributes[DeprecationAttributes.VERSION.key]?.toString()
62+
checkNotNull(strVersion) {
63+
"$BLOCK_MACRO_NAME_DEPRECATE_REQUIREMENT missing required attribute '${DeprecationAttributes.VERSION.key}'".also {
64+
logger.error{it}
65+
}
66+
}
67+
println("**Deprecating $strTarget")
68+
val strVersionOid = makeConformityVersionOid(strVersion)
69+
70+
71+
check(strTarget.startsWith(WellKnownOid.DEV_SDPi.oid)) {
72+
"Oid `$strTarget` must begin with ${WellKnownOid.DEV_SDPi.oid}".also {
73+
logger.error{it}
74+
}
75+
}
76+
77+
val reOid = Regex("""^(?:(?:[01]\.(?:[0-9]|[1-3][0-9]))|(?:2\.(?:0|[1-9]\d*)))(?:\.(?:0|[1-9]\d*))*$""")
78+
check(reOid.matches(strTarget)) {
79+
"Oid `$strTarget` must be a valid oid".also {
80+
logger.error{it}
81+
}
82+
}
83+
84+
checkNotNull(!entries.containsKey(strTarget)) {
85+
"Oid $strTarget is already marked deprecated".also {
86+
logger.error{it}
87+
}
88+
}
89+
90+
91+
entries[strTarget] = DeprecatedOid(strTarget, strVersionOid)
92+
93+
return null
94+
}
95+
}
96+
97+
@Name(BLOCK_MACRO_NAME_DEPRECATE_TRANSACTION)
98+
class DeprecateTransactionProcessor : BlockMacroProcessor(BLOCK_MACRO_NAME_DEPRECATE_TRANSACTION) {
99+
private companion object : Logging
100+
101+
val entries: Map<String, DeprecatedOid>
102+
field = mutableMapOf()
103+
104+
fun isDeprecated(strTransactionOid: String) : DeprecatedOid? {
105+
return entries[strTransactionOid]
106+
}
107+
108+
override fun process(parent: StructuralNode, strTarget: String, attributes: MutableMap<String, Any>): Any? {
109+
110+
val strVersion = attributes[DeprecationAttributes.VERSION.key]?.toString()
111+
checkNotNull(strVersion) {
112+
"$BLOCK_MACRO_NAME_DEPRECATE_TRANSACTION missing required attribute '${DeprecationAttributes.VERSION.key}'".also {
113+
logger.error{it}
114+
}
115+
}
116+
117+
val strVersionOid = makeConformityVersionOid(strVersion)
118+
119+
val strTransactionId = getTransactionOid(strTarget)
120+
121+
checkNotNull(!entries.containsKey(strTransactionId)) {
122+
"Transaction $strTransactionId is already marked deprecated".also {
123+
logger.error{it}
124+
}
125+
}
126+
127+
entries[strTransactionId] = DeprecatedOid(strTransactionId, strVersionOid)
128+
129+
return null
130+
}
131+
132+
private fun getTransactionOid(strTransactionId: String): String {
133+
if (strTransactionId.startsWith("DEV-")) {
134+
val strLeaf = strTransactionId.substring(4)
135+
if (strLeaf.toIntOrNull() != null) {
136+
return "${WellKnownOid.DEV_TRANSACTION.oid}.$strLeaf"
137+
}
138+
}
139+
throw IllegalArgumentException("'$strTransactionId' is not a valid transaction id")
140+
}
141+
}

0 commit comments

Comments
 (0)