From e835f1a1912f059531309a11adf151de83699011 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Sat, 29 Oct 2011 20:43:30 +0200 Subject: [PATCH] Updated Representer API doc, minor documentation changes. --- autoddoc.cfg | 2 +- doc/doctrees/environment.pickle | Bin 12705 -> 12705 bytes doc/doctrees/tutorials/custom_types.doctree | Bin 46981 -> 47085 bytes doc/html/_sources/tutorials/custom_types.txt | 55 +++++++++---------- doc/html/api/dyaml.constructor.html | 6 +- doc/html/api/dyaml.dumper.html | 2 + doc/html/api/dyaml.encoding.html | 2 + doc/html/api/dyaml.exception.html | 4 +- doc/html/api/dyaml.linebreak.html | 2 + doc/html/api/dyaml.loader.html | 6 +- doc/html/api/dyaml.node.html | 12 ++-- doc/html/api/dyaml.representer.html | 20 +++++-- doc/html/api/dyaml.resolver.html | 6 +- doc/html/api/index.html | 2 + doc/html/articles/spec_differences.html | 2 +- doc/html/index.html | 2 +- doc/html/search.html | 2 +- doc/html/searchindex.js | 2 +- doc/html/tutorials/custom_types.html | 55 +++++++++---------- doc/html/tutorials/getting_started.html | 2 +- doc/html/tutorials/yaml_syntax.html | 2 +- docsrc/tutorials/custom_types.rst | 55 +++++++++---------- dyaml/representer.d | 18 ++++-- 23 files changed, 144 insertions(+), 115 deletions(-) diff --git a/autoddoc.cfg b/autoddoc.cfg index 741fd31..15aea1f 100644 --- a/autoddoc.cfg +++ b/autoddoc.cfg @@ -29,7 +29,7 @@ links = ../index.html Documentation home # Source files or patterns to ignore. Supports regexp syntax. # E.g; To ignore main.d and all source files in the test/ directory, # you would use: "main.d test/*" -ignore = test/*, examples/*, docsrc/*, autoddoc/*, yaml.d, unittest.d, cdc.d, dyaml/composer.d, dyaml/event.d, dyaml/parser.d, dyaml/reader.d, dyaml/scanner.d, dyaml/token.d, dyaml/util.d, dyaml/anchor.d, dyaml/emitter.d, dyaml/flags.d, dyaml/serializer.d, dyaml/sharedobject.d, dyaml/tag.d, dyaml/tagdirectives.d, dyaml/queue.d, dyaml/escapes.d, dyaml/fastcharsearch.d, dyaml/style.d +ignore = test/*, examples/*, docsrc/*, autoddoc/*, yaml.d, unittest.d, cdc.d, dyaml/composer.d, dyaml/event.d, dyaml/parser.d, dyaml/reader.d, dyaml/scanner.d, dyaml/token.d, dyaml/util.d, dyaml/anchor.d, dyaml/emitter.d, dyaml/flags.d, dyaml/serializer.d, dyaml/sharedobject.d, dyaml/tag.d, dyaml/tagdirectives.d, dyaml/queue.d, dyaml/escapes.d, dyaml/fastcharsearch.d [DDOC] # Command to use to generate the documentation. diff --git a/doc/doctrees/environment.pickle b/doc/doctrees/environment.pickle index 2c074b70c6f55ccd41e8bdc8d4e253cb349f7902..ecdd68cb6a49845c64463a882c8cdb1f920f4738 100644 GIT binary patch delta 63 zcmZ3OyfAq~tG>}{A>9MVR%9r~yBH0;{%QKYS9WMi!-AQjVbRf*Bg)1^lA3vd+Il~wDnku(w-jeZEz62D<24Z=aPg#;K37$Oj07!Vj`)HBmkw=^?7yzY?@ zu`J2Ki7}2bx_}+WAH*m8KVkqUwv&xRY{#)N4K*n1VviOPL$d6L z&r)t}UZaVAO*9l$w~*bZMFM^?qRV19AgLiSr1>#IkN6Z((#4<@4y&PdUF=p3Mf3$E zT^Ie5A&Egb=#`o75|?P*a+l01EijZ~&op|%7|p@pPo5!IU{~_8f;ayO)Vz`+{!{39 zBlR3+Wouduw$G(a7HZ&f+8?Y7XRn{Xe3|HzLZTGVVJNFUT9%jAez zMOOBW{L!JTNrEs9Udk?qkF%#_h)mYCK$mQR@z(iPiODg8-(`U=>)dgop^1{;FRHVq zD2blS-6{N4DGdO5h1Ywc&*$aj=O4u!HEG>g(vrbT9kU3RrVVQ}v^mqZ`u=TL)Q`=Nr@h?^1E-VD=Oebty znURePJLbU!tJY4B24^~w1P|oaIB$mSqgj5qVb{*R4>cx0@2YOuMiZ%=G zeN2}tdC^eyLPS!jr!TK`F^upm0rdMH^~99=4(O%(d!)ApxUSYl>r?dh;JTG*+hEw>QDcGsR_b#^=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z76(G};AO9%7ZWI*Nds})_f4CPuXB8xzY5lKSLeP)z64hyy@xMgJ<5InOV7EAUgz~6 xVu{~Kwe-Sz1M5{vSvS0PJRe>>XA^&fhHmy_EL|xy+sN<}Y(&{lv5fRM{}1-}oYVjS diff --git a/doc/html/_sources/tutorials/custom_types.txt b/doc/html/_sources/tutorials/custom_types.txt index 35d48e0..9b3eaf5 100644 --- a/doc/html/_sources/tutorials/custom_types.txt +++ b/doc/html/_sources/tutorials/custom_types.txt @@ -2,15 +2,15 @@ Custom YAML data types ====================== -Often you might want to serialize complex data types such as classes. You can -use functions to process nodes such as a mapping containing class data members -indexed by name. Alternatively, YAML supports custom data types using -identifiers called *tags*. That is the topic of this tutorial. +Sometimes you need to serialize complex data types such as classes. To do this +you could use plain nodes such as mappings with class data members. However, +YAML supports custom types with identifiers called *tags*. That is the topic of +this tutorial. Each YAML node has a tag specifying its type. For instance: strings use the tag ``tag:yaml.org,2002:str``. Tags of most default types are *implicitly resolved* during parsing, so you don't need to specify tag for each float, integer, etc. -It is also possible to implicitly resolve custom tags, as we will show later. +D:YAML can also implicitly resolve custom tags, as we will show later. ----------- @@ -18,16 +18,16 @@ Constructor ----------- D:YAML uses the `Constructor <../api/dyaml.constructor.html>`_ class to process -each node to hold data type corresponding to its tag. *Constructor* stores a -function for each supported tag to process it. These functions are supplied by -the user using the *addConstructorXXX()* methods, where *XXX* is *Scalar*, -*Sequence* or *Mapping*. *Constructor* is then passed to *Loader*, which parses -YAML input. +each node to hold data type corresponding to its tag. *Constructor* stores +functions to process each supported tag. These are supplied by the user using +the *addConstructorXXX()* methods, where *XXX* is *Scalar*, *Sequence* or +*Mapping*. *Constructor* is then passed to *Loader*, which parses YAML input. Struct types have no specific requirements for YAML support. Class types should define the *opEquals()* operator, as this is used in equality comparisons of nodes. Default class *opEquals()* compares references, which means two identical -objects might be considered unequal. +objects might be considered unequal. (Default struct *opEquals()* compares +byte-by-byte, sometimes you might want to override that as well.) We will implement support for an RGB color type. It is implemented as the following struct: @@ -173,10 +173,10 @@ You can find the source code for what we've done so far in the Resolver -------- -Specifying tag for every color value can be tedious. D:YAML can implicitly -resolve scalar tags using regular expressions. This is how default types such as -int are resolved. We will use the `Resolver <../api/dyaml.resolver.html>`_ class -to add implicit tag resolution for the Color data type (in its scalar form). +Specifying tag for every color can be tedious. D:YAML can implicitly resolve +scalar tags using regular expressions. This is how default types are resolved. +We will use the `Resolver <../api/dyaml.resolver.html>`_ class to add implicit +tag resolution for the Color data type (in its scalar form). We use the *addImplicitResolver()* method of *Resolver*, passing the tag, regular expression the scalar must match to resolve to this tag, and a string of @@ -228,9 +228,9 @@ D:YAML package. Representer ----------- -Now that you know how to load custom data types, it might also be useful to know -how to dump them. D:YAML uses the `Representer <../api/dyaml.representer.html>`_ -class for this purpose. +Now that you can load custom data types, it might be good to know how to dump +them. D:YAML uses the `Representer <../api/dyaml.representer.html>`_ class for +this purpose. *Representer* processes YAML nodes into plain mapping, sequence or scalar nodes ready for output. Just like with *Constructor*, this is done by user specified @@ -239,15 +239,14 @@ functions. These functions take references to a node to process and to the Representer functions can be added with the *addRepresenter()* method. The *Representer* is then passed to *Dumper*, which dumps YAML documents. Only one -representer can be added for a type. This is asserted in *addRepresenter()* -preconditions. By default, the default YAML types already have representer -functions, but you can disable them by constructing *Representer* with the +function per type can be specified. This is asserted in *addRepresenter()* +preconditions. Default YAML types already have representer functions specified, +but you can disable them by constructing *Representer* with the *useDefaultRepresenters* parameter set to false. -By default, tags are explicitly specified for all non-default types. If you -want the tags to be implicit, you can pass a *Resolver* that will resolve them -implicitly. Of course, you will then need to use an identical *Resolver* when -loading the output. +By default, tags are explicitly output for all non-default types. To make dumped +tags implicit, you can pass a *Resolver* that will resolve them implicitly. Of +course, you will need to use an identical *Resolver* when loading the output. With the following code, we will add support for dumping the our Color type. @@ -274,10 +273,10 @@ With the following code, we will add support for dumping the our Color type. First we get the *Color* from the node. Then we convert it to a string with the CSS-like format we've used before. Finally, we use the *representScalar()* -method of *Representer* to get a scalar node ready for output. -There are corresponding *representMapping()* and *representSequence()* methods +method of *Representer* to get a scalar node ready for output. There are +corresponding *representMapping()* and *representSequence()* methods as well, with examples in the -`Resolver API documentation <../api/dyaml.resolver.html>`_. +`Resolver API documentation <../api/dyaml.resolver.html>`_. Since a type can only have one representer function, we don't dump *Color* both in the scalar and mapping formats we've used before. However, you can decide to diff --git a/doc/html/api/dyaml.constructor.html b/doc/html/api/dyaml.constructor.html index 63d0eca..da144bb 100644 --- a/doc/html/api/dyaml.constructor.html +++ b/doc/html/api/dyaml.constructor.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • @@ -81,7 +83,7 @@ If a tag is detected with no known constructor function, it is considered an error.

    -
    this(in bool defaultConstructors = true); +
    this(in const(bool) defaultConstructors = true);

    Construct a Constructor.

    @@ -89,7 +91,7 @@ defaultConstructors to disable constructor functions for these.

    -Parameters:
    +Parameters:
    bool defaultConstructors
    const(bool) defaultConstructors Use constructors for default YAML tags?
    diff --git a/doc/html/api/dyaml.dumper.html b/doc/html/api/dyaml.dumper.html index 2ccf744..fad08ae 100644 --- a/doc/html/api/dyaml.dumper.html +++ b/doc/html/api/dyaml.dumper.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • diff --git a/doc/html/api/dyaml.encoding.html b/doc/html/api/dyaml.encoding.html index 85aea05..93068b0 100644 --- a/doc/html/api/dyaml.encoding.html +++ b/doc/html/api/dyaml.encoding.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • diff --git a/doc/html/api/dyaml.exception.html b/doc/html/api/dyaml.exception.html index c961026..a1c5237 100644 --- a/doc/html/api/dyaml.exception.html +++ b/doc/html/api/dyaml.exception.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • @@ -56,7 +58,7 @@

    Position in a YAML stream, used for error messages.

    -
    this(in uint line, in uint column); +
    this(in const(uint) line, in const(uint) column);

    Construct a Mark with specified line and column in the file.

    diff --git a/doc/html/api/dyaml.linebreak.html b/doc/html/api/dyaml.linebreak.html index 8e14db5..13e4e4f 100644 --- a/doc/html/api/dyaml.linebreak.html +++ b/doc/html/api/dyaml.linebreak.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • diff --git a/doc/html/api/dyaml.loader.html b/doc/html/api/dyaml.loader.html index f3f3e8f..f38dc9c 100644 --- a/doc/html/api/dyaml.loader.html +++ b/doc/html/api/dyaml.loader.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • @@ -97,11 +99,11 @@ -
    this(in string filename); +
    this(in const(immutable(char)[]) filename);

    Construct a Loader to load YAML from a file.

    -Parameters:
    +Parameters:
    string filename
    const(immutable(char)[]) filename Name of the file to load from.
    Throws:
    YAMLException if the file could not be opened or read.
    diff --git a/doc/html/api/dyaml.node.html b/doc/html/api/dyaml.node.html index 5e58e4d..d4e31f2 100644 --- a/doc/html/api/dyaml.node.html +++ b/doc/html/api/dyaml.node.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • @@ -74,7 +76,7 @@

    Value node.

    -
    auto this(K, V)(K key, V value); +
    this(K, V)(K key, V value);

    Construct a Pair from two values. Will be converted to Nodes if needed.

    @@ -96,7 +98,7 @@

    Node collection style. Used to remember style this node was loaded with.

    -
    auto this(T)(T value, in string tag = null); +
    this(T)(T value, in string tag = null);

    Construct a Node from a value.

    @@ -124,7 +126,7 @@
    -
    auto this(T)(T[] array, in string tag = null); +
    this(T)(T[] array, in string tag = null);

    Construct a node from an array.

    @@ -154,7 +156,7 @@
    -
    auto this(K, V)(V[K] array, in string tag = null); +
    this(K, V)(V[K] array, in string tag = null);

    Construct a node from an associative array.

    @@ -186,7 +188,7 @@
    -
    auto this(K, V)(K[] keys, V[] values, in string tag = null); +
    this(K, V)(K[] keys, V[] values, in string tag = null);

    Construct a node from arrays of keys and values.

    diff --git a/doc/html/api/dyaml.representer.html b/doc/html/api/dyaml.representer.html index 8f8f002..a97ceb6 100644 --- a/doc/html/api/dyaml.representer.html +++ b/doc/html/api/dyaml.representer.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • @@ -72,12 +74,12 @@
    @property void defaultScalarStyle(ScalarStyle style);
    -

    Set default style for scalars. Invalid means the style is chosen automatically.

    +

    Set default style for scalars. Invalid means the style is chosen automatically.

    @property void defaultCollectionStyle(CollectionStyle style);
    -

    Set default style for collections. Invalid means the style is chosen automatically.

    +

    Set default style for collections. Invalid means the style is chosen automatically.

    void addRepresenter(T)(Node function(ref Node, Representer) representer); @@ -193,7 +195,8 @@ string scalar Scalar value. ScalarStyle style -Style of the scalar (will be default if invalid). +Style of the scalar. If invalid, default style will be used. + If the node was loaded before, previous style will always be used. Returns:
    The represented node. @@ -209,6 +212,7 @@ auto value = node.as!MyStruct; auto scalar = format(value.x, ":", value.y, ":", value.z); return representer.representScalar("!mystruct.tag", scalar); + }

    @@ -226,7 +230,8 @@ Node[] sequence Sequence of nodes. CollectionStyle style -Style of the sequence (will be default if invalid). +Style of the sequence. If invalid, default style will be used. + If the node was loaded before, previous style will always be used.
    Returns:
    The represented node. @@ -244,7 +249,9 @@ { auto value = node.as!MyStruct; auto nodes = [Node(value.x), Node(value.y), Node(value.z)]; - return representer.representSequence("!mystruct.tag", nodes); + //use flow style + return representer.representSequence("!mystruct.tag", nodes, + CollectionStyle.Flow); }

    @@ -262,7 +269,8 @@ Pair[] pairs Key-value pairs of the mapping. CollectionStyle style -Style of the mapping (will be default if invalid). +Style of the mapping. If invalid, default style will be used. + If the node was loaded before, previous style will always be used.
    Returns:
    The represented node. diff --git a/doc/html/api/dyaml.resolver.html b/doc/html/api/dyaml.resolver.html index 82a428b..e41c9e9 100644 --- a/doc/html/api/dyaml.resolver.html +++ b/doc/html/api/dyaml.resolver.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • @@ -52,7 +54,7 @@

    Can be used to implicitly resolve custom data types of scalar values.

    -
    this(in bool defaultImplicitResolvers = true); +
    this(in const(bool) defaultImplicitResolvers = true);

    Construct a Resolver.

    @@ -60,7 +62,7 @@ you can use defaultImplicitResolvers to disable default resolvers.

    -Parameters:
    +Parameters:
    bool defaultImplicitResolvers
    const(bool) defaultImplicitResolvers Use default YAML implicit resolvers?
    diff --git a/doc/html/api/index.html b/doc/html/api/index.html index 2bcfa00..304962a 100644 --- a/doc/html/api/index.html +++ b/doc/html/api/index.html @@ -32,6 +32,8 @@
  • dyaml.node
  • dyaml.representer
  • dyaml.resolver
  • +
  • dyaml.std.variant
  • +
  • dyaml.style
  • diff --git a/doc/html/articles/spec_differences.html b/doc/html/articles/spec_differences.html index aa571a2..5d4970b 100644 --- a/doc/html/articles/spec_differences.html +++ b/doc/html/articles/spec_differences.html @@ -138,7 +138,7 @@ struct appears in Phobos.

    diff --git a/doc/html/index.html b/doc/html/index.html index a2a4b45..f721c62 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -104,7 +104,7 @@ diff --git a/doc/html/search.html b/doc/html/search.html index b78b597..230bccf 100644 --- a/doc/html/search.html +++ b/doc/html/search.html @@ -87,7 +87,7 @@ diff --git a/doc/html/searchindex.js b/doc/html/searchindex.js index 37e3890..2e381bc 100644 --- a/doc/html/searchindex.js +++ b/doc/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({objects:{},terms:{represent:[2,3],all:[1,3,4],code:[0,1,3,4],representmap:3,scalar:[0,1,2,3,4],follow:[3,4],decid:3,depend:[0,3],show:[0,3],readabl:0,specif:[0,1,3,2],representsequ:3,program:4,digit:[3,4],sourc:[3,4],everi:3,string:[0,3,4],powervr:0,"void":[3,4],phobo:1,ident:3,failur:3,yamlexcept:[3,4],implicitli:[0,3],implement:[1,3],tri:1,gender:0,list:[0,1,2],iter:4,"try":[3,4],item:0,refer:[0,3],slower:0,past:4,fold:0,second:[0,4],design:0,pass:3,download:4,rrr:3,even:[1,4],index:[3,4],what:3,appear:1,compar:3,cast:3,preserv:[0,4],section:3,current:4,version:4,"new":3,method:[3,4],dyaml:[1,4],never:1,here:4,ggg:3,ldyaml:4,path:4,modifi:4,implicit:[0,3],valu:[0,1,3,4],convert:[0,3,4],male:0,loos:1,datetim:0,omap:0,chang:[0,1,3],commonli:4,modul:4,unix:4,subnod:4,instal:4,articl:[0,2],regex:3,from:3,would:[3,4],doubl:0,two:[0,1,3],next:[3,4],few:1,call:[3,4],msg:3,type:[0,1,2,3,4],tell:4,more:[0,4],phone:0,known:[1,2,4],hold:3,must:[3,4],addrepresent:3,word:4,alia:[0,1],work:1,itself:3,can:[0,1,3,4],learn:4,purpos:3,root:[3,4],overrid:3,want:3,stream:[0,1],give:4,process:3,templat:3,topic:3,tag:[0,1,3,2],tab:1,serial:[0,3],addconstructorxxx:3,cours:3,multipl:[0,1],newlin:0,quot:[0,1],getting_start:4,how:[3,4],foreach:[3,4],answer:[0,4],instead:0,simpl:[0,3,4],css:3,map:[0,1,2,3,4],mar:4,clone:0,variant:1,befor:3,ff0000:3,uint:3,mai:1,end:[0,1,3],data:[0,1,2,3,4],welcom:[2,4],ani:[0,3,4],stdio:4,explicit:[0,3],correspond:3,ambigu:1,caus:1,inform:[0,4],green:[0,3],allow:[0,1],first:[0,2,3,4],order:[1,4],over:4,move:4,orang:3,becaus:1,veri:1,hierarchi:0,still:[0,1],paramet:3,write:4,style:[0,4],precondit:3,yaml:[0,1,2,3,4],window:4,complex:[0,3],main:[3,4],might:[0,1,3,4],easier:0,them:[0,1,3,4],"float":[0,3],"return":[3,4],thei:[0,1,3,4],python:0,auto:3,now:[1,3,4],introduct:[0,4],name:[0,3],separ:0,each:[0,3],found:[3,4],went:3,complet:3,mean:[1,3],compil:[3,4],unequ:[1,3],idea:4,"static":3,expect:[3,4],our:[3,4],extract:4,out:[0,3],space:0,content:[1,3,4],rel:4,"0123456789abcdefabcdef":3,ref:3,red:[0,3],difficulti:1,advanc:0,"0123456789abcdef":3,base:[0,3],dictionari:0,put:[3,4],org:[1,3],"byte":1,thrown:4,pyyaml:[0,1],indent:[0,1],could:[3,4],keep:4,length:3,yamlcoloninflowcontext:1,confus:1,assign:0,radeon:0,oper:[0,3,4],rang:3,onc:[0,1],arrai:[0,1,3,4],restrict:1,unlik:0,alreadi:[3,4],done:3,stabl:4,miss:3,addconstructormap:3,size:0,differ:[1,2,3,4],dump:[3,4],script:4,associ:[0,1,4],addimplicitresolv:3,system:[0,4],construct:[0,3],gpu:0,white:3,conveni:0,"final":[3,4],store:[0,3],adher:1,consol:4,option:[0,4],especi:0,ishexdigit:3,specifi:[0,3,4],pars:[0,3,4],somewhat:0,exactli:4,than:1,serv:4,remov:0,structur:[0,1],charact:[0,1,3],project:[2,4],str:[0,3],were:3,posit:3,argument:3,packag:[3,4],have:[0,3,4],tabl:0,need:[0,1,3,4],"null":0,lib:4,alias:[0,1,2],constructcolormap:3,note:[3,4],also:[0,3,4],read:[0,3,4],take:3,which:[0,1,3],brace:0,channel:3,uppercas:3,blue:[0,3],begin:[0,1],normal:4,previou:3,most:[0,3,4],regular:3,pair:[0,3],"class":[1,3],opequ:3,don:[1,3,4],later:3,flow:[0,1],doe:[0,1,4],bracket:0,cortex:0,fact:0,ldc:4,cdc:4,alphanumer:1,syntax:[0,2],identifi:[0,3],find:[3,4],onli:[3,4],explicitli:[0,3],just:[3,4],explain:4,should:[1,3,4],meant:4,std:[3,4],get:[2,3,4],express:3,cannot:[1,4],report:3,requir:3,whether:3,common:0,contain:[0,1,3,4],where:[0,3,4],wiki:1,set:[0,2,3,4],seq:0,see:[0,1,3],rgb:3,result:3,fail:1,close:1,athlon:0,representscalar:3,wikipedia:0,written:4,between:[0,1,2],"import":4,altern:3,accord:1,kei:[0,1,4],both:3,last:0,howev:[0,3],equal:3,comment:[0,4],etc:3,tutori:[2,3,4],context:[0,1],load:[1,3,4],color:[0,3],hyphen:0,loader:[3,4],colon:0,suppli:3,respect:3,addconstructorscalar:3,bbb:3,empti:0,sinc:3,json:0,basic:4,xxx:[3,4],anywher:0,assert:3,togeth:3,input:[3,4],"catch":3,multi:0,therefor:[1,3],look:4,plain:[0,1,3],ffff00:3,defin:[0,3],ain:0,error:4,anchor:[0,1,2],readi:3,non:[0,3],archiv:4,tediou:3,ascii:[1,3],dumper:[3,4],disabl:3,clearli:1,same:[0,1,3,4],check:[3,4],member:3,binari:0,instanc:[1,3,4],timestamp:0,android:0,document:[0,1,2,3,4],difficult:0,http:1,nest:0,user:[0,3],nodeexcept:3,markup:0,well:3,constructorexcept:3,person:0,exampl:[3,4],command:4,thi:[0,1,3,4],everyth:3,left:0,explan:4,systim:0,newest:4,execut:4,less:1,paragraph:0,gdc:4,human:0,yet:4,languag:[0,4],struct:[1,3,4],libdyaml:4,interptet:1,except:4,constructcolorscalar:3,add:[3,4],other:[1,4],els:0,match:3,build:4,real:0,format:[0,3,4],handl:[1,3],know:3,world:4,recurs:[0,1],tolow:3,like:3,success:3,arbitrari:3,resolv:[0,2,3],integ:[0,3,4],arthur:0,api:[2,3,4],singl:[0,1],output:[3,4],unnecessari:1,right:1,often:3,linux:[0,4],some:[0,1,3,4],guarante:3,ubyt:[0,3],librari:4,representcolor:3,lead:1,though:4,unord:1,condit:3,either:[0,3,4],object:3,run:4,acronym:0,usag:4,immut:3,rrggbb:3,unicod:1,chapter:0,comparison:3,about:[1,4],rare:1,usedefaultrepresent:3,page:0,constructor:[2,3],fals:3,produc:4,block:0,subset:0,within:1,encod:1,automat:4,bsd:0,mark:[0,1,3],your:[2,3,4],wai:[1,3],support:[0,1,3],question:0,"long":0,custom:[0,2,3],writeln:[3,4],start:[0,2,3,4],"function":3,form:3,continu:0,link:4,line:0,conclus:4,"throw":[3,4],dmd:4,consist:0,possibl:[0,1,3,4],"default":[0,3],displai:4,until:0,directori:[3,4],problem:1,similar:[0,4],featur:[0,1],creat:[0,3,4],"int":[0,3,4],cover:4,dure:3,parser:[0,4],doesn:4,repres:[0,3,4],"char":3,exist:4,file:[1,3,4],yamlnul:0,isdigit:3,dent:0,simplest:4,probabl:0,hex:3,when:[3,4],detail:[0,1],invalid:3,valid:1,bool:0,futur:[0,1],test:3,you:[0,3,4],node:[0,3,4],resolut:[0,3],sequenc:[0,2,3,4],consid:[1,3],debian:0,reduc:0,longer:3,home:4,rule:1,hello:4,ignor:1,far:3,escap:0,cpu:0},objtypes:{},titles:["YAML syntax","Differences between D:YAML and the YAML specification","Welcome to D:YAML documentation!","Custom YAML data types","Getting started"],objnames:{},filenames:["tutorials/yaml_syntax","articles/spec_differences","index","tutorials/custom_types","tutorials/getting_started"]}) \ No newline at end of file +Search.setIndex({objects:{},terms:{represent:[2,3],all:[1,3,4],code:[0,1,3,4],representmap:3,scalar:[0,1,2,3,4],follow:[3,4],decid:3,depend:[0,3],show:[0,3],readabl:0,specif:[0,1,3,2],representsequ:3,program:4,digit:[3,4],sourc:[3,4],everi:3,string:[0,3,4],powervr:0,"void":[3,4],phobo:1,ident:3,failur:3,yamlexcept:[3,4],implicitli:[0,3],implement:[1,3],tri:1,gender:0,list:[0,1,2],iter:4,"try":[3,4],item:0,refer:[0,3],slower:0,past:4,fold:0,second:[0,4],design:0,pass:3,download:4,rrr:3,even:[1,4],index:4,what:3,appear:1,compar:3,cast:3,preserv:[0,4],section:3,current:4,version:4,"new":3,method:[3,4],dyaml:[1,4],never:1,here:4,ggg:3,ldyaml:4,path:4,modifi:4,implicit:[0,3],valu:[0,1,3,4],convert:[0,3,4],male:0,loos:1,datetim:0,omap:0,chang:[0,1,3],commonli:4,modul:4,unix:4,subnod:4,instal:4,articl:[0,2],regex:3,from:3,would:[3,4],doubl:0,two:[0,1,3],next:[3,4],few:1,call:[3,4],msg:3,type:[0,1,2,3,4],tell:4,more:[0,4],phone:0,known:[1,2,4],hold:3,must:[3,4],addrepresent:3,word:4,alia:[0,1],work:1,itself:3,can:[0,1,3,4],learn:4,purpos:3,root:[3,4],overrid:3,want:3,stream:[0,1],give:4,process:3,templat:3,topic:3,tag:[0,1,3,2],tab:1,serial:[0,3],addconstructorxxx:3,cours:3,multipl:[0,1],newlin:0,quot:[0,1],getting_start:4,how:[3,4],foreach:[3,4],answer:[0,4],instead:0,simpl:[0,3,4],css:3,map:[0,1,2,3,4],mar:4,clone:0,variant:1,befor:3,ff0000:3,uint:3,mai:1,end:[0,1,3],data:[0,1,2,3,4],welcom:[2,4],ani:[0,3,4],stdio:4,explicit:[0,3],correspond:3,ambigu:1,caus:1,inform:[0,4],green:[0,3],allow:[0,1],first:[0,2,3,4],order:[1,4],over:4,move:4,orang:3,becaus:1,veri:1,hierarchi:0,still:[0,1],paramet:3,write:4,style:[0,4],precondit:3,yaml:[0,1,2,3,4],window:4,complex:[0,3],main:[3,4],might:[0,1,3,4],easier:0,them:[0,1,3,4],good:3,"return":[3,4],thei:[0,1,3,4],python:0,auto:3,now:[1,3,4],introduct:[0,4],name:0,separ:0,each:[0,3],found:[3,4],went:3,complet:3,mean:[1,3],compil:[3,4],unequ:[1,3],idea:4,"static":3,expect:[3,4],our:[3,4],extract:4,out:[0,3],space:0,content:[1,3,4],rel:4,"0123456789abcdefabcdef":3,ref:3,red:[0,3],difficulti:1,advanc:0,"0123456789abcdef":3,base:[0,3],dictionari:0,put:[3,4],org:[1,3],"byte":[1,3],thrown:4,pyyaml:[0,1],indent:[0,1],could:[3,4],keep:4,length:3,yamlcoloninflowcontext:1,confus:1,assign:0,radeon:0,oper:[0,3,4],rang:3,onc:[0,1],arrai:[0,1,3,4],sometim:3,restrict:1,unlik:0,alreadi:[3,4],done:3,stabl:4,miss:3,addconstructormap:3,size:0,differ:[1,2,3,4],dump:[3,4],script:4,associ:[0,1,4],addimplicitresolv:3,system:[0,4],construct:[0,3],gpu:0,white:3,conveni:0,"final":[3,4],store:[0,3],adher:1,consol:4,option:[0,4],especi:0,ishexdigit:3,specifi:[0,3,4],pars:[0,3,4],somewhat:0,exactli:4,than:1,serv:4,remov:0,structur:[0,1],charact:[0,1,3],project:[2,4],str:[0,3],were:3,posit:3,argument:3,packag:[3,4],have:[0,3,4],tabl:0,need:[0,1,3,4],"null":0,lib:4,alias:[0,1,2],constructcolormap:3,note:[3,4],also:[0,3,4],read:[0,3,4],take:3,which:[0,1,3],brace:0,channel:3,uppercas:3,blue:[0,3],begin:[0,1],normal:4,previou:3,most:[0,3,4],regular:3,pair:[0,3],"class":[1,3],opequ:3,don:[1,3,4],later:3,flow:[0,1],doe:[0,1,4],bracket:0,cortex:0,fact:0,ldc:4,cdc:4,alphanumer:1,syntax:[0,2],identifi:[0,3],find:[3,4],onli:[3,4],explicitli:[0,3],just:[3,4],explain:4,should:[1,3,4],meant:4,std:[3,4],get:[2,3,4],express:3,cannot:[1,4],report:3,requir:3,whether:3,common:0,contain:[0,1,3,4],where:[0,3,4],wiki:1,set:[0,2,3,4],seq:0,"float":[0,3],see:[0,1,3],rgb:3,result:3,fail:1,close:1,athlon:0,representscalar:3,wikipedia:0,written:4,between:[0,1,2],"import":4,accord:1,kei:[0,1,4],both:3,last:0,howev:[0,3],equal:3,comment:[0,4],etc:3,tutori:[2,3,4],context:[0,1],load:[1,3,4],color:[0,3],hyphen:0,loader:[3,4],colon:0,suppli:3,respect:3,addconstructorscalar:3,bbb:3,empti:0,sinc:3,json:0,basic:4,xxx:[3,4],anywher:0,assert:3,togeth:3,input:[3,4],"catch":3,multi:0,therefor:[1,3],look:4,plain:[0,1,3],ffff00:3,defin:[0,3],ain:0,error:4,anchor:[0,1,2],readi:3,non:[0,3],archiv:4,tediou:3,ascii:[1,3],dumper:[3,4],disabl:3,clearli:1,make:3,same:[0,1,3,4],check:[3,4],member:3,binari:0,instanc:[1,3,4],timestamp:0,android:0,document:[0,1,2,3,4],difficult:0,http:1,nest:0,user:[0,3],nodeexcept:3,markup:0,well:3,constructorexcept:3,person:0,exampl:[3,4],command:4,thi:[0,1,3,4],everyth:3,left:0,explan:4,systim:0,newest:4,execut:4,less:1,paragraph:0,gdc:4,human:0,yet:4,languag:[0,4],struct:[1,3,4],libdyaml:4,interptet:1,except:4,constructcolorscalar:3,add:[3,4],other:[1,4],els:0,match:3,build:4,real:0,format:[0,3,4],handl:[1,3],know:3,world:4,recurs:[0,1],tolow:3,like:3,success:3,arbitrari:3,resolv:[0,2,3],integ:[0,3,4],arthur:0,api:[2,3,4],singl:[0,1],output:[3,4],unnecessari:1,right:1,linux:[0,4],some:[0,1,3,4],guarante:3,ubyt:[0,3],librari:4,representcolor:3,lead:1,though:4,per:3,unord:1,condit:3,either:[0,3,4],object:3,run:4,acronym:0,usag:4,immut:3,rrggbb:3,unicod:1,chapter:0,comparison:3,about:[1,4],rare:1,usedefaultrepresent:3,page:0,constructor:[2,3],fals:3,produc:4,block:0,subset:0,within:1,encod:1,automat:4,bsd:0,mark:[0,1,3],your:[2,3,4],wai:[1,3],support:[0,1,3],question:0,"long":0,custom:[0,2,3],writeln:[3,4],start:[0,2,3,4],"function":3,form:3,continu:0,link:4,line:0,conclus:4,"throw":[3,4],dmd:4,consist:0,possibl:[0,1,3,4],"default":[0,3],displai:4,until:0,directori:[3,4],problem:1,similar:[0,4],featur:[0,1],creat:[0,3,4],"int":[0,4],cover:4,dure:3,parser:[0,4],doesn:4,repres:[0,3,4],"char":3,exist:4,file:[1,3,4],yamlnul:0,isdigit:3,dent:0,simplest:4,probabl:0,hex:3,when:[3,4],detail:[0,1],invalid:3,valid:1,bool:0,futur:[0,1],test:3,you:[0,3,4],node:[0,3,4],resolut:[0,3],sequenc:[0,2,3,4],consid:[1,3],debian:0,reduc:0,longer:3,home:4,rule:1,hello:4,ignor:1,far:3,escap:0,cpu:0},objtypes:{},titles:["YAML syntax","Differences between D:YAML and the YAML specification","Welcome to D:YAML documentation!","Custom YAML data types","Getting started"],objnames:{},filenames:["tutorials/yaml_syntax","articles/spec_differences","index","tutorials/custom_types","tutorials/getting_started"]}) \ No newline at end of file diff --git a/doc/html/tutorials/custom_types.html b/doc/html/tutorials/custom_types.html index 61113c9..bd8b27d 100644 --- a/doc/html/tutorials/custom_types.html +++ b/doc/html/tutorials/custom_types.html @@ -47,26 +47,26 @@

    Custom YAML data types

    -

    Often you might want to serialize complex data types such as classes. You can -use functions to process nodes such as a mapping containing class data members -indexed by name. Alternatively, YAML supports custom data types using -identifiers called tags. That is the topic of this tutorial.

    +

    Sometimes you need to serialize complex data types such as classes. To do this +you could use plain nodes such as mappings with class data members. However, +YAML supports custom types with identifiers called tags. That is the topic of +this tutorial.

    Each YAML node has a tag specifying its type. For instance: strings use the tag tag:yaml.org,2002:str. Tags of most default types are implicitly resolved during parsing, so you don’t need to specify tag for each float, integer, etc. -It is also possible to implicitly resolve custom tags, as we will show later.

    +D:YAML can also implicitly resolve custom tags, as we will show later.

    Constructor

    D:YAML uses the Constructor class to process -each node to hold data type corresponding to its tag. Constructor stores a -function for each supported tag to process it. These functions are supplied by -the user using the addConstructorXXX() methods, where XXX is Scalar, -Sequence or Mapping. Constructor is then passed to Loader, which parses -YAML input.

    +each node to hold data type corresponding to its tag. Constructor stores +functions to process each supported tag. These are supplied by the user using +the addConstructorXXX() methods, where XXX is Scalar, Sequence or +Mapping. Constructor is then passed to Loader, which parses YAML input.

    Struct types have no specific requirements for YAML support. Class types should define the opEquals() operator, as this is used in equality comparisons of nodes. Default class opEquals() compares references, which means two identical -objects might be considered unequal.

    +objects might be considered unequal. (Default struct opEquals() compares +byte-by-byte, sometimes you might want to override that as well.)

    We will implement support for an RGB color type. It is implemented as the following struct:

    struct Color
    @@ -198,10 +198,10 @@ they were loaded as expected.

    Resolver

    -

    Specifying tag for every color value can be tedious. D:YAML can implicitly -resolve scalar tags using regular expressions. This is how default types such as -int are resolved. We will use the Resolver class -to add implicit tag resolution for the Color data type (in its scalar form).

    +

    Specifying tag for every color can be tedious. D:YAML can implicitly resolve +scalar tags using regular expressions. This is how default types are resolved. +We will use the Resolver class to add implicit +tag resolution for the Color data type (in its scalar form).

    We use the addImplicitResolver() method of Resolver, passing the tag, regular expression the scalar must match to resolve to this tag, and a string of possible starting characters of the scalar. Then we pass the Resolver to @@ -242,23 +242,22 @@ D:YAML package.

    Representer

    -

    Now that you know how to load custom data types, it might also be useful to know -how to dump them. D:YAML uses the Representer -class for this purpose.

    +

    Now that you can load custom data types, it might be good to know how to dump +them. D:YAML uses the Representer class for +this purpose.

    Representer processes YAML nodes into plain mapping, sequence or scalar nodes ready for output. Just like with Constructor, this is done by user specified functions. These functions take references to a node to process and to the Representer, and return the processed node.

    Representer functions can be added with the addRepresenter() method. The Representer is then passed to Dumper, which dumps YAML documents. Only one -representer can be added for a type. This is asserted in addRepresenter() -preconditions. By default, the default YAML types already have representer -functions, but you can disable them by constructing Representer with the +function per type can be specified. This is asserted in addRepresenter() +preconditions. Default YAML types already have representer functions specified, +but you can disable them by constructing Representer with the useDefaultRepresenters parameter set to false.

    -

    By default, tags are explicitly specified for all non-default types. If you -want the tags to be implicit, you can pass a Resolver that will resolve them -implicitly. Of course, you will then need to use an identical Resolver when -loading the output.

    +

    By default, tags are explicitly output for all non-default types. To make dumped +tags implicit, you can pass a Resolver that will resolve them implicitly. Of +course, you will need to use an identical Resolver when loading the output.

    With the following code, we will add support for dumping the our Color type.

    Node representColor(ref Node node, Representer representer)
     {
    @@ -282,8 +281,8 @@ loading the output.

    First we get the Color from the node. Then we convert it to a string with the CSS-like format we’ve used before. Finally, we use the representScalar() -method of Representer to get a scalar node ready for output. -There are corresponding representMapping() and representSequence() methods +method of Representer to get a scalar node ready for output. There are +corresponding representMapping() and representSequence() methods as well, with examples in the Resolver API documentation.

    Since a type can only have one representer function, we don’t dump Color both @@ -369,7 +368,7 @@ directory of the D:YAML package.

    diff --git a/doc/html/tutorials/getting_started.html b/doc/html/tutorials/getting_started.html index 097e38d..79c2943 100644 --- a/doc/html/tutorials/getting_started.html +++ b/doc/html/tutorials/getting_started.html @@ -237,7 +237,7 @@ example in the example/getting_st
    diff --git a/doc/html/tutorials/yaml_syntax.html b/doc/html/tutorials/yaml_syntax.html index fd99d4d..ea682f5 100644 --- a/doc/html/tutorials/yaml_syntax.html +++ b/doc/html/tutorials/yaml_syntax.html @@ -330,7 +330,7 @@ Some of these might change in the future (especially !!map and !!set).

    diff --git a/docsrc/tutorials/custom_types.rst b/docsrc/tutorials/custom_types.rst index 35d48e0..9b3eaf5 100644 --- a/docsrc/tutorials/custom_types.rst +++ b/docsrc/tutorials/custom_types.rst @@ -2,15 +2,15 @@ Custom YAML data types ====================== -Often you might want to serialize complex data types such as classes. You can -use functions to process nodes such as a mapping containing class data members -indexed by name. Alternatively, YAML supports custom data types using -identifiers called *tags*. That is the topic of this tutorial. +Sometimes you need to serialize complex data types such as classes. To do this +you could use plain nodes such as mappings with class data members. However, +YAML supports custom types with identifiers called *tags*. That is the topic of +this tutorial. Each YAML node has a tag specifying its type. For instance: strings use the tag ``tag:yaml.org,2002:str``. Tags of most default types are *implicitly resolved* during parsing, so you don't need to specify tag for each float, integer, etc. -It is also possible to implicitly resolve custom tags, as we will show later. +D:YAML can also implicitly resolve custom tags, as we will show later. ----------- @@ -18,16 +18,16 @@ Constructor ----------- D:YAML uses the `Constructor <../api/dyaml.constructor.html>`_ class to process -each node to hold data type corresponding to its tag. *Constructor* stores a -function for each supported tag to process it. These functions are supplied by -the user using the *addConstructorXXX()* methods, where *XXX* is *Scalar*, -*Sequence* or *Mapping*. *Constructor* is then passed to *Loader*, which parses -YAML input. +each node to hold data type corresponding to its tag. *Constructor* stores +functions to process each supported tag. These are supplied by the user using +the *addConstructorXXX()* methods, where *XXX* is *Scalar*, *Sequence* or +*Mapping*. *Constructor* is then passed to *Loader*, which parses YAML input. Struct types have no specific requirements for YAML support. Class types should define the *opEquals()* operator, as this is used in equality comparisons of nodes. Default class *opEquals()* compares references, which means two identical -objects might be considered unequal. +objects might be considered unequal. (Default struct *opEquals()* compares +byte-by-byte, sometimes you might want to override that as well.) We will implement support for an RGB color type. It is implemented as the following struct: @@ -173,10 +173,10 @@ You can find the source code for what we've done so far in the Resolver -------- -Specifying tag for every color value can be tedious. D:YAML can implicitly -resolve scalar tags using regular expressions. This is how default types such as -int are resolved. We will use the `Resolver <../api/dyaml.resolver.html>`_ class -to add implicit tag resolution for the Color data type (in its scalar form). +Specifying tag for every color can be tedious. D:YAML can implicitly resolve +scalar tags using regular expressions. This is how default types are resolved. +We will use the `Resolver <../api/dyaml.resolver.html>`_ class to add implicit +tag resolution for the Color data type (in its scalar form). We use the *addImplicitResolver()* method of *Resolver*, passing the tag, regular expression the scalar must match to resolve to this tag, and a string of @@ -228,9 +228,9 @@ D:YAML package. Representer ----------- -Now that you know how to load custom data types, it might also be useful to know -how to dump them. D:YAML uses the `Representer <../api/dyaml.representer.html>`_ -class for this purpose. +Now that you can load custom data types, it might be good to know how to dump +them. D:YAML uses the `Representer <../api/dyaml.representer.html>`_ class for +this purpose. *Representer* processes YAML nodes into plain mapping, sequence or scalar nodes ready for output. Just like with *Constructor*, this is done by user specified @@ -239,15 +239,14 @@ functions. These functions take references to a node to process and to the Representer functions can be added with the *addRepresenter()* method. The *Representer* is then passed to *Dumper*, which dumps YAML documents. Only one -representer can be added for a type. This is asserted in *addRepresenter()* -preconditions. By default, the default YAML types already have representer -functions, but you can disable them by constructing *Representer* with the +function per type can be specified. This is asserted in *addRepresenter()* +preconditions. Default YAML types already have representer functions specified, +but you can disable them by constructing *Representer* with the *useDefaultRepresenters* parameter set to false. -By default, tags are explicitly specified for all non-default types. If you -want the tags to be implicit, you can pass a *Resolver* that will resolve them -implicitly. Of course, you will then need to use an identical *Resolver* when -loading the output. +By default, tags are explicitly output for all non-default types. To make dumped +tags implicit, you can pass a *Resolver* that will resolve them implicitly. Of +course, you will need to use an identical *Resolver* when loading the output. With the following code, we will add support for dumping the our Color type. @@ -274,10 +273,10 @@ With the following code, we will add support for dumping the our Color type. First we get the *Color* from the node. Then we convert it to a string with the CSS-like format we've used before. Finally, we use the *representScalar()* -method of *Representer* to get a scalar node ready for output. -There are corresponding *representMapping()* and *representSequence()* methods +method of *Representer* to get a scalar node ready for output. There are +corresponding *representMapping()* and *representSequence()* methods as well, with examples in the -`Resolver API documentation <../api/dyaml.resolver.html>`_. +`Resolver API documentation <../api/dyaml.resolver.html>`_. Since a type can only have one representer function, we don't dump *Color* both in the scalar and mapping formats we've used before. However, you can decide to diff --git a/dyaml/representer.d b/dyaml/representer.d index 1ebaf86..48e01a8 100644 --- a/dyaml/representer.d +++ b/dyaml/representer.d @@ -82,13 +82,13 @@ final class Representer representers_ = null; } - ///Set default style for scalars. Invalid means the style is chosen automatically. + ///Set default _style for scalars. Invalid means the _style is chosen automatically. @property void defaultScalarStyle(ScalarStyle style) { defaultScalarStyle_ = style; } - ///Set default style for collections. Invalid means the style is chosen automatically. + ///Set default _style for collections. Invalid means the _style is chosen automatically. @property void defaultCollectionStyle(CollectionStyle style) { defaultCollectionStyle_ = style; @@ -212,7 +212,8 @@ final class Representer * * Params: tag = Tag of the _scalar. * scalar = Scalar value. - * style = Style of the scalar (will be default if invalid). + * style = Style of the _scalar. If invalid, default _style will be used. + * If the node was loaded before, previous _style will always be used. * * Returns: The represented node. * @@ -228,6 +229,7 @@ final class Representer * auto value = node.as!MyStruct; * auto scalar = format(value.x, ":", value.y, ":", value.z); * return representer.representScalar("!mystruct.tag", scalar); + * * } * -------------------- */ @@ -246,7 +248,8 @@ final class Representer * * Params: tag = Tag of the sequence. * sequence = Sequence of nodes. - * style = Style of the sequence (will be default if invalid). + * style = Style of the _sequence. If invalid, default _style will be used. + * If the node was loaded before, previous _style will always be used. * * Returns: The represented node. * @@ -263,7 +266,9 @@ final class Representer * { * auto value = node.as!MyStruct; * auto nodes = [Node(value.x), Node(value.y), Node(value.z)]; - * return representer.representSequence("!mystruct.tag", nodes); + * //use flow style + * return representer.representSequence("!mystruct.tag", nodes, + * CollectionStyle.Flow); * } * -------------------- */ @@ -302,7 +307,8 @@ final class Representer * * Params: tag = Tag of the mapping. * pairs = Key-value _pairs of the mapping. - * style = Style of the mapping (will be default if invalid). + * style = Style of the _mapping. If invalid, default _style will be used. + * If the node was loaded before, previous _style will always be used. * * Returns: The represented node. *