follow-up #17692: more inline syntax highlighting (#17837)

This commit is contained in:
Andrey Makarov 2021-04-29 18:16:14 +03:00 • committed by GitHub
commit e61381a293
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 287 additions and 181 deletions

View file

@ -127,9 +127,9 @@ compiler may instead choose to allow the program to die with a fatal error.
echo "invalid index"
The current implementation allows to switch between these different behaviors
via ``--panics:on|off``. When panics are turned on, the program dies with a
via `--panics:on|off`:option:. When panics are turned on, the program dies with a
panic, if they are turned off the runtime errors are turned into
exceptions. The benefit of ``--panics:on`` is that it produces smaller binary
exceptions. The benefit of `--panics:on`:option: is that it produces smaller binary
code and the compiler has more freedom to optimize the code.
An `unchecked runtime error`:idx: is an error that is not guaranteed to be
@ -678,7 +678,7 @@ defined here.)
These keywords are also operators:
`and or not xor shl shr div mod in notin is isnot of as from`.
`.`:tok: `=`:tok:, `:`:tok:, `::`:tok: are not available as general operators; they
`.`:tok:, `=`:tok:, `:`:tok:, `::`:tok: are not available as general operators; they
are used for other notational purposes.
`*:` is as a special case treated as the two tokens `*`:tok: and `:`:tok:
@ -697,7 +697,7 @@ The following strings denote other tokens::
The `slice`:idx: operator `..`:tok: takes precedence over other tokens that
contain a dot: `{..}`:tok: are the three tokens `{`:tok:, `..`:tok:, `}`:tok:
contain a dot: `{..}` are the three tokens `{`:tok:, `..`:tok:, `}`:tok:
and not the two tokens `{.`:tok:, `.}`:tok:.
@ -1460,7 +1460,7 @@ The notation `x[i]` can be used to access the i-th element of `x`.
Arrays are always bounds checked (statically or at runtime). These
checks can be disabled via pragmas or invoking the compiler with the
``--boundChecks:off`` command-line switch.
`--boundChecks:off`:option: command-line switch.
An array constructor can have explicit indexes for readability:
@ -4093,7 +4093,7 @@ Multi-methods
--------------
**Note:** Starting from Nim 0.20, to use multi-methods one must explicitly pass
``--multimethods:on`` when compiling.
`--multimethods:on`:option: when compiling.
In a multi-method, all parameters that have an object type are used for the
dispatching:
@ -4805,7 +4805,7 @@ And so is:
The reason for this is that `DivByZeroDefect` inherits from `Defect` and
with ``--panics:on`` Defects become unrecoverable errors.
with `--panics:on`:option: Defects become unrecoverable errors.
(Since version 1.4 of the language.)
@ -5604,7 +5604,7 @@ However, this means that the method call syntax is not available for
**Note**: The Nim compiler prior to version 1 was more lenient about this
requirement. Use the ``--useVersion:0.19`` switch for a transition period.
requirement. Use the `--useVersion:0.19`:option: switch for a transition period.
@ -6960,7 +6960,7 @@ with the project:
{.compile: "myfile.cpp".}
**Note**: Nim computes a SHA1 checksum and only recompiles the file if it
has changed. One can use the ``-f`` command-line option to force
has changed. One can use the `-f`:option: command-line option to force
the recompilation of the file.
Since 1.4 the `compile` pragma is also available with this syntax:
@ -6983,7 +6983,7 @@ The `link` pragma can be used to link an additional file with the project:
PassC pragma
------------
The `passc` pragma can be used to pass additional parameters to the C
compiler like one would using the command-line switch ``--passc``:
compiler like one would using the command-line switch `--passc`:option:\:
.. code-block:: Nim
{.passc: "-Wall -Werror".}
@ -7011,7 +7011,7 @@ the pragma resides in:
PassL pragma
------------
The `passL` pragma can be used to pass additional parameters to the linker
like one would be using the command-line switch ``--passL``:
like one would be using the command-line switch `--passL`:option:\:
.. code-block:: Nim
{.passL: "-lSDLmain -lSDL".}
@ -7047,8 +7047,8 @@ Example:
embedsC()
`nimbase.h` defines `NIM_EXTERNC` C macro that can be used for
`extern "C"`:cpp: code to work with both `nim c` and `nim cpp`, e.g.:
``nimbase.h`` defines `NIM_EXTERNC`:c: C macro that can be used for
`extern "C"`:cpp: code to work with both `nim c`:cmd: and `nim cpp`:cmd:, e.g.:
.. code-block:: Nim
proc foobar() {.importc:"$1".}
@ -7124,7 +7124,7 @@ pragmas this allows *sloppy* interfacing with libraries written in C++:
proc run(device: IrrlichtDevice): bool {.
header: irr, importcpp: "#.run(@)".}
The compiler needs to be told to generate C++ (command ``cpp``) for
The compiler needs to be told to generate C++ (command `cpp`:option:) for
this to work. The conditional symbol `cpp` is defined when the compiler
emits C++ code.
@ -7368,7 +7368,7 @@ allows *sloppy* interfacing with libraries written in Objective C:
g.greet(12, 34)
g.free()
The compiler needs to be told to generate Objective C (command ``objc``) for
The compiler needs to be told to generate Objective C (command `objc`:option:) for
this to work. The conditional symbol ``objc`` is defined when the compiler
emits Objective C code.
@ -7414,7 +7414,7 @@ will generate this code:
The `.cppNonPod` pragma should be used for non-POD `importcpp` types so that they
work properly (in particular regarding constructor and destructor) for
`.threadvar` variables. This requires ``--tlsEmulation:off``.
`.threadvar` variables. This requires `--tlsEmulation:off`:option:.
.. code-block:: nim
type Foo {.cppNonPod, importcpp, header: "funs.h".} = object
@ -7458,12 +7458,13 @@ pragma description
::
nim c -d:FooBar=42 foobar.nim
In the above example, providing the ``-d`` flag causes the symbol
In the above example, providing the `-d`:option: flag causes the symbol
`FooBar` to be overwritten at compile-time, printing out 42. If the
``-d:FooBar=42`` were to be omitted, the default value of 5 would be
`-d:FooBar=42`:option: were to be omitted, the default value of 5 would be
used. To see if a value was provided, `defined(FooBar)` can be used.
The syntax ``-d:flag`` is actually just a shortcut for ``-d:flag=true``.
The syntax `-d:flag`:option: is actually just a shortcut for
`-d:flag=true`:option:.
User-defined pragmas
====================
@ -7800,7 +7801,7 @@ strings, because they are precompiled.
because of order of initialization problems.
**Note**: A `dynlib` import can be overridden with
the ``--dynlibOverride:name`` command-line option. The
the `--dynlibOverride:name`:option: command-line option. The
`Compiler User Guide <nimc.html>`_ contains further information.
@ -7815,14 +7816,14 @@ conjunction with the `exportc` pragma:
proc exportme(): int {.cdecl, exportc, dynlib.}
This is only useful if the program is compiled as a dynamic library via the
``--app:lib`` command-line option.
`--app:lib`:option: command-line option.
Threads
=======
To enable thread support the ``--threads:on`` command-line switch needs to
To enable thread support the `--threads:on`:option: command-line switch needs to
be used. The system_ module then contains several threading primitives.
See the `threads <threads.html>`_ and `channels <channels.html>`_ modules
for the low-level thread API. There are also high-level parallelism constructs
@ -7864,7 +7865,7 @@ any of its parameters contain a `ref` or `closure` type. This enforces
the *no heap sharing restriction*.
Routines that are imported from C are always assumed to be `gcsafe`.
To disable the GC-safety checking the ``--threadAnalysis:off`` command-line
To disable the GC-safety checking the `--threadAnalysis:off`:option: command-line
switch can be used. This is a temporary workaround to ease the porting effort
from old code to the new threading model.