Use .. warning:: (#17320)

This commit is contained in:
konsumlamm 2021-03-10 19:39:23 +01:00 • committed by GitHub
commit 9819fb21d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 84 additions and 88 deletions

View file

@ -1048,14 +1048,14 @@ proc realpath*(name, resolved: cstring): cstring {.
proc mkstemp*(tmpl: cstring): cint {.importc, header: "<stdlib.h>", sideEffect.} proc mkstemp*(tmpl: cstring): cint {.importc, header: "<stdlib.h>", sideEffect.}
## Creates a unique temporary file. ## Creates a unique temporary file.
## ##
## **Warning**: The `tmpl` argument is written to by `mkstemp` and thus ## .. warning:: The `tmpl` argument is written to by `mkstemp` and thus
## can't be a string literal. If in doubt make a copy of the cstring before ## can't be a string literal. If in doubt make a copy of the cstring before
## passing it in. ## passing it in.
proc mkstemps*(tmpl: cstring, suffixlen: int): cint {.importc, header: "<stdlib.h>", sideEffect.} proc mkstemps*(tmpl: cstring, suffixlen: int): cint {.importc, header: "<stdlib.h>", sideEffect.}
## Creates a unique temporary file. ## Creates a unique temporary file.
## ##
## **Warning**: The `tmpl` argument is written to by `mkstemps` and thus ## .. warning:: The `tmpl` argument is written to by `mkstemps` and thus
## can't be a string literal. If in doubt make a copy of the cstring before ## can't be a string literal. If in doubt make a copy of the cstring before
## passing it in. ## passing it in.

View file

@ -2437,7 +2437,7 @@ proc sort*[A](t: var CountTable[A], order = SortOrder.Descending) =
## Sorts the count table so that, by default, the entry with the ## Sorts the count table so that, by default, the entry with the
## highest counter comes first. ## highest counter comes first.
## ##
## **WARNING:** This is destructive! Once sorted, you must not modify `t` afterwards! ## .. warning:: This is destructive! Once sorted, you must not modify `t` afterwards!
## ##
## You can use the iterators `pairs<#pairs.i,CountTable[A]>`_, ## You can use the iterators `pairs<#pairs.i,CountTable[A]>`_,
## `keys<#keys.i,CountTable[A]>`_, and `values<#values.i,CountTable[A]>`_ ## `keys<#keys.i,CountTable[A]>`_, and `values<#values.i,CountTable[A]>`_

View file

@ -99,7 +99,7 @@ proc libCandidates*(s: string, dest: var seq[string]) =
proc loadLibPattern*(pattern: string, globalSymbols = false): LibHandle = proc loadLibPattern*(pattern: string, globalSymbols = false): LibHandle =
## loads a library with name matching `pattern`, similar to what `dynlib` ## loads a library with name matching `pattern`, similar to what `dynlib`
## pragma does. Returns nil if the library could not be loaded. ## pragma does. Returns nil if the library could not be loaded.
## Warning: this proc uses the GC and so cannot be used to load the GC. ## .. warning:: this proc uses the GC and so cannot be used to load the GC.
var candidates = newSeq[string]() var candidates = newSeq[string]()
libCandidates(pattern, candidates) libCandidates(pattern, candidates)
for c in candidates: for c in candidates:

View file

@ -102,8 +102,7 @@ proc osLastError*(): OSErrorCode {.sideEffect.} =
## OS call failed. The `OSErrorMsg` procedure can then be used to convert ## OS call failed. The `OSErrorMsg` procedure can then be used to convert
## this code into a string. ## this code into a string.
## ##
## **Warning**: ## .. warning:: The behaviour of this procedure varies between Windows and POSIX systems.
## The behaviour of this procedure varies between Windows and POSIX systems.
## On Windows some OS calls can reset the error code to `0` causing this ## On Windows some OS calls can reset the error code to `0` causing this
## procedure to return `0`. It is therefore advised to call this procedure ## procedure to return `0`. It is therefore advised to call this procedure
## immediately after an OS call fails. On POSIX systems this is not a problem. ## immediately after an OS call fails. On POSIX systems this is not a problem.

View file

@ -45,8 +45,8 @@
## ``levelThreshold`` field and the global log filter. The latter can be changed ## ``levelThreshold`` field and the global log filter. The latter can be changed
## with the `setLogFilter proc<#setLogFilter,Level>`_. ## with the `setLogFilter proc<#setLogFilter,Level>`_.
## ##
## **Warning:** ## .. warning::
## * For loggers that log to a console or to files, only error and fatal ## For loggers that log to a console or to files, only error and fatal
## messages will cause their output buffers to be flushed immediately. ## messages will cause their output buffers to be flushed immediately.
## Use the `flushFile proc <io.html#flushFile,File>`_ to flush the buffer ## Use the `flushFile proc <io.html#flushFile,File>`_ to flush the buffer
## manually if needed. ## manually if needed.
@ -794,7 +794,7 @@ template fatal*(args: varargs[string, `$`]) =
proc addHandler*(handler: Logger) = proc addHandler*(handler: Logger) =
## Adds a logger to the list of registered handlers. ## Adds a logger to the list of registered handlers.
## ##
## **Warning:** The list of handlers is a thread-local variable. If the given ## .. warning:: The list of handlers is a thread-local variable. If the given
## handler will be used in multiple threads, this proc should be called in ## handler will be used in multiple threads, this proc should be called in
## each of those threads. ## each of those threads.
## ##
@ -820,7 +820,7 @@ proc setLogFilter*(lvl: Level) =
## individual logger's ``levelThreshold``. By default, all messages are ## individual logger's ``levelThreshold``. By default, all messages are
## logged. ## logged.
## ##
## **Warning:** The global log filter is a thread-local variable. If logging ## .. warning:: The global log filter is a thread-local variable. If logging
## is being performed in multiple threads, this proc should be called in each ## is being performed in multiple threads, this proc should be called in each
## thread unless it is intended that different threads should log at different ## thread unless it is intended that different threads should log at different
## logging levels. ## logging levels.

View file

@ -280,7 +280,7 @@ proc getAddrInfo*(address: string, port: Port, domain: Domain = AF_INET,
protocol: Protocol = IPPROTO_TCP): ptr AddrInfo = protocol: Protocol = IPPROTO_TCP): ptr AddrInfo =
## ##
## ##
## **Warning**: The resulting `ptr AddrInfo` must be freed using `freeAddrInfo`! ## .. warning:: The resulting `ptr AddrInfo` must be freed using `freeAddrInfo`!
var hints: AddrInfo var hints: AddrInfo
result = nil result = nil
hints.ai_family = toInt(domain) hints.ai_family = toInt(domain)

View file

@ -1445,7 +1445,7 @@ proc recv*(socket: Socket, data: var string, size: int, timeout = -1,
## ##
## **Note**: `data` must be initialised. ## **Note**: `data` must be initialised.
## ##
## **Warning**: Only the `SafeDisconn` flag is currently supported. ## .. warning:: Only the `SafeDisconn` flag is currently supported.
data.setLen(size) data.setLen(size)
result = result =
if timeout == -1: if timeout == -1:
@ -1480,7 +1480,7 @@ proc recv*(socket: Socket, size: int, timeout = -1,
## within the time specified a TimeoutError exception will be raised. ## within the time specified a TimeoutError exception will be raised.
## ##
## ##
## **Warning**: Only the `SafeDisconn` flag is currently supported. ## .. warning:: Only the `SafeDisconn` flag is currently supported.
result = newString(size) result = newString(size)
discard recv(socket, result, size, timeout, flags) discard recv(socket, result, size, timeout, flags)
@ -1523,7 +1523,7 @@ proc readLine*(socket: Socket, line: var string, timeout = -1,
## 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**: Only the `SafeDisconn` flag is currently supported. ## .. warning:: Only the `SafeDisconn` flag is currently supported.
template addNLIfEmpty() = template addNLIfEmpty() =
if line.len == 0: if line.len == 0:
@ -1579,7 +1579,7 @@ proc recvLine*(socket: Socket, timeout = -1,
## 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**: Only the `SafeDisconn` flag is currently supported. ## .. warning:: Only the `SafeDisconn` flag is currently supported.
result = "" result = ""
readLine(socket, result, timeout, flags, maxLength) readLine(socket, result, timeout, flags, maxLength)
@ -1592,7 +1592,7 @@ proc recvFrom*(socket: Socket, data: var string, length: int,
## If an error occurs an OSError exception will be raised. Otherwise the return ## If an error occurs an OSError exception will be raised. Otherwise the return
## value will be the length of data received. ## value will be the length of data received.
## ##
## **Warning:** This function does not yet have a buffered implementation, ## .. warning:: This function does not yet have a buffered implementation,
## so when `socket` is buffered the non-buffered implementation will be ## so when `socket` is buffered the non-buffered implementation will be
## used. Therefore if `socket` contains something in its buffer this ## used. Therefore if `socket` contains something in its buffer this
## function will make no effort to return it. ## function will make no effort to return it.

View file

@ -1458,7 +1458,7 @@ proc normalizePath*(path: var string) {.rtl, extern: "nos$1", tags: [].} =
## On relative paths, double dot (`..`) sequences are collapsed if possible. ## On relative paths, double dot (`..`) sequences are collapsed if possible.
## On absolute paths they are always collapsed. ## On absolute paths they are always collapsed.
## ##
## Warning: URL-encoded and Unicode attempts at directory traversal are not detected. ## .. warning:: URL-encoded and Unicode attempts at directory traversal are not detected.
## Triple dot is not handled. ## Triple dot is not handled.
## ##
## See also: ## See also:
@ -1722,8 +1722,7 @@ proc createSymlink*(src, dest: string) {.noWeirdTarget.} =
## Create a symbolic link at `dest` which points to the item specified ## Create a symbolic link at `dest` which points to the item specified
## by `src`. On most operating systems, will fail if a link already exists. ## by `src`. On most operating systems, will fail if a link already exists.
## ##
## **Warning**: ## .. warning:: Some OS's (such as Microsoft Windows) restrict the creation
## Some OS's (such as Microsoft Windows) restrict the creation
## of symlinks to root users (administrators) or users with developper mode enabled. ## of symlinks to root users (administrators) or users with developper mode enabled.
## ##
## See also: ## See also:
@ -2349,8 +2348,7 @@ iterator walkDirRec*(dir: string,
## If ``relative`` is true (default: false) the resulting path is ## If ``relative`` is true (default: false) the resulting path is
## shortened to be relative to ``dir``, otherwise the full path is returned. ## shortened to be relative to ``dir``, otherwise the full path is returned.
## ##
## **Warning**: ## .. warning:: Modifying the directory structure while the iterator
## Modifying the directory structure while the iterator
## is traversing may result in undefined behavior! ## is traversing may result in undefined behavior!
## ##
## Walking is recursive. `followFilter` controls the behaviour of the iterator: ## Walking is recursive. `followFilter` controls the behaviour of the iterator:
@ -2584,7 +2582,7 @@ proc createHardlink*(src, dest: string) {.noWeirdTarget.} =
## Create a hard link at `dest` which points to the item specified ## Create a hard link at `dest` which points to the item specified
## by `src`. ## by `src`.
## ##
## **Warning**: Some OS's restrict the creation of hard links to ## .. warning:: Some OS's restrict the creation of hard links to
## root users (administrators). ## root users (administrators).
## ##
## See also: ## See also:

View file

@ -80,9 +80,8 @@ proc execProcess*(command: string, workingDir: string = "",
## A convenience procedure that executes ``command`` with ``startProcess`` ## A convenience procedure that executes ``command`` with ``startProcess``
## and returns its output as a string. ## and returns its output as a string.
## ##
## **WARNING:** This function uses `poEvalCommand` by default for backwards ## .. warning:: This function uses `poEvalCommand` by default for backwards
## compatibility. ## compatibility. Make sure to pass options explicitly.
## Make sure to pass options explicitly.
## ##
## See also: ## See also:
## * `startProcess proc ## * `startProcess proc
@ -155,7 +154,7 @@ proc startProcess*(command: string, workingDir: string = "",
proc close*(p: Process) {.rtl, extern: "nosp$1", tags: [WriteIOEffect].} proc close*(p: Process) {.rtl, extern: "nosp$1", tags: [WriteIOEffect].}
## When the process has finished executing, cleanup related handles. ## When the process has finished executing, cleanup related handles.
## ##
## **WARNING:** If the process has not finished executing, this will forcibly ## .. warning:: If the process has not finished executing, this will forcibly
## terminate the process. Doing so may result in zombie processes and ## terminate the process. Doing so may result in zombie processes and
## `pty leaks <http://stackoverflow.com/questions/27021641/how-to-fix-request-failed-on-channel-0>`_. ## `pty leaks <http://stackoverflow.com/questions/27021641/how-to-fix-request-failed-on-channel-0>`_.
@ -215,7 +214,7 @@ proc waitForExit*(p: Process, timeout: int = -1): int {.rtl,
extern: "nosp$1", tags: [].} extern: "nosp$1", tags: [].}
## Waits for the process to finish and returns `p`'s error code. ## Waits for the process to finish and returns `p`'s error code.
## ##
## **WARNING**: Be careful when using `waitForExit` for processes created without ## .. warning:: Be careful when using `waitForExit` for processes created without
## `poParentStreams` because they may fill output buffers, causing deadlock. ## `poParentStreams` because they may fill output buffers, causing deadlock.
## ##
## On posix, if the process has exited because of a signal, 128 + signal ## On posix, if the process has exited because of a signal, 128 + signal
@ -230,7 +229,7 @@ proc peekExitCode*(p: Process): int {.rtl, extern: "nosp$1", tags: [].}
proc inputStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].} proc inputStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].}
## Returns ``p``'s input stream for writing to. ## Returns ``p``'s input stream for writing to.
## ##
## **WARNING**: The returned `Stream` should not be closed manually as it ## .. warning:: The returned `Stream` should not be closed manually as it
## is closed when closing the Process ``p``. ## is closed when closing the Process ``p``.
## ##
## See also: ## See also:
@ -244,7 +243,7 @@ proc outputStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].}
## Use `peekableOutputStream proc <#peekableOutputStream,Process>`_ ## Use `peekableOutputStream proc <#peekableOutputStream,Process>`_
## if you need to peek stream. ## if you need to peek stream.
## ##
## **WARNING**: The returned `Stream` should not be closed manually as it ## .. warning:: The returned `Stream` should not be closed manually as it
## is closed when closing the Process ``p``. ## is closed when closing the Process ``p``.
## ##
## See also: ## See also:
@ -258,7 +257,7 @@ proc errorStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].}
## Use `peekableErrorStream proc <#peekableErrorStream,Process>`_ ## Use `peekableErrorStream proc <#peekableErrorStream,Process>`_
## if you need to peek stream. ## if you need to peek stream.
## ##
## **WARNING**: The returned `Stream` should not be closed manually as it ## .. warning:: The returned `Stream` should not be closed manually as it
## is closed when closing the Process ``p``. ## is closed when closing the Process ``p``.
## ##
## See also: ## See also:
@ -270,7 +269,7 @@ proc peekableOutputStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: []
## ##
## You can peek returned stream. ## You can peek returned stream.
## ##
## **WARNING**: The returned `Stream` should not be closed manually as it ## .. warning:: The returned `Stream` should not be closed manually as it
## is closed when closing the Process ``p``. ## is closed when closing the Process ``p``.
## ##
## See also: ## See also:
@ -282,7 +281,7 @@ proc peekableErrorStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [],
## ##
## You can run peek operation to returned stream. ## You can run peek operation to returned stream.
## ##
## **WARNING**: The returned `Stream` should not be closed manually as it ## .. warning:: The returned `Stream` should not be closed manually as it
## is closed when closing the Process ``p``. ## is closed when closing the Process ``p``.
## ##
## See also: ## See also:
@ -293,7 +292,7 @@ proc inputHandle*(p: Process): FileHandle {.rtl, extern: "nosp$1",
tags: [].} = tags: [].} =
## Returns ``p``'s input file handle for writing to. ## Returns ``p``'s input file handle for writing to.
## ##
## **WARNING**: The returned `FileHandle` should not be closed manually as ## .. warning:: The returned `FileHandle` should not be closed manually as
## it is closed when closing the Process ``p``. ## it is closed when closing the Process ``p``.
## ##
## See also: ## See also:
@ -305,7 +304,7 @@ proc outputHandle*(p: Process): FileHandle {.rtl, extern: "nosp$1",
tags: [].} = tags: [].} =
## Returns ``p``'s output file handle for reading from. ## Returns ``p``'s output file handle for reading from.
## ##
## **WARNING**: The returned `FileHandle` should not be closed manually as ## .. warning:: The returned `FileHandle` should not be closed manually as
## it is closed when closing the Process ``p``. ## it is closed when closing the Process ``p``.
## ##
## See also: ## See also:
@ -317,7 +316,7 @@ proc errorHandle*(p: Process): FileHandle {.rtl, extern: "nosp$1",
tags: [].} = tags: [].} =
## Returns ``p``'s error file handle for reading from. ## Returns ``p``'s error file handle for reading from.
## ##
## **WARNING**: The returned `FileHandle` should not be closed manually as ## .. warning:: The returned `FileHandle` should not be closed manually as
## it is closed when closing the Process ``p``. ## it is closed when closing the Process ``p``.
## ##
## See also: ## See also:

