stevedlawrence commented on code in PR #1340:
URL: https://github.com/apache/daffodil/pull/1340#discussion_r1810797111
##########
build.sbt:
##########
@@ -481,6 +489,106 @@ lazy val unidocSettings =
(JavaUnidoc / unidoc / unidocAllSources).value.map(apiDocSourceFilter)
)
+lazy val genTunablesDocSettings = Seq(
+ Compile / genTunablesDoc := {
+ val stream = (propgen / streams).value
+ val dafExtFile =
+ (propgen / Compile / resources).value.find(_.getName == "dafext.xsd").get
+ val outputDocFile = (Compile / target).value / "tunables.md"
+ // parse xsd file
+ val dafExtXml = scala.xml.XML.loadFile(dafExtFile)
+ // extract tunables information
+ val tunablesElements =
+ (dafExtXml \ "element").filter(_ \@ "name" == "tunables") \\ "all" \
"element"
+ // build documentation
+ val documentationTuple = tunablesElements.map { ele =>
+ val subtitle = ele \@ "name"
+ val documentation = (ele \ "annotation" \
"documentation").text.trim.replaceAll(" +", " ")
+ val default = ele \@ "default"
+ (subtitle, documentation, default)
+ }
+ val (deprecated, nonDeprecated) = documentationTuple.partition { t =>
+ t._2.startsWith("Deprecated")
+ }
+ if (nonDeprecated.isEmpty) {
+ sys.error("tunables document generation failed as non-deprecated
elements list is empty")
Review Comment:
This just outputs a log message but doesn't actually fail the task. I've
found the best way to create a failure with an error message is to replace
`sys.error` with this:
```scala
throw new MessageOnlyException("error message here")
```
It also means you can move the following code out of the else block.
##########
build.sbt:
##########
@@ -481,6 +489,106 @@ lazy val unidocSettings =
(JavaUnidoc / unidoc / unidocAllSources).value.map(apiDocSourceFilter)
)
+lazy val genTunablesDocSettings = Seq(
+ Compile / genTunablesDoc := {
+ val stream = (propgen / streams).value
+ val dafExtFile =
+ (propgen / Compile / resources).value.find(_.getName == "dafext.xsd").get
+ val outputDocFile = (Compile / target).value / "tunables.md"
+ // parse xsd file
+ val dafExtXml = scala.xml.XML.loadFile(dafExtFile)
+ // extract tunables information
+ val tunablesElements =
+ (dafExtXml \ "element").filter(_ \@ "name" == "tunables") \\ "all" \
"element"
+ // build documentation
+ val documentationTuple = tunablesElements.map { ele =>
+ val subtitle = ele \@ "name"
+ val documentation = (ele \ "annotation" \
"documentation").text.trim.replaceAll(" +", " ")
Review Comment:
Suggest doing `(ele \ "annotation" \
"documentation").text.split("\n").map(_.trim).mkString("\n")`. Triming each
individual line will avoid a space at the beginning of lines. I *think* the
extra space shouldn't affect the markdown since it's just a single space, but
for a format that is somewhat space-sensitive it's probably best to ensure
there are no leading spaces.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]