Merge pull request #1328 from 9rnsr/fix10230

Issue 10230 - Duplicated buttons for runnable examples
This commit is contained in:
monarch dodra 2013-08-31 02:50:17 -07:00
commit aa3b13ce49
3 changed files with 72 additions and 155 deletions

View file

@ -25,14 +25,10 @@ $(D opApply) function $(D r). Note that narrow strings are handled as
a special case in an overload. a special case in an overload.
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
auto a = array([1, 2, 3, 4, 5][]); auto a = array([1, 2, 3, 4, 5][]);
assert(a == [ 1, 2, 3, 4, 5 ]); assert(a == [ 1, 2, 3, 4, 5 ]);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
ForeachType!Range[] array(Range)(Range r) ForeachType!Range[] array(Range)(Range r)
if (isIterable!Range && !isNarrowString!Range) if (isIterable!Range && !isNarrowString!Range)
@ -230,16 +226,12 @@ Returns a newly allocated associative array out of elements of the input range,
which must be a range of tuples (Key, Value). which must be a range of tuples (Key, Value).
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
auto a = assocArray(zip([0, 1, 2], ["a", "b", "c"])); auto a = assocArray(zip([0, 1, 2], ["a", "b", "c"]));
assert(a == [0:"a", 1:"b", 2:"c"]); assert(a == [0:"a", 1:"b", 2:"c"]);
auto b = assocArray([ tuple("foo", "bar"), tuple("baz", "quux") ]); auto b = assocArray([ tuple("foo", "bar"), tuple("baz", "quux") ]);
assert(b == ["foo":"bar", "baz":"quux"]); assert(b == ["foo":"bar", "baz":"quux"]);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
auto assocArray(Range)(Range r) auto assocArray(Range)(Range r)
@ -312,8 +304,6 @@ array. In this case sizes may be specified for any number of dimensions from 1
to the number in $(D T). to the number in $(D T).
Examples: Examples:
$(D_RUN_CODE
$(ARGS
--- ---
double[] arr = uninitializedArray!(double[])(100); double[] arr = uninitializedArray!(double[])(100);
assert(arr.length == 100); assert(arr.length == 100);
@ -322,7 +312,6 @@ double[][] matrix = uninitializedArray!(double[][])(42, 31);
assert(matrix.length == 42); assert(matrix.length == 42);
assert(matrix[0].length == 31); assert(matrix[0].length == 31);
--- ---
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
auto uninitializedArray(T, I...)(I sizes) auto uninitializedArray(T, I...)(I sizes)
if(allSatisfy!(isIntegral, I)) if(allSatisfy!(isIntegral, I))
@ -415,14 +404,11 @@ the first argument using the dot notation, $(D array.empty) is
equivalent to $(D empty(array)). equivalent to $(D empty(array)).
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
auto a = [ 1, 2, 3 ]; auto a = [ 1, 2, 3 ];
assert(!a.empty); assert(!a.empty);
assert(a[3 .. $].empty); assert(a[3 .. $].empty);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
@property bool empty(T)(in T[] a) @safe pure nothrow @property bool empty(T)(in T[] a) @safe pure nothrow
@ -445,14 +431,11 @@ equivalent to $(D save(array)). The function does not duplicate the
content of the array, it simply returns its argument. content of the array, it simply returns its argument.
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
auto a = [ 1, 2, 3 ]; auto a = [ 1, 2, 3 ];
auto b = a.save; auto b = a.save;
assert(b is a); assert(b is a);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
@property T[] save(T)(T[] a) @safe pure nothrow @property T[] save(T)(T[] a) @safe pure nothrow
@ -469,14 +452,11 @@ $(D popFront) automaticaly advances to the next $(GLOSSARY code
point). point).
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
int[] a = [ 1, 2, 3 ]; int[] a = [ 1, 2, 3 ];
a.popFront(); a.popFront();
assert(a == [ 2, 3 ]); assert(a == [ 2, 3 ]);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
void popFront(T)(ref T[] a) void popFront(T)(ref T[] a)
@ -573,14 +553,11 @@ popFront) automaticaly eliminates the last $(GLOSSARY code point).
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
int[] a = [ 1, 2, 3 ]; int[] a = [ 1, 2, 3 ];
a.popBack(); a.popBack();
assert(a == [ 1, 2 ]); assert(a == [ 1, 2 ]);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
void popBack(T)(ref T[] a) void popBack(T)(ref T[] a)
@ -645,13 +622,10 @@ dchar).
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
int[] a = [ 1, 2, 3 ]; int[] a = [ 1, 2, 3 ];
assert(a.front == 1); assert(a.front == 1);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
@property ref T front(T)(T[] a) @property ref T front(T)(T[] a)
if (!isNarrowString!(T[]) && !is(T[] == void[])) if (!isNarrowString!(T[]) && !is(T[] == void[]))
@ -690,13 +664,10 @@ back) automaticaly returns the last $(GLOSSARY code point) as a $(D
dchar). dchar).
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
int[] a = [ 1, 2, 3 ]; int[] a = [ 1, 2, 3 ];
assert(a.back == 3); assert(a.back == 3);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
@property ref T back(T)(T[] a) if (!isNarrowString!(T[])) @property ref T back(T)(T[] a) if (!isNarrowString!(T[]))
{ {
@ -735,8 +706,6 @@ values referred by them. If $(D r1) and $(D r2) have an overlapping
slice, returns that slice. Otherwise, returns the null slice. slice, returns that slice. Otherwise, returns the null slice.
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
int[] a = [ 10, 11, 12, 13, 14 ]; int[] a = [ 10, 11, 12, 13, 14 ];
int[] b = a[1 .. 3]; int[] b = a[1 .. 3];
@ -745,7 +714,6 @@ b = b.dup;
// overlap disappears even though the content is the same // overlap disappears even though the content is the same
assert(overlap(a, b).empty); assert(overlap(a, b).empty);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) @trusted pure nothrow inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) @trusted pure nothrow
{ {
@ -816,15 +784,12 @@ it's commented out.
must be an input range or a single item) inserted at position $(D pos). must be an input range or a single item) inserted at position $(D pos).
Examples: Examples:
$(D_RUN_CODE
$(ARGS
-------------------- --------------------
int[] a = [ 1, 2, 3, 4 ]; int[] a = [ 1, 2, 3, 4 ];
auto b = a.insert(2, [ 1, 2 ]); auto b = a.insert(2, [ 1, 2 ]);
assert(a == [ 1, 2, 3, 4 ]); assert(a == [ 1, 2, 3, 4 ]);
assert(b == [ 1, 2, 1, 2, 3, 4 ]); assert(b == [ 1, 2, 1, 2, 3, 4 ]);
-------------------- --------------------
), $(ARGS), $(ARGS), $(ARGS import std.array;))
+/ +/
T[] insert(T, Range)(T[] array, size_t pos, Range stuff) T[] insert(T, Range)(T[] array, size_t pos, Range stuff)
if(isInputRange!Range && if(isInputRange!Range &&
@ -937,8 +902,6 @@ private void copyBackwards(T)(T[] src, T[] dest)
implicitly convertible items) in $(D array) at position $(D pos). implicitly convertible items) in $(D array) at position $(D pos).
Example: Example:
$(D_RUN_CODE
$(ARGS
--- ---
int[] a = [ 1, 2, 3, 4 ]; int[] a = [ 1, 2, 3, 4 ];
a.insertInPlace(2, [ 1, 2 ]); a.insertInPlace(2, [ 1, 2 ]);
@ -946,7 +909,6 @@ assert(a == [ 1, 2, 1, 2, 3, 4 ]);
a.insertInPlace(3, 10u, 11); a.insertInPlace(3, 10u, 11);
assert(a == [ 1, 2, 1, 10, 11, 2, 3, 4]); assert(a == [ 1, 2, 1, 10, 11, 2, 3, 4]);
--- ---
), $(ARGS), $(ARGS), $(ARGS import std.array;))
+/ +/
void insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff) void insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff)
if(!isSomeString!(T[]) if(!isSomeString!(T[])
@ -1416,13 +1378,10 @@ unittest
Splits a string by whitespace. Splits a string by whitespace.
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
auto a = " a bcd ef gh "; auto a = " a bcd ef gh ";
assert(equal(splitter(a), ["", "a", "bcd", "ef", "gh"][])); assert(equal(splitter(a), ["", "a", "bcd", "ef", "gh"][]));
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array, std.algorithm: equal;))
*/ */
auto splitter(C)(C[] s) auto splitter(C)(C[] s)
if(isSomeString!(C[])) if(isSomeString!(C[]))
@ -1516,8 +1475,6 @@ unittest
$(D sep) as the separator if present. $(D sep) as the separator if present.
Examples: Examples:
$(D_RUN_CODE
$(ARGS
-------------------- --------------------
assert(join(["hello", "silly", "world"], " ") == "hello silly world"); assert(join(["hello", "silly", "world"], " ") == "hello silly world");
assert(join(["hello", "silly", "world"]) == "hellosillyworld"); assert(join(["hello", "silly", "world"]) == "hellosillyworld");
@ -1525,7 +1482,6 @@ assert(join(["hello", "silly", "world"]) == "hellosillyworld");
assert(join([[1, 2, 3], [4, 5]], [72, 73]) == [1, 2, 3, 72, 73, 4, 5]); assert(join([[1, 2, 3], [4, 5]], [72, 73]) == [1, 2, 3, 72, 73, 4, 5]);
assert(join([[1, 2, 3], [4, 5]]) == [1, 2, 3, 4, 5]); assert(join([[1, 2, 3], [4, 5]]) == [1, 2, 3, 4, 5]);
-------------------- --------------------
), $(ARGS), $(ARGS), $(ARGS import std.array;))
+/ +/
ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, R sep) ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, R sep)
if(isInputRange!RoR && if(isInputRange!RoR &&
@ -1818,15 +1774,12 @@ until then, it's commented out.
array without changing the contents of $(D subject). array without changing the contents of $(D subject).
Examples: Examples:
$(D_RUN_CODE
$(ARGS
-------------------- --------------------
auto a = [ 1, 2, 3, 4 ]; auto a = [ 1, 2, 3, 4 ];
auto b = a.replace(1, 3, [ 9, 9, 9 ]); auto b = a.replace(1, 3, [ 9, 9, 9 ]);
assert(a == [ 1, 2, 3, 4 ]); assert(a == [ 1, 2, 3, 4 ]);
assert(b == [ 1, 9, 9, 9, 4 ]); assert(b == [ 1, 9, 9, 9, 4 ]);
-------------------- --------------------
), $(ARGS), $(ARGS), $(ARGS import std.array;))
+/ +/
T[] replace(T, Range)(T[] subject, size_t from, size_t to, Range stuff) T[] replace(T, Range)(T[] subject, size_t from, size_t to, Range stuff)
if(isInputRange!Range && if(isInputRange!Range &&
@ -1917,14 +1870,11 @@ unittest
shrinks the array as needed. shrinks the array as needed.
Example: Example:
$(D_RUN_CODE
$(ARGS
--- ---
int[] a = [ 1, 2, 3, 4 ]; int[] a = [ 1, 2, 3, 4 ];
a.replaceInPlace(1, 3, [ 9, 9, 9 ]); a.replaceInPlace(1, 3, [ 9, 9, 9 ]);
assert(a == [ 1, 9, 9, 9, 4 ]); assert(a == [ 1, 9, 9, 9, 4 ]);
--- ---
), $(ARGS), $(ARGS), $(ARGS import std.array;))
+/ +/
void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff) void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff)
if(isDynamicArray!Range && if(isDynamicArray!Range &&
@ -2146,8 +2096,6 @@ recommended over $(D a ~= data) when appending many elements because it is more
efficient. efficient.
Example: Example:
$(D_RUN_CODE
$(ARGS
---- ----
auto app = appender!string(); auto app = appender!string();
string b = "abcdefg"; string b = "abcdefg";
@ -2160,7 +2108,6 @@ app2.put(3);
app2.put([ 4, 5, 6 ]); app2.put([ 4, 5, 6 ]);
assert(app2.data == [ 1, 2, 3, 4, 5, 6 ]); assert(app2.data == [ 1, 2, 3, 4, 5, 6 ]);
---- ----
), $(ARGS), $(ARGS), $(ARGS import std.array;))
*/ */
struct Appender(A : T[], T) struct Appender(A : T[], T)
{ {

View file

@ -7,8 +7,6 @@
* RFC 4648 - The Base16, Base32, and Base64 Data Encodings). * RFC 4648 - The Base16, Base32, and Base64 Data Encodings).
* *
* Example: * Example:
* $(D_RUN_CODE
* $(ARGS
* ----- * -----
* ubyte[] data = [0x14, 0xfb, 0x9c, 0x03, 0xd9, 0x7e]; * ubyte[] data = [0x14, 0xfb, 0x9c, 0x03, 0xd9, 0x7e];
* *
@ -18,12 +16,10 @@
* ubyte[] decoded = Base64.decode("FPucA9l+"); * ubyte[] decoded = Base64.decode("FPucA9l+");
* assert(decoded == [0x14, 0xfb, 0x9c, 0x03, 0xd9, 0x7e]); * assert(decoded == [0x14, 0xfb, 0x9c, 0x03, 0xd9, 0x7e]);
* ----- * -----
* ), $(ARGS), $(ARGS), $(ARGS import std.base64;)) *
* Support Range interface using Encoder / Decoder. * Support Range interface using Encoder / Decoder.
* *
* Example: * Example:
* $(D_RUN_CODE
* $(ARGS
* ----- * -----
* // Create MIME Base64 with CRLF, per line 76. * // Create MIME Base64 with CRLF, per line 76.
* File f = File("./text.txt", "r"); * File f = File("./text.txt", "r");
@ -39,7 +35,6 @@
* *
* writeln(mime64.data); * writeln(mime64.data);
* ----- * -----
*), $(ARGS), $(ARGS), $(ARGS import std.base64, std.array, std.stdio: File, writeln;))
* *
* Copyright: Masahiro Nakagawa 2010-. * Copyright: Masahiro Nakagawa 2010-.
* License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). * License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
@ -672,8 +667,6 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* Default $(D Encoder) encodes chunk data. * Default $(D Encoder) encodes chunk data.
* *
* Example: * Example:
*$(D_RUN_CODE
*$(ARGS
* ----- * -----
* File f = File("text.txt", "r"); * File f = File("text.txt", "r");
* scope(exit) f.close(); * scope(exit) f.close();
@ -684,14 +677,11 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* writeln(++line, ". ", encoded); * writeln(++line, ". ", encoded);
* } * }
* ----- * -----
*), $(ARGS), $(ARGS), $(ARGS import std.base64, std.stdio: File, writeln;))
* *
* In addition, You can use $(D Encoder) that returns encoded single character. * In addition, You can use $(D Encoder) that returns encoded single character.
* This $(D Encoder) performs Range-based and lazy encoding. * This $(D Encoder) performs Range-based and lazy encoding.
* *
* Example: * Example:
*$(D_RUN_CODE
*$(ARGS
* ----- * -----
* ubyte[] data = cast(ubyte[]) "0123456789"; * ubyte[] data = cast(ubyte[]) "0123456789";
* *
@ -701,7 +691,6 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* writeln(encoded); * writeln(encoded);
* } * }
* ----- * -----
*), $(ARGS), $(ARGS), $(ARGS import std.base64, std.stdio: writeln;))
* *
* Params: * Params:
* range = an $(D InputRange) to iterate. * range = an $(D InputRange) to iterate.
@ -1357,22 +1346,17 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* Default $(D Decoder) decodes chunk data. * Default $(D Decoder) decodes chunk data.
* *
* Example: * Example:
*$(D_RUN_CODE
*$(ARGS
* ----- * -----
* foreach (decoded; Base64.decoder(stdin.byLine())) * foreach (decoded; Base64.decoder(stdin.byLine()))
* { * {
* writeln(decoded); * writeln(decoded);
* } * }
* ----- * -----
*), $(ARGS FPucA9l+), $(ARGS), $(ARGS import std.base64, std.stdio;))
* *
* In addition, You can use $(D Decoder) that returns decoded single character. * In addition, You can use $(D Decoder) that returns decoded single character.
* This $(D Decoder) performs Range-based and lazy decoding. * This $(D Decoder) performs Range-based and lazy decoding.
* *
* Example: * Example:
*$(D_RUN_CODE
*$(ARGS
* ----- * -----
* auto encoded = Base64.encoder(cast(ubyte[])"0123456789"); * auto encoded = Base64.encoder(cast(ubyte[])"0123456789");
* foreach (n; map!q{a - '0'}(Base64.decoder(encoded))) * foreach (n; map!q{a - '0'}(Base64.decoder(encoded)))
@ -1380,8 +1364,6 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* writeln(n); * writeln(n);
* } * }
* ----- * -----
*), $(ARGS), $(ARGS), $(ARGS import std.base64, std.stdio: writeln;
*import std.algorithm: map;))
* *
* NOTE: * NOTE:
* If you use $(D ByChunk), chunk-size should be the multiple of 4. * If you use $(D ByChunk), chunk-size should be the multiple of 4.