View file

@ -332,7 +332,7 @@ when defined(windows):
proc setCursorYPos*(f: File, y: int) = proc setCursorYPos*(f: File, y: int) =
## Sets the terminal's cursor to the y position. ## Sets the terminal's cursor to the y position.
## The x position is not changed. ## The x position is not changed.
## **Warning**: This is not supported on UNIX! ## .. warning:: This is not supported on UNIX!
when defined(windows): when defined(windows):
let h = conHandle(f) let h = conHandle(f)
var scrbuf: CONSOLE_SCREEN_BUFFER_INFO var scrbuf: CONSOLE_SCREEN_BUFFER_INFO

View file

@ -84,7 +84,7 @@ when defined(nimExperimentalJsfetch) or defined(nimdoc):
proc unsafeNewFetchOptions*(metod, body, mode, credentials, cache, referrerPolicy: cstring; proc unsafeNewFetchOptions*(metod, body, mode, credentials, cache, referrerPolicy: cstring;
keepalive: bool; redirect = "follow".cstring; referrer = "client".cstring; integrity = "".cstring): FetchOptions {.importjs: keepalive: bool; redirect = "follow".cstring; referrer = "client".cstring; integrity = "".cstring): FetchOptions {.importjs:
"{method: #, body: #, mode: #, credentials: #, cache: #, referrerPolicy: #, keepalive: #, redirect: #, referrer: #, integrity: #}".} "{method: #, body: #, mode: #, credentials: #, cache: #, referrerPolicy: #, keepalive: #, redirect: #, referrer: #, integrity: #}".}
## .. Warning:: Unsafe `newfetchOptions`. ## .. warning:: Unsafe `newfetchOptions`.
func newfetchOptions*(metod: HttpMethod; body: cstring; func newfetchOptions*(metod: HttpMethod; body: cstring;
mode: FetchModes; credentials: FetchCredentials; cache: FetchCaches; referrerPolicy: FetchReferrerPolicies; mode: FetchModes; credentials: FetchCredentials; cache: FetchCaches; referrerPolicy: FetchReferrerPolicies;

View file

@ -17,7 +17,7 @@ func add*(self: FormData; name: cstring; value: SomeNumber | bool | cstring, fil
func delete*(self: FormData; name: cstring) {.importjs: "#.$1(#)".} func delete*(self: FormData; name: cstring) {.importjs: "#.$1(#)".}
## https://developer.mozilla.org/en-US/docs/Web/API/FormData/delete ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/delete
## ##
## .. Warning:: Deletes *all items* with the same key name. ## .. warning:: Deletes *all items* with the same key name.
func getAll*(self: FormData; name: cstring): seq[cstring] {.importjs: "#.$1(#)".} func getAll*(self: FormData; name: cstring): seq[cstring] {.importjs: "#.$1(#)".}
## https://developer.mozilla.org/en-US/docs/Web/API/FormData/getAll ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/getAll

View file

@ -14,7 +14,7 @@ func add*(self: Headers; key: cstring; value: cstring) {.importjs: "#.append(#,
func delete*(self: Headers; key: cstring) {.importjs: "#.$1(#)".} func delete*(self: Headers; key: cstring) {.importjs: "#.$1(#)".}
## https://developer.mozilla.org/en-US/docs/Web/API/Headers/delete ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/delete
## ##
## .. Warning:: Delete *all* items with `key` from the headers, including duplicated keys. ## .. warning:: Delete *all* items with `key` from the headers, including duplicated keys.
func hasKey*(self: Headers; key: cstring): bool {.importjs: "#.has(#)".} func hasKey*(self: Headers; key: cstring): bool {.importjs: "#.has(#)".}
## https://developer.mozilla.org/en-US/docs/Web/API/Headers/has ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/has

View file

@ -271,7 +271,7 @@ iterator fields*[T: tuple|object](x: T): RootObj {.
magic: "Fields", noSideEffect.} = magic: "Fields", noSideEffect.} =
## Iterates over every field of `x`. ## Iterates over every field of `x`.
## ##
## **Warning**: This really transforms the 'for' and unrolls the loop. ## .. warning:: This really transforms the 'for' and unrolls the loop.
## The current implementation also has a bug ## The current implementation also has a bug
## that affects symbol binding in the loop body. ## that affects symbol binding in the loop body.
runnableExamples: runnableExamples:
@ -283,7 +283,7 @@ iterator fields*[S:tuple|object, T:tuple|object](x: S, y: T): tuple[key: string,
magic: "Fields", noSideEffect.} = magic: "Fields", noSideEffect.} =
## Iterates over every field of `x` and `y`. ## Iterates over every field of `x` and `y`.
## ##
## **Warning**: This really transforms the 'for' and unrolls the loop. ## .. warning:: This really transforms the 'for' and unrolls the loop.
## The current implementation also has a bug that affects symbol binding ## The current implementation also has a bug that affects symbol binding
## in the loop body. ## in the loop body.
runnableExamples: runnableExamples:
@ -304,7 +304,7 @@ iterator fieldPairs*[T: tuple|object](x: T): tuple[key: string, val: RootObj] {.
## picking the appropriate code to a secondary proc which you overload for ## picking the appropriate code to a secondary proc which you overload for
## each field type and pass the `value` to. ## each field type and pass the `value` to.
## ##
## **Warning**: This really transforms the 'for' and unrolls the loop. The ## .. warning::: This really transforms the 'for' and unrolls the loop. The
## current implementation also has a bug that affects symbol binding in the ## current implementation also has a bug that affects symbol binding in the
## loop body. ## loop body.
runnableExamples: runnableExamples:
@ -325,7 +325,7 @@ iterator fieldPairs*[S: tuple|object, T: tuple|object](x: S, y: T): tuple[
magic: "FieldPairs", noSideEffect.} = magic: "FieldPairs", noSideEffect.} =
## Iterates over every field of `x` and `y`. ## Iterates over every field of `x` and `y`.
## ##
## **Warning**: This really transforms the 'for' and unrolls the loop. ## .. warning:: This really transforms the 'for' and unrolls the loop.
## The current implementation also has a bug that affects symbol binding ## The current implementation also has a bug that affects symbol binding
## in the loop body. ## in the loop body.
runnableExamples: runnableExamples: