use .. warning:: (#17226)

* remove unnecessary when statement

* remove outdated codes

* use warnings
This commit is contained in:
flywind 2021-03-04 18:34:55 +08:00 • committed by GitHub
commit 5670b848cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 16 deletions

View file

@ -563,7 +563,8 @@ proc product*[T](x: openArray[seq[T]]): seq[seq[T]] =
## Produces the Cartesian product of the array. ## Produces the Cartesian product of the array.
## Every element of the result is a combination of one element from each seq in `x`, ## Every element of the result is a combination of one element from each seq in `x`,
## with the ith element coming from `x[i]`. ## with the ith element coming from `x[i]`.
## Warning: complexity may explode. ##
## .. warning:: complexity may explode.
runnableExamples: runnableExamples:
assert product(@[@[1], @[2]]) == @[@[1, 2]] assert product(@[@[1], @[2]]) == @[@[1, 2]]
assert product(@[@["A", "K"], @["Q"]]) == @[@["K", "Q"], @["A", "Q"]] assert product(@[@["A", "K"], @["Q"]]) == @[@["K", "Q"], @["A", "Q"]]

View file

@ -435,7 +435,7 @@ when defined(windows) or defined(nimdoc):
## read, or the socket has disconnected in which case the future will ## read, or the socket has disconnected in which case the future will
## complete with a value of `""`. ## complete with a value of `""`.
## ##
## **Warning**: The `Peek` socket flag is not supported on Windows. ## .. warning:: The `Peek` socket flag is not supported on Windows.
# Things to note: # Things to note:
@ -509,7 +509,7 @@ when defined(windows) or defined(nimdoc):
## has disconnected in which case the future will complete with a value of ## has disconnected in which case the future will complete with a value of
## `0`. ## `0`.
## ##
## **Warning**: The `Peek` socket flag is not supported on Windows. ## .. warning:: The `Peek` socket flag is not supported on Windows.
# Things to note: # Things to note:
@ -572,7 +572,7 @@ when defined(windows) or defined(nimdoc):
## Sends `size` bytes from `buf` to `socket`. The returned future ## Sends `size` bytes from `buf` to `socket`. The returned future
## will complete once all data has been sent. ## will complete once all data has been sent.
## ##
## **WARNING**: Use it with caution. If `buf` refers to GC'ed object, ## .. warning:: Use it with caution. If `buf` refers to GC'ed object,
## you must use GC_ref/GC_unref calls to avoid early freeing of the buffer. ## you must use GC_ref/GC_unref calls to avoid early freeing of the buffer.
verifyPresence(socket) verifyPresence(socket)
var retFuture = newFuture[void]("send") var retFuture = newFuture[void]("send")

View file

@ -517,10 +517,9 @@ proc recvLineInto*(socket: AsyncSocket, resString: FutureVar[string],
## The `maxLength` parameter determines the maximum amount of characters ## The `maxLength` parameter determines the maximum amount of characters
## that can be read. `resString` will be truncated after that. ## that can be read. `resString` will be truncated after that.
## ##
## **Warning**: The `Peek` flag is not yet implemented. ## .. warning:: The `Peek` flag is not yet implemented.
## ##
## **Warning**: `recvLineInto` on unbuffered sockets assumes that the ## .. warning:: `recvLineInto` on unbuffered sockets assumes that the protocol uses `\r\L` to delimit a new line.
## protocol uses `\r\L` to delimit a new line.
assert SocketFlag.Peek notin flags ## TODO: assert SocketFlag.Peek notin flags ## TODO:
result = newFuture[void]("asyncnet.recvLineInto") result = newFuture[void]("asyncnet.recvLineInto")
@ -611,10 +610,9 @@ proc recvLine*(socket: AsyncSocket,
## The `maxLength` parameter determines the maximum amount of characters ## The `maxLength` parameter determines the maximum amount of characters
## that can be read. The result is truncated after that. ## that can be read. The result is truncated after that.
## ##
## **Warning**: The `Peek` flag is not yet implemented. ## .. warning:: The `Peek` flag is not yet implemented.
## ##
## **Warning**: `recvLine` on unbuffered sockets assumes that the protocol ## .. warning:: `recvLine` on unbuffered sockets assumes that the protocol uses `\r\L` to delimit a new line.
## uses `\r\L` to delimit a new line.
assert SocketFlag.Peek notin flags ## TODO: assert SocketFlag.Peek notin flags ## TODO:
# TODO: Optimise this # TODO: Optimise this

View file

@ -110,7 +110,7 @@
## .. code-block:: Nim ## .. code-block:: Nim
## client.onProgressChanged = nil ## client.onProgressChanged = nil
## ##
## **Warning:** The `total` reported by httpclient may be 0 in some cases. ## .. warning:: The `total` reported by httpclient may be 0 in some cases.
## ##
## ##
## SSL/TLS support ## SSL/TLS support

View file

@ -1939,8 +1939,7 @@ when notJSnotNims:
## With this hook you can influence exception handling on a global level. ## With this hook you can influence exception handling on a global level.
## If not nil, every 'raise' statement ends up calling this hook. ## If not nil, every 'raise' statement ends up calling this hook.
## ##
## **Warning**: Ordinary application code should never set this hook! ## .. warning:: Ordinary application code should never set this hook! You better know what you do when setting this.
## You better know what you do when setting this.
## ##
## If `globalRaiseHook` returns false, the exception is caught and does ## If `globalRaiseHook` returns false, the exception is caught and does
## not propagate further through the call stack. ## not propagate further through the call stack.
@ -1950,8 +1949,7 @@ when notJSnotNims:
## thread local level. ## thread local level.
## If not nil, every 'raise' statement ends up calling this hook. ## If not nil, every 'raise' statement ends up calling this hook.
## ##
## **Warning**: Ordinary application code should never set this hook! ## .. warning:: Ordinary application code should never set this hook! You better know what you do when setting this.
## You better know what you do when setting this.
## ##
## If `localRaiseHook` returns false, the exception ## If `localRaiseHook` returns false, the exception
## is caught and does not propagate further through the call stack. ## is caught and does not propagate further through the call stack.
@ -2408,7 +2406,7 @@ when notJSnotNims and hostOS != "standalone":
proc setCurrentException*(exc: ref Exception) {.inline, benign.} = proc setCurrentException*(exc: ref Exception) {.inline, benign.} =
## Sets the current exception. ## Sets the current exception.
## ##
## **Warning**: Only use this if you know what you are doing. ## .. warning:: Only use this if you know what you are doing.
currException = exc currException = exc
elif defined(nimscript): elif defined(nimscript):
proc getCurrentException*(): ref Exception {.compilerRtl.} = discard proc getCurrentException*(): ref Exception {.compilerRtl.} = discard