View file

@ -13,8 +13,6 @@
* additional features specific to in-process messaging. * additional features specific to in-process messaging.
* *
* Synposis: * Synposis:
*$(D_RUN_CODE
*$(ARGS
* --- * ---
* import std.stdio; * import std.stdio;
* import std.concurrency; * import std.concurrency;
@ -45,7 +43,6 @@
* writeln("Successfully printed number."); * writeln("Successfully printed number.");
* } * }
* --- * ---
*), $(ARGS), $(ARGS), $(ARGS))
* *
* Copyright: Copyright Sean Kelly 2009 - 2010. * Copyright: Copyright Sean Kelly 2009 - 2010.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
@ -429,8 +426,6 @@ private template isSpawnable(F, T...)
* threads. * threads.
* *
* Example: * Example:
*$(D_RUN_CODE
*$(ARGS
* --- * ---
* import std.stdio, std.concurrency; * import std.stdio, std.concurrency;
* *
@ -455,7 +450,6 @@ private template isSpawnable(F, T...)
* auto tid2 = spawn(&f2, str.dup); * auto tid2 = spawn(&f2, str.dup);
* } * }
* --- * ---
*), $(ARGS), $(ARGS), $(ARGS))
*/ */
Tid spawn(F, T...)( F fn, T args ) Tid spawn(F, T...)( F fn, T args )
if ( isSpawnable!(F, T) ) if ( isSpawnable!(F, T) )
@ -623,8 +617,6 @@ private void _send(T...)( MsgType type, Tid tid, T vals )
* sent. * sent.
* *
* Example: * Example:
*$(D_RUN_CODE
*$(ARGS
* --- * ---
* import std.stdio; * import std.stdio;
* import std.variant; * import std.variant;
@ -645,7 +637,6 @@ private void _send(T...)( MsgType type, Tid tid, T vals )
* send(tid, 42); * send(tid, 42);
* } * }
* --- * ---
*), $(ARGS), $(ARGS), $(ARGS))
*/ */
void receive(T...)( T ops ) void receive(T...)( T ops )
{ {
@ -706,11 +697,9 @@ private template receiveOnlyRet(T...)
* the message will be packed into a $(XREF typecons, Tuple). * the message will be packed into a $(XREF typecons, Tuple).
* *
* Example: * Example:
*$(D_RUN_CODE
*$(ARGS
* --- * ---
* import std.concurrency; * import std.concurrency;
*
* void spawnedFunc() * void spawnedFunc()
* { * {
* auto msg = receiveOnly!(int, string)(); * auto msg = receiveOnly!(int, string)();
@ -724,7 +713,6 @@ private template receiveOnlyRet(T...)
* send(tid, 42, "42"); * send(tid, 42, "42");
* } * }
* --- * ---
*), $(ARGS), $(ARGS), $(ARGS))
*/ */
receiveOnlyRet!(T) receiveOnly(T...)() receiveOnlyRet!(T) receiveOnly(T...)()
{ {