diff --git a/autoddoc.py b/autoddoc.py index 5f050b9..26f685b 100755 --- a/autoddoc.py +++ b/autoddoc.py @@ -294,7 +294,7 @@ default_css =\ " border: 0.6em solid #cccccc;\n" " background-color: #f6f6f6;\n" " font-size: 0.875em;\n" - " line-height: 1.4em;\n" + " line-height: 1.3em;\n" "}\n" "\n" "div#content li{padding-bottom: .7ex;}\n" diff --git a/doc/doctrees/environment.pickle b/doc/doctrees/environment.pickle index 62f0768..eb0504b 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 7518da8..a523422 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 c535cb0..0f9bf45 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 65853ee..8f6e565 100644 --- a/doc/html/_sources/tutorials/custom_types.txt +++ b/doc/html/_sources/tutorials/custom_types.txt @@ -3,7 +3,7 @@ Custom YAML data types ====================== 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. YAML also +you could use plain nodes such as mappings with classes' fields. YAML also supports custom types with identifiers called *tags*. That is the topic of this tutorial. @@ -23,11 +23,13 @@ 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 - this is used in equality comparisons of -nodes. Default class *opEquals()* compares references, which means two identical -objects might be considered unequal. (Default struct *opEquals()* compares -byte-by-byte, sometimes you might want to override that as well.) +Structs and classes must implement the *opCmp()* operator for YAML support. This +is used for duplicate detection in mappings, sorting and equality comparisons of +nodes. The signature of the operator that must be implemented is +``const int opCmp(ref const MyStruct s)`` for structs where *MyStruct* is the +struct type, and ``int opCmp(Object o)`` for classes. Note that the class +*opCmp()* should not alter the compared values - it is not const for compatibility +reasons. We will implement support for an RGB color type. It is implemented as the following struct: @@ -39,6 +41,14 @@ following struct: ubyte red; ubyte green; ubyte blue; + + const int opCmp(ref const Color c) + { + if(red != c.red) {return red - c.red;} + if(green != c.green){return green - c.green;} + if(blue != c.blue) {return blue - c.blue;} + return 0; + } } First, we need a function to construct our data type. The function will take a diff --git a/doc/html/_sources/tutorials/getting_started.txt b/doc/html/_sources/tutorials/getting_started.txt index 55c451b..5b7ed81 100644 --- a/doc/html/_sources/tutorials/getting_started.txt +++ b/doc/html/_sources/tutorials/getting_started.txt @@ -43,7 +43,7 @@ Do this by typing the following command into the console:: dmd cdc.d -Now you can use CDC to compile D:YAML. +Now compile D:YAML with CDC. To do this on Unix/Linux, use the following command:: ./cdc @@ -101,8 +101,8 @@ into the file: Explanation of the code ^^^^^^^^^^^^^^^^^^^^^^^ -First, we import the *yaml* module. This is the only module you need to import -to use D:YAML - it automatically imports all needed modules. +First, we import the *yaml* module. This is the only D:YAML module you need to +import - it automatically imports all needed modules. Next we load the file using the *Loader.load()* method. *Loader* is a struct used for parsing YAML documents. The *load()* method loads the file as @@ -146,18 +146,18 @@ formatted differently. Comments are not preserved, either. Compiling ^^^^^^^^^ -To compile your project, you must give DMD the directories containing import -modules and the library. You also need to tell it to link with D:YAML. The import -directory should be the D:YAML package directory. You can specify it using the -``-I`` option of DMD. The library directory should be where you put the compiled -D:YAML library. On Unix/Linux you can specify it using the ``-L-L`` option, and -link with D:YAML using the ``-L-l`` option. On Windows, the import directory is -used as the library directory. To link with the library on Windows, just add the -path to it relative to the current directory. +To compile your project, DMD needs to know which directories contain the +imported modules and the library. You also need to tell it to link with D:YAML. +The import directory should be the D:YAML package directory. You can specify it +using the ``-I`` option of DMD. The library directory should point to the +compiled library. On Unix/Linux you can specify it using the ``-L-L`` option, +and link with D:YAML using the ``-L-l`` option. On Windows, the import directory +is used as the library directory. To link with the library on Windows, just add +the path to it relative to the current directory. For example, if you extracted and compiled D:YAML in ``/home/xxx/dyaml``, your project is in ``/home/xxx/dyaml-project``, and you are currently in that -directory, you can compile the project with the following command on Unix/Linux:: +directory, compile the project with the following command on Unix/Linux:: dmd -I../dyaml -L-L../dyaml -L-ldyaml main.d diff --git a/doc/html/api/css/style.css b/doc/html/api/css/style.css index 4dcf993..65dbada 100644 --- a/doc/html/api/css/style.css +++ b/doc/html/api/css/style.css @@ -190,7 +190,7 @@ div#content border: 0.6em solid #cccccc; background-color: #f6f6f6; font-size: 0.875em; - line-height: 1.4em; + line-height: 1.3em; } div#content li{padding-bottom: .7ex;} diff --git a/doc/html/api/dyaml.constructor.html b/doc/html/api/dyaml.constructor.html index f05fd59..e393fbc 100644 --- a/doc/html/api/dyaml.constructor.html +++ b/doc/html/api/dyaml.constructor.html @@ -72,6 +72,8 @@
Each YAML scalar, sequence or mapping has a tag specifying its data type.
Constructor uses user-specifyable functions to create a node of desired
data type from a scalar, sequence or mapping.
+
+
Each of these functions is associated with a tag, and can process either
@@ -82,7 +84,7 @@
If a tag is detected with no known constructor function, it is considered an error.
Construct a Constructor.
@@ -107,12 +109,24 @@ Any exception thrown by this function will be caught by D:YAML and its message will be added to a YAMLException that will also tell the user which type failed to construct, and position in the file. +