Skip to content

Commit f90a970

Browse files
author
Egor Andreevich
authored
Merge pull request #665 from square/egorand/191007/dokka-0.10.0
Dokka 0.10.0
2 parents 9b107c4 + f8f1af7 commit f90a970

File tree

12 files changed

+36
-239
lines changed

12 files changed

+36
-239
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
'kotlin': '1.3.50',
44
'jmhPlugin': '0.4.8',
55
'animalSnifferPlugin': '1.5.0',
6-
'dokka': '0.9.18',
6+
'dokka': '0.10.0',
77
'jmh': '1.21',
88
'animalSniffer': '1.16',
99
'junit': '4.12',

gradle/gradle-mvn-mpp-push.gradle

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,38 @@ apply plugin: 'org.jetbrains.dokka'
55
dokka {
66
outputDirectory = "$rootDir/docs/2.x"
77
outputFormat = 'gfm'
8-
reportUndocumented = false
9-
skipDeprecated = true
10-
jdkVersion = 8
11-
impliedPlatforms = ["Common"] // This will force platform tags for all non-common sources e.g. "JVM"
12-
kotlinTasks {
13-
// dokka fails to retrieve sources from MPP-tasks so they must be set empty to avoid exception
14-
// use sourceRoot instead (see below)
15-
[]
16-
}
17-
packageOptions {
18-
prefix = "com.squareup.okio"
19-
suppress = true
20-
}
21-
packageOptions {
22-
prefix = "okio.internal"
23-
suppress = true
24-
}
25-
sourceRoot {
26-
// assuming there is only a single source dir...
27-
path = kotlin.sourceSets.commonMain.kotlin.srcDirs[0]
28-
platforms = ["Common"]
29-
}
30-
if (kotlin.sourceSets.getNames().contains("jvmMain")) {
31-
sourceRoot {
32-
// assuming there is only a single source dir...
33-
path = kotlin.sourceSets.jvmMain.kotlin.srcDirs[0]
34-
platforms = ["JVM"]
8+
9+
multiplatform {
10+
global {
11+
reportUndocumented = false
12+
skipDeprecated = true
13+
jdkVersion = 8
14+
perPackageOption {
15+
prefix = "com.squareup.okio"
16+
suppress = true
17+
}
18+
perPackageOption {
19+
prefix = "okio.internal"
20+
suppress = true
21+
}
3522
}
36-
}
37-
if (kotlin.sourceSets.getNames().contains("jsMain")) {
38-
sourceRoot {
39-
// assuming there is only a single source dir...
40-
path = kotlin.sourceSets.jsMain.kotlin.srcDirs[0]
41-
platforms = ["js"]
23+
jvm {
24+
sourceRoot {
25+
// assuming there is only a single source dir...
26+
path = kotlin.sourceSets.jvmMain.kotlin.srcDirs[0]
27+
}
4228
}
43-
}
44-
if (kotlin.sourceSets.getNames().contains("nativeMain")) {
45-
sourceRoot {
46-
// assuming there is only a single source dir...
47-
path = kotlin.sourceSets.nativeMain.kotlin.srcDirs[0]
48-
platforms = ["native"]
29+
js {
30+
sourceRoot {
31+
// assuming there is only a single source dir...
32+
path = kotlin.sourceSets.jsMain.kotlin.srcDirs[0]
33+
}
34+
}
35+
'native' {
36+
sourceRoot {
37+
// assuming there is only a single source dir...
38+
path = kotlin.sourceSets.nativeMain.kotlin.srcDirs[0]
39+
}
4940
}
5041
}
5142
}

okio/src/commonMain/kotlin/okio/Buffer.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ expect class Buffer() : BufferedSource, BufferedSink {
6565
/** Returns the byte at `pos`. */
6666
operator fun get(pos: Long): Byte
6767

68+
/**
69+
* Discards all bytes in this buffer. Calling this method when you're done with a buffer will
70+
* return its segments to the pool.
71+
*/
6872
fun clear()
6973

74+
/** Discards `byteCount` bytes from the head of this buffer. */
7075
override fun skip(byteCount: Long)
7176

7277
override fun write(byteString: ByteString): Buffer

okio/src/jsMain/kotlin/okio/Buffer.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,13 @@ actual class Buffer : BufferedSource, BufferedSink {
8383
byteCount: Long
8484
): Buffer = commonCopyTo(out, offset, byteCount)
8585

86-
/**
87-
* Overload of [copyTo] with byteCount = size - offset, work around for
88-
* https://youtrack.jetbrains.com/issue/KT-30847
89-
*/
9086
actual fun copyTo(
9187
out: Buffer,
9288
offset: Long
9389
): Buffer = copyTo(out, offset, size - offset)
9490

9591
actual operator fun get(pos: Long): Byte = commonGet(pos)
9692

97-
/**
98-
* Returns the number of bytes in segments that are not writable. This is the number of bytes that
99-
* can be flushed immediately to an underlying sink without harming throughput.
100-
*/
10193
actual fun completeSegmentByteCount(): Long = commonCompleteSegmentByteCount()
10294

10395
override fun readByte(): Byte = commonReadByte()
@@ -248,12 +240,9 @@ actual class Buffer : BufferedSource, BufferedSink {
248240
*/
249241
override fun toString() = snapshot().toString()
250242

251-
/** Returns a deep copy of this buffer. */
252243
actual fun copy(): Buffer = commonCopy()
253244

254-
/** Returns an immutable copy of this buffer as a byte string. */
255245
actual fun snapshot(): ByteString = commonSnapshot()
256246

257-
/** Returns an immutable copy of the first `byteCount` bytes of this buffer as a byte string. */
258247
actual fun snapshot(byteCount: Int): ByteString = commonSnapshot(byteCount)
259248
}

okio/src/jsMain/kotlin/okio/ByteString.kt

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -42,93 +42,54 @@ import okio.internal.commonToString
4242
import okio.internal.commonUtf8
4343
import okio.internal.commonWrite
4444

45-
/**
46-
* An immutable sequence of bytes.
47-
*
48-
* Byte strings compare lexicographically as a sequence of **unsigned** bytes. That is, the byte
49-
* string `ff` sorts after `00`. This is counter to the sort order of the corresponding bytes,
50-
* where `-1` sorts before `0`.
51-
*/
5245
actual open class ByteString
53-
// Trusted internal constructor doesn't clone data.
5446
internal actual constructor(
5547
internal actual val data: ByteArray
5648
) : Comparable<ByteString> {
5749
internal actual var hashCode: Int = 0 // Lazily computed; 0 if unknown.
5850
internal actual var utf8: String? = null // Lazily computed.
5951

60-
/** Constructs a new `String` by decoding the bytes as `UTF-8`. */
6152
actual open fun utf8(): String = commonUtf8()
6253

63-
/**
64-
* Returns this byte string encoded as [Base64](http://www.ietf.org/rfc/rfc2045.txt). In violation
65-
* of the RFC, the returned string does not wrap lines at 76 columns.
66-
*/
6754
actual open fun base64(): String = commonBase64()
6855

69-
/** Returns this byte string encoded as [URL-safe Base64](http://www.ietf.org/rfc/rfc4648.txt). */
7056
actual open fun base64Url(): String = commonBase64Url()
7157

72-
/** Returns this byte string encoded in hexadecimal. */
7358
actual open fun hex(): String = commonHex()
7459

75-
/**
76-
* Returns a byte string equal to this byte string, but with the bytes 'A' through 'Z' replaced
77-
* with the corresponding byte in 'a' through 'z'. Returns this byte string if it contains no
78-
* bytes in 'A' through 'Z'.
79-
*/
8060
actual open fun toAsciiLowercase(): ByteString = commonToAsciiLowercase()
8161

82-
/**
83-
* Returns a byte string equal to this byte string, but with the bytes 'a' through 'z' replaced
84-
* with the corresponding byte in 'A' through 'Z'. Returns this byte string if it contains no
85-
* bytes in 'a' through 'z'.
86-
*/
8762
actual open fun toAsciiUppercase(): ByteString = commonToAsciiUppercase()
8863

8964
actual open fun substring(beginIndex: Int, endIndex: Int): ByteString =
9065
commonSubstring(beginIndex, endIndex)
9166

92-
/** Returns the byte at `pos`. */
9367
internal actual open fun internalGet(pos: Int): Byte {
9468
if (pos >= size || pos < 0) throw ArrayIndexOutOfBoundsException("size=$size pos=$pos")
9569
return commonGetByte(pos)
9670
}
9771

98-
/** Returns the byte at `index`. */
9972
actual operator fun get(index: Int): Byte = internalGet(index)
10073

101-
/** Returns the number of bytes in this ByteString. */
10274
actual val size
10375
get() = getSize()
10476

105-
// Hack to work around Kotlin's limitation for using JvmName on open/override vals/funs
10677
internal actual open fun getSize() = commonGetSize()
10778

108-
/** Returns a byte array containing a copy of the bytes in this `ByteString`. */
10979
actual open fun toByteArray() = commonToByteArray()
11080

111-
/** Returns the bytes of this string without a defensive copy. Do not mutate! */
11281
internal actual open fun internalArray() = commonInternalArray()
11382

11483
internal actual open fun write(buffer: Buffer, offset: Int, byteCount: Int) =
11584
commonWrite(buffer, offset, byteCount)
11685

117-
/**
118-
* Returns true if the bytes of this in `[offset..offset+byteCount)` equal the bytes of `other` in
119-
* `[otherOffset..otherOffset+byteCount)`. Returns false if either range is out of bounds.
120-
*/
12186
actual open fun rangeEquals(
12287
offset: Int,
12388
other: ByteString,
12489
otherOffset: Int,
12590
byteCount: Int
12691
): Boolean = commonRangeEquals(offset, other, otherOffset, byteCount)
12792

128-
/**
129-
* Returns true if the bytes of this in `[offset..offset+byteCount)` equal the bytes of `other` in
130-
* `[otherOffset..otherOffset+byteCount)`. Returns false if either range is out of bounds.
131-
*/
13293
actual open fun rangeEquals(
13394
offset: Int,
13495
other: ByteArray,
@@ -165,25 +126,17 @@ internal actual constructor(
165126
actual override fun toString() = commonToString()
166127

167128
actual companion object {
168-
/** A singleton empty `ByteString`. */
169129
actual val EMPTY: ByteString = ByteString(byteArrayOf())
170130

171-
/** Returns a new byte string containing a clone of the bytes of `data`. */
172131
actual fun of(vararg data: Byte) = commonOf(data)
173132

174133
actual fun ByteArray.toByteString(offset: Int, byteCount: Int): ByteString =
175134
commonToByteString(offset, byteCount)
176135

177-
/** Returns a new byte string containing the `UTF-8` bytes of this [String]. */
178136
actual fun String.encodeUtf8(): ByteString = commonEncodeUtf8()
179137

180-
/**
181-
* Decodes the Base64-encoded bytes and returns their value as a byte string. Returns null if
182-
* this is not a Base64-encoded sequence of bytes.
183-
*/
184138
actual fun String.decodeBase64(): ByteString? = commonDecodeBase64()
185139

186-
/** Decodes the hex-encoded bytes and returns their value a byte string. */
187140
actual fun String.decodeHex() = commonDecodeHex()
188141
}
189142
}

okio/src/jsMain/kotlin/okio/SegmentedByteString.kt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,6 @@ import okio.internal.commonSubstring
2424
import okio.internal.commonToByteArray
2525
import okio.internal.commonWrite
2626

27-
/**
28-
* An immutable byte string composed of segments of byte arrays. This class exists to implement
29-
* efficient snapshots of buffers. It is implemented as an array of segments, plus a directory in
30-
* two halves that describes how the segments compose this byte string.
31-
*
32-
* The first half of the directory is the cumulative byte count covered by each segment. The
33-
* element at `directory[0]` contains the number of bytes held in `segments[0]`; the
34-
* element at `directory[1]` contains the number of bytes held in `segments[0] +
35-
* segments[1]`, and so on. The element at `directory[segments.length - 1]` contains the total
36-
* size of this byte string. The first half of the directory is always monotonically increasing.
37-
*
38-
* The second half of the directory is the offset in `segments` of the first content byte.
39-
* Bytes preceding this offset are unused, as are bytes beyond the segment's effective size.
40-
*
41-
* Suppose we have a byte string, `[A, B, C, D, E, F, G, H, I, J, K, L, M]` that is stored
42-
* across three byte arrays: `[x, x, x, x, A, B, C, D, E, x, x, x]`, `[x, F, G]`, and `[H, I, J, K,
43-
* L, M, x, x, x, x, x, x]`. The three byte arrays would be stored in `segments` in order. Since the
44-
* arrays contribute 5, 2, and 6 elements respectively, the directory starts with `[5, 7, 13` to
45-
* hold the cumulative total at each position. Since the offsets into the arrays are 4, 1, and 0
46-
* respectively, the directory ends with `4, 1, 0]`. Concatenating these two halves, the complete
47-
* directory is `[5, 7, 13, 4, 1, 0]`.
48-
*
49-
* This structure is chosen so that the segment holding a particular offset can be found by
50-
* binary search. We use one array rather than two for the directory as a micro-optimization.
51-
*/
5227
internal actual class SegmentedByteString internal actual constructor(
5328
internal actual val segments: Array<ByteArray>,
5429
internal actual val directory: IntArray

okio/src/jvmMain/kotlin/okio/Buffer.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,8 @@ actual class Buffer : BufferedSource, BufferedSink, Cloneable, ByteChannel {
356356
return toCopy
357357
}
358358

359-
/**
360-
* Discards all bytes in this buffer. Calling this method when you're done with a buffer will
361-
* return its segments to the pool.
362-
*/
363359
actual fun clear() = commonClear()
364360

365-
/** Discards `byteCount` bytes from the head of this buffer. */
366361
@Throws(EOFException::class)
367362
actual override fun skip(byteCount: Long) = commonSkip(byteCount)
368363

@@ -556,7 +551,6 @@ actual class Buffer : BufferedSource, BufferedSink, Cloneable, ByteChannel {
556551
*/
557552
override fun toString() = snapshot().toString()
558553

559-
/** Returns a deep copy of this buffer. */
560554
actual fun copy(): Buffer = commonCopy()
561555

562556
/** Returns a deep copy of this buffer. */

okio/src/jvmMain/kotlin/okio/ByteString.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import javax.crypto.Mac
5656
import javax.crypto.spec.SecretKeySpec
5757

5858
actual open class ByteString
59-
// Trusted internal constructor doesn't clone data.
6059
internal actual constructor(
6160
internal actual val data: ByteArray
6261
) : Serializable, Comparable<ByteString> {
@@ -124,7 +123,6 @@ internal actual constructor(
124123
actual val size
125124
@JvmName("size") get() = getSize()
126125

127-
// Hack to work around Kotlin's limitation for using JvmName on open/override vals/funs
128126
internal actual open fun getSize() = commonGetSize()
129127

130128
actual open fun toByteArray() = commonToByteArray()

okio/src/jvmMain/kotlin/okio/SegmentedByteString.kt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,6 @@ import java.security.MessageDigest
3333
import javax.crypto.Mac
3434
import javax.crypto.spec.SecretKeySpec
3535

36-
/**
37-
* An immutable byte string composed of segments of byte arrays. This class exists to implement
38-
* efficient snapshots of buffers. It is implemented as an array of segments, plus a directory in
39-
* two halves that describes how the segments compose this byte string.
40-
*
41-
* The first half of the directory is the cumulative byte count covered by each segment. The
42-
* element at `directory[0]` contains the number of bytes held in `segments[0]`; the
43-
* element at `directory[1]` contains the number of bytes held in `segments[0] +
44-
* segments[1]`, and so on. The element at `directory[segments.length - 1]` contains the total
45-
* size of this byte string. The first half of the directory is always monotonically increasing.
46-
*
47-
* The second half of the directory is the offset in `segments` of the first content byte.
48-
* Bytes preceding this offset are unused, as are bytes beyond the segment's effective size.
49-
*
50-
* Suppose we have a byte string, `[A, B, C, D, E, F, G, H, I, J, K, L, M]` that is stored
51-
* across three byte arrays: `[x, x, x, x, A, B, C, D, E, x, x, x]`, `[x, F, G]`, and `[H, I, J, K,
52-
* L, M, x, x, x, x, x, x]`. The three byte arrays would be stored in `segments` in order. Since the
53-
* arrays contribute 5, 2, and 6 elements respectively, the directory starts with `[5, 7, 13` to
54-
* hold the cumulative total at each position. Since the offsets into the arrays are 4, 1, and 0
55-
* respectively, the directory ends with `4, 1, 0]`. Concatenating these two halves, the complete
56-
* directory is `[5, 7, 13, 4, 1, 0]`.
57-
*
58-
* This structure is chosen so that the segment holding a particular offset can be found by
59-
* binary search. We use one array rather than two for the directory as a micro-optimization.
60-
*/
6136
internal actual class SegmentedByteString internal actual constructor(
6237
@Transient internal actual val segments: Array<ByteArray>,
6338
@Transient internal actual val directory: IntArray

okio/src/nativeMain/kotlin/okio/Buffer.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,13 @@ actual class Buffer : BufferedSource, BufferedSink {
8383
byteCount: Long
8484
): Buffer = commonCopyTo(out, offset, byteCount)
8585

86-
/**
87-
* Overload of [copyTo] with byteCount = size - offset, work around for
88-
* https://youtrack.jetbrains.com/issue/KT-30847
89-
*/
9086
actual fun copyTo(
9187
out: Buffer,
9288
offset: Long
9389
): Buffer = copyTo(out, offset, size - offset)
9490

9591
actual operator fun get(pos: Long): Byte = commonGet(pos)
9692

97-
/**
98-
* Returns the number of bytes in segments that are not writable. This is the number of bytes that
99-
* can be flushed immediately to an underlying sink without harming throughput.
100-
*/
10193
actual fun completeSegmentByteCount(): Long = commonCompleteSegmentByteCount()
10294

10395
override fun readByte(): Byte = commonReadByte()
@@ -248,12 +240,9 @@ actual class Buffer : BufferedSource, BufferedSink {
248240
*/
249241
override fun toString() = snapshot().toString()
250242

251-
/** Returns a deep copy of this buffer. */
252243
actual fun copy(): Buffer = commonCopy()
253244

254-
/** Returns an immutable copy of this buffer as a byte string. */
255245
actual fun snapshot(): ByteString = commonSnapshot()
256246

257-
/** Returns an immutable copy of the first `byteCount` bytes of this buffer as a byte string. */
258247
actual fun snapshot(byteCount: Int): ByteString = commonSnapshot(byteCount)
259248
}

0 commit comments

Comments
 (0)