Merge branch '001_create_documentation' into 'master'
Added docs for the public stuff in fahrplanparser.d and substitution.d fixes #1 . See merge request !3
This commit is contained in:
commit
969df165c5
2 changed files with 17 additions and 0 deletions
|
@ -28,6 +28,11 @@ enum directionXPath = "/m/des";
|
|||
|
||||
public:
|
||||
|
||||
/***********************************
|
||||
* Parses the departure monitor data and returns it as an associative array.
|
||||
* data is expected to contain valid XML as returned by queries sent to http://mobile.defas-fgi.de/beg/.
|
||||
*/
|
||||
|
||||
auto parsedFahrplan(in string data)
|
||||
{
|
||||
// dfmt off
|
||||
|
@ -40,6 +45,7 @@ auto parsedFahrplan(in string data)
|
|||
// dfmt on
|
||||
}
|
||||
|
||||
///
|
||||
@system unittest
|
||||
{
|
||||
import std.array : array;
|
||||
|
|
|
@ -6,6 +6,10 @@ import std.traits : Parameters;
|
|||
|
||||
public:
|
||||
|
||||
/***********************************
|
||||
* Loads a substitution dictonary from a file.
|
||||
*/
|
||||
|
||||
void loadSubstitutionFile(alias slurpFun = slurp)(string fileName)
|
||||
if (is(Parameters!(slurpFun!(string, string)) == AliasSeq!(string, const char[])))
|
||||
{
|
||||
|
@ -15,6 +19,7 @@ void loadSubstitutionFile(alias slurpFun = slurp)(string fileName)
|
|||
slurpFun!(string, string)(fileName, `"%s" = "%s"`).each!(pair => map[pair[0]] = pair[1]);
|
||||
}
|
||||
|
||||
///
|
||||
@safe unittest
|
||||
{
|
||||
import std.typecons : Tuple, tuple;
|
||||
|
@ -65,11 +70,17 @@ void loadSubstitutionFile(alias slurpFun = slurp)(string fileName)
|
|||
assert(map["Text in"] == "wird durch diesen ersetzt");
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* Substitutes a string with its corresponding replacement, if one is available.
|
||||
* Otherwise just returns the original string.
|
||||
*/
|
||||
|
||||
auto substitute(string s) @safe nothrow
|
||||
{
|
||||
return s in map ? map[s] : s;
|
||||
}
|
||||
|
||||
///
|
||||
@safe unittest
|
||||
{
|
||||
map[""] = "";
|
||||
|
|
Loading…
Reference in a new issue