-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User guide documentation update #5
base: master
Are you sure you want to change the base?
Changes from 3 commits
20a399b
e8e3fe2
e5a6375
78f6e58
5f258c8
25e86c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -380,6 +380,21 @@ enums: | |
17: udp | ||
---- | ||
|
||
Alternatively, hexadecimal notation can also be used to define an enumeration: | ||
|
||
[source,yaml] | ||
---- | ||
seq: | ||
- id: key | ||
type: u4 | ||
enum: keys | ||
enums: | ||
keys: | ||
0x77696474: width #widt | ||
0x68656967: height #heig | ||
0x64657074: depth #dept | ||
---- | ||
|
||
There are two things that should be done to declare a enum: | ||
|
||
1. We add `enums` key on the type level (i.e. on the same level as | ||
|
@@ -472,7 +487,25 @@ structure: | |
|
||
[source,yaml] | ||
---- | ||
TODO | ||
seq: | ||
- id: header | ||
type: file_header | ||
- id: metadata | ||
type: metadata_section | ||
types: | ||
file_header: | ||
seq: | ||
- id: version | ||
type: u2 | ||
metadata_section: | ||
seq: | ||
- id: author | ||
type: strz | ||
encoding: UTF-8 | ||
- id: publisher | ||
type: strz | ||
encoding: UTF-8 | ||
if: _parent.header.version >= 2 | ||
---- | ||
|
||
==== `_root` | ||
|
@@ -799,6 +832,39 @@ other value which was not listed explicitly. | |
_: rec_type_unknown | ||
---- | ||
|
||
If an enumeration has already been defined, you can use references to | ||
items in the enumeration instead of specifying integers a second time: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, if you defined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm good point, I'll update the text accordingly |
||
|
||
[source,yaml] | ||
---- | ||
seq: | ||
- id: key | ||
type: u4 | ||
enum: keys | ||
- id: data | ||
type: | ||
switch-on: key | ||
cases: | ||
keys::width: data_field_width | ||
keys::height: data_field_height | ||
keys::depth: data_field_depth | ||
types: | ||
data_field_width: | ||
seq: | ||
#... | ||
data_field_height: | ||
seq: | ||
#... | ||
data_field_depth: | ||
seq: | ||
#... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pedantic person in me cries for that misaligned types:
data_field_width: # ...
data_field_height: # ...
data_field_depth: # ... for brevity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, agreed |
||
enums: | ||
keys: | ||
0x77696474: width #widt | ||
0x68656967: height #heig | ||
0x64657074: depth #dept | ||
---- | ||
|
||
=== Instances: data beyond the sequence | ||
|
||
So far we've done all the data specifications in `seq` - thus they'll | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally ok, but I'd also noted that this is a service provided by YAML, not something specific to KS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that a new section of the document could be created for general syntax and a very brief overview of YAML and what it provides. This example I provided may be better suited there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some Construct features are Python features, but I would advertise them just the same. Purpose of documentation is to show capabilities, not attribution. =) Just saying.