Anypoint Studio - DataWeave 1.0 - How to add comments? - comments

Is it possible to add comments to our DataWeave v1.0 scripts in Anypoint Studio?

Yes. You can add a single-line comment:
%dw 1.0
%output application/java
%namespace ns0 http://www.namespace.com/resource
---
{
// This is a comment.
id: payload.id
}
But be careful: comments are not allowed everywhere. For example; comments at the end of the file won't work at the moment.
See also the related topic in the MuleSoft forum: Comments in DataWeave

Related

TeamCity Kotlin DSL - Use of function option in BuildType

Does somebody knows how to use the function option in BuildType and how are then the options accessible?
Here the link to the function: https://teamcity.jetbrains.com/app/dsl-documentation/jetbrains.build-server.configs.kotlin.v2019_2/-build-type-settings/option.html
What's the intent behind this option? How is it then reflected inside a TeamCity Build Configuration?
Unfortunately, I haven't found a documentation / tutorial / post about that topic.
It's relevant to the given Build Configuration Type in any job.
This gives the default options:
Regular
Composite
Deployment

gRPC documentation generator

Does gRPC support generating documentation for services like Swagger?
protoc-gen-doc is a protoc plugin which generates HTML docs using Go HTML templates. Although it isn't being used by the original sponsor company anymore, it looks like a good starting point.
Your protofiles are the documentation.
You can put comments there to clarify meaning of parameters or service methods.

referencing sphinx generated Python docs from YAML file

We have an internal python API that we have documented using Sphinx. part of the system uses YAML for configuration files that contain reference to py file that use the API. I've been asked to see if there is a way, using sphinx, to link the YAML config files to the the appropriate API docs. I've been doing research on google, here and sphinx site and it looks like I may be able to use intersphinx but I'm unclear how to make the connection between the two.
so for example: here is the yaml config file:
HALT_LEVEL: Any
SUITE: "Checkin Tests"
DESCRIPTION: "checkin test suite"
TESTLIST:
- TESTCASE: install stuff
DESC: "Installs RPM"
TESTGROUP: sprint_0
TESTFILE: install_stuff.py # I would like to turn this into a link to our sphinx docs
# for this. This file is already part of sphinx docs"
So then when someone is looking at the html/sphinx version of the the above file they could click on install_stuff.py and it take them to the docs that exist
Is this possible?
thanks in advance,
Greg.
Just for those that may be interested. I was able to do this but not using Sphinx. I used pyyaml to read the file and pygments to generate the html then hacked the generated html.
Since pygments doesn't appear to allow live href links what to add them what I is
# create a yaml string using pyyaml and then modify the string.
href = '[ahref="%s"]%s[/a]' % (hrefData, hrefString)
yamldata['KEYWORD'][idx]['HOST'] = href
This changes the referenced yaml to a string that looks something like '[ahref="http://example.com"]Example.com[/a]'. The brackets make it easier to change after the html is generated. Further down in the code I use pygments to generate the html
htmlpage = highlight(yamldata,lexer, HtmlFormatter(full=True, title=yamldata['TITLE']))
Now I convert the href that I created above to a real href with:
webpage = htmlpage.replace(''', '').replace('ahref', 'a href').replace('[','<').replace(']','>').replace('"','"')

Other file formats with the gradle license plugin

using license gradle plugin,
If we want to include other types of files like .js, .xsl, .rptdesign etc., also to add the license text, what do we need to do? Please any one can suggest me.
If you read the instructions, they say:
An extensive list of formats and mappings are available by default, see the SupportedFormats link. Occasionally a project might need to add a mapping to a unknown file type to an existing comment style.
license {
mapping {
javascript='JAVADOC_STYLE'
}
}
// or
license.mapping 'javascript' 'JAVADOC_STYLE'
// or directly on the task
licenseMain.mapping 'javascript' 'JAVADOC_STYLE'
Defining new comment types is not currently supported, but file a bug and it can be added.

YAML Schema Validation?

Is there a schema validation language for YAML? I've googled but couldn't find anything useful.
Something like XSD format, using the language itself to describe the schema, would be the best choice in my case.
JSON Schema can be used with most YAML documents resulting in a more portable and better documented solution than Rx or Kwalify. JSON Schema is the only of the three for which I have been able to find editor support.
More information on using YAML and JSON Schema including tools and editor support is tracked on this page. At the time of writing, there is editor support in Visual Studio Code and a command-line based validation tool available via npm.
Full Disclosure: I authored the web site linked above to try to make the application of JSON Schema to YAML more discoverable. I also wrote an editor extension for VS Code that has since been superseded by the RedHat extension linked above.
Try Kwalify (Ruby and Java only), or Rx (many languages)
I wonder if it would make sense to reuse JSON schema for this. YAML can be easily converted to JSON without loosing any information (?), so in theory YAML could be validated by the same tool chain, allowing open source community to concentrate on one good schema tool chain. The schema itself could also be written in YAML and converted to JSON.
Good idea. Googled this up because I was looking for the same.
It's possible to convert YAML to XML in a defined manner (similarly to JSON <-> XML) and validate with a standard XML validator.
Depending on your platform, there are tools or snippets for that conversion: JavaScript (NPM), Ruby, Java (Jackson), Java (TestNG) (you'll need to see the source for what parameters it wants).
If done using an API, the error positions can even be mapped back to the original YAML file.
You can use this python ysd project to validate your yaml files. https://github.com/yonahd/ysd
Super simple to use
python yaml-validator/main.py -v yamls/example-values.yaml -r yamls/example-rules.yaml
Example rule file:
required: // field must exist and type must match
env: str
enabled: bool
replicas: int
optional: // if field exists type must match
disk: str
Example yaml file (helm values file):
network:
service:
port: 8060
enabled: true
image:
app: my-app:build
replicas: 1
env: dev
disk: local
If your project is in C++, you can also use the yaml-schema-cpp library. It allows to validate (and complete) the .yaml input files using schema files (YAML files with extension .schema) from your C++ code.

Resources