diff --git a/autoddoc.cfg b/autoddoc.cfg index e21ffe1..7498db8 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 +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 [DDOC] # Command to use to generate the documentation. diff --git a/doc/doctrees/environment.pickle b/doc/doctrees/environment.pickle index adc89ed..ecb58be 100644 Binary files a/doc/doctrees/environment.pickle and b/doc/doctrees/environment.pickle differ diff --git a/doc/doctrees/tutorials/custom_types.doctree b/doc/doctrees/tutorials/custom_types.doctree index 056c1d8..98e74fb 100644 Binary files a/doc/doctrees/tutorials/custom_types.doctree and b/doc/doctrees/tutorials/custom_types.doctree differ diff --git a/doc/doctrees/tutorials/getting_started.doctree b/doc/doctrees/tutorials/getting_started.doctree index 18d2b4c..c535cb0 100644 Binary files a/doc/doctrees/tutorials/getting_started.doctree and b/doc/doctrees/tutorials/getting_started.doctree differ diff --git a/doc/html/_sources/tutorials/custom_types.txt b/doc/html/_sources/tutorials/custom_types.txt index 389abdc..35d48e0 100644 --- a/doc/html/_sources/tutorials/custom_types.txt +++ b/doc/html/_sources/tutorials/custom_types.txt @@ -54,7 +54,7 @@ of these functions: Color constructColorScalar(Mark start, Mark end, ref Node node) { - string value = node.get!string; + string value = node.as!string; if(value.length != 6) { @@ -93,9 +93,9 @@ of these functions: //Might throw if a value is missing is not an integer, or is out of range. try { - r = node["r"].get!ubyte; - g = node["g"].get!ubyte; - b = node["b"].get!ubyte; + r = node["r"].as!ubyte; + g = node["g"].as!ubyte; + b = node["b"].as!ubyte; } catch(NodeException e) { @@ -143,10 +143,10 @@ Finally, the code to put it all together: auto root = loader.load(); - if(root["scalar-red"].get!Color == red && - root["mapping-red"].get!Color == red && - root["scalar-orange"].get!Color == orange && - root["mapping-orange"].get!Color == orange) + if(root["scalar-red"].as!Color == red && + root["mapping-red"].as!Color == red && + root["scalar-orange"].as!Color == orange && + root["mapping-orange"].as!Color == orange) { writeln("SUCCESS"); return; @@ -162,8 +162,8 @@ Finally, the code to put it all together: First, we create a *Constructor* and pass functions to handle the ``!color`` and ``!color-mapping`` tag. We construct a *Loader* and pass the *Constructor* -to it. We then load the YAML document, and finally, read the colors using -*get()* method to test if they were loaded as expected. +to it. We then load the YAML document, and finally, read the colors to test if +they were loaded as expected. You can find the source code for what we've done so far in the ``examples/constructor`` directory in the D:YAML package. @@ -256,7 +256,7 @@ With the following code, we will add support for dumping the our Color type. Node representColor(ref Node node, Representer representer) { //The node is guaranteed to be Color as we add representer for Color. - Color color = node.get!Color; + Color color = node.as!Color; static immutable hex = "0123456789ABCDEF"; diff --git a/doc/html/_sources/tutorials/getting_started.txt b/doc/html/_sources/tutorials/getting_started.txt index 8e4c7cd..55c451b 100644 --- a/doc/html/_sources/tutorials/getting_started.txt +++ b/doc/html/_sources/tutorials/getting_started.txt @@ -90,7 +90,7 @@ into the file: { writeln(word); } - writeln("The answer is ", root["Answer"].get!int); + writeln("The answer is ", root["Answer"].as!int); //Dump the loaded document to output.yaml. Dumper("output.yaml").dump(root); @@ -115,7 +115,7 @@ possible. mapping (associative array) or a scalar (value). Here the root node is a mapping, and we use the index operator to get subnodes with keys "Hello World" and "Answer". We iterate over the first, as it is a sequence, and use the -*Node.get()* method on the second to get its value as an integer. +*Node.as()* method on the second to read its value as an integer. You can iterate over a mapping or sequence as if it was an associative or normal array. If you try to iterate over a scalar, it will throw a *YAMLException*. @@ -128,9 +128,9 @@ not possible to convert to iterated type, a *YAMLException* is thrown. For instance, if we specified *int* here, we would get an error, as "Hello" cannot be converted to an integer. -The *Node.get()* method is used to get value of a scalar node, allowing to -specify type. D:YAML will try to return the scalar as this type, converting if -needed, throwing *YAMLException* if not possible. +The *Node.as()* method is used to read value of a scalar node as specified type. +D:YAML will try to return the scalar as this type, converting if needed, +throwing *YAMLException* if not possible. Finally we dump the document we just read to ``output.yaml`` with the *Dumper.dump()* method. *Dumper* is a struct used to dump YAML documents. diff --git a/doc/html/api/dyaml.constructor.html b/doc/html/api/dyaml.constructor.html index 117a4b3..63d0eca 100644 --- a/doc/html/api/dyaml.constructor.html +++ b/doc/html/api/dyaml.constructor.html @@ -127,7 +127,7 @@ { //Guaranteed to be string as we construct from scalar. //!mystruct x:y:z - auto parts = node.get!string().split(":"); + auto parts = node.as!string().split(":"); try { return MyStruct(to!int(parts[0]), to!int(parts[1]), to!int(parts[2])); @@ -174,7 +174,7 @@ //!mystruct [x, y, z] try { - return MyStruct(node[0].get!int, node[1].get!int, node[2].get!int); + return MyStruct(node[0].as!int, node[1].as!int, node[2].as!int); } catch(NodeException e) { @@ -218,7 +218,7 @@ //!mystruct {"x": x, "y": y, "z": z} try { - return MyStruct(node["x"].get!int, node["y"].get!int, node["z"].get!int); + return MyStruct(node["x"].as!int, node["y"].as!int, node["z"].as!int); } catch(NodeException e) { diff --git a/doc/html/api/dyaml.dumper.html b/doc/html/api/dyaml.dumper.html index 403281d..2ccf744 100644 --- a/doc/html/api/dyaml.dumper.html +++ b/doc/html/api/dyaml.dumper.html @@ -189,9 +189,11 @@
Example:
Dumper dumper = Dumper("file.yaml"); + string[string] directives; + directives["!short!"] = "tag:long.org,2011:"; //This will emit tags starting with "tag:long.org,2011" //with a "!short!" prefix instead. - dumper.tags("short", "tag:long.org,2011:"); + dumper.tagDirectives(directives); dumper.dump(Node("foo"));diff --git a/doc/html/api/dyaml.loader.html b/doc/html/api/dyaml.loader.html index 89af805..1223a95 100644 --- a/doc/html/api/dyaml.loader.html +++ b/doc/html/api/dyaml.loader.html @@ -149,6 +149,12 @@
Load all YAML documents. +
+This is just a shortcut that iterates over all documents and returns + them all at once. Calling loadAll after iterating over the node or + vice versa will not return any documents, as they have all been parsed + already. +
Returns:Is this node a user defined type?
+Shortcut for get().
+auto node = Node(42); - assert(node.get!int == 42); - assert(node.get!string == "42"); - assert(node.get!double == 42.0); + assert(node.as!int == 42); + assert(node.as!string == "42"); + assert(node.as!double == 42.0);