Skip to content

Commit

Permalink
follow-up nim-lang#18013 - inline syntax highlighting (nim-lang#18166)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mr authored and PMunch committed Mar 28, 2022
1 parent 54a5166 commit 8d3c470
Show file tree
Hide file tree
Showing 20 changed files with 183 additions and 164 deletions.
2 changes: 1 addition & 1 deletion doc/destructors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Nim Destructors and Move Semantics
:Authors: Andreas Rumpf
:Version: |nimversion|

.. default-role:: code
.. include:: rstcommon.rst
.. default-role:: nim
.. contents::


Expand Down
2 changes: 1 addition & 1 deletion doc/docgen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
:Author: Erik O'Leary
:Version: |nimversion|

.. default-role:: code
.. include:: rstcommon.rst
.. default-role:: Nim
.. contents::


Expand Down
4 changes: 2 additions & 2 deletions doc/drnim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
:Author: Andreas Rumpf
:Version: |nimversion|

.. default-role:: code
.. include:: rstcommon.rst
.. default-role:: Nim
.. contents::


Expand Down Expand Up @@ -43,7 +43,7 @@ your code.
Installation
============

Run `koch drnim`:option:, the executable will afterwards be
Run `koch drnim`:cmd:, the executable will afterwards be
in ``$nim/bin/drnim``.


Expand Down
2 changes: 1 addition & 1 deletion doc/estp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Embedded Stack Trace Profiler (ESTP) User Guide
===================================================

.. default-role:: code
.. include:: rstcommon.rst
.. default-role:: Nim

:Author: Andreas Rumpf
:Version: |nimversion|
Expand Down
31 changes: 19 additions & 12 deletions doc/hcr.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.. default-role:: code

===================================
Hot code reloading
===================================

.. default-role:: code
.. include:: rstcommon.rst

The `hotCodeReloading`:idx: option enables special compilation mode where
changes in the code can be applied automatically to a running program.
The code reloading happens at the granularity of an individual module.
Expand All @@ -22,7 +23,7 @@ during development resides.

In this example, we use SDL2 to create a window and we reload the logic
code when `F9` is pressed. The important lines are marked with `#***`.
To install SDL2 you can use `nimble install sdl2`.
To install SDL2 you can use `nimble install sdl2`:cmd:.


.. code-block:: nim
Expand Down Expand Up @@ -98,34 +99,40 @@ To install SDL2 you can use `nimble install sdl2`.
main()
Compile this example via::
Compile this example via:

```cmd
nim c --hotcodereloading:on mymain.nim
```

Now start the program and KEEP it running!

::

.. code:: cmd
# Unix:
mymain &
# or Windows (click on the .exe)
mymain.exe
# edit
For example, change the line::
For example, change the line:

```nim
discard renderer.setDrawColor(255, 128, 128, 0)
```

into::
into:

```nim
discard renderer.setDrawColor(255, 255, 128, 0)
```

(This will change the color of the rectangle.)

Then recompile the project, but do not restart or quit the mymain.exe program!
::

```cmd
nim c --hotcodereloading:on mymain.nim
```

Now give the `mymain` SDL window the focus, press F9, and watch the
updated version of the program.
Expand Down Expand Up @@ -188,15 +195,15 @@ Native code targets
===================

Native projects using the hot code reloading option will be implicitly
compiled with the `-d:useNimRtl` option and they will depend on both
compiled with the `-d:useNimRtl`:option: option and they will depend on both
the `nimrtl` library and the `nimhcr` library which implements the
hot code reloading run-time. Both libraries can be found in the `lib`
folder of Nim and can be compiled into dynamic libraries to satisfy
runtime demands of the example code above. An example of compiling
`nimhcr.nim` and `nimrtl.nim` when the source dir of Nim is installed
``nimhcr.nim`` and ``nimrtl.nim`` when the source dir of Nim is installed
with choosenim follows.

::
.. code:: console
# Unix/MacOS
# Make sure you are in the directory containing your .nim files
Expand Down
2 changes: 1 addition & 1 deletion doc/intern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
:Author: Andreas Rumpf
:Version: |nimversion|

.. default-role:: code
.. include:: rstcommon.rst
.. default-role:: Nim
.. contents::

"Abstraction is layering ignorance on top of reality." -- Richard Gabriel
Expand Down
27 changes: 13 additions & 14 deletions doc/koch.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.. default-role:: code

===============================
Nim maintenance script
===============================

:Version: |nimversion|

.. default-role:: code
.. include:: rstcommon.rst
.. contents::

.. raw:: html
Expand All @@ -19,7 +19,7 @@ Introduction

The `koch`:idx: program is Nim's maintenance script. It is a replacement
for make and shell scripting with the advantage that it is much more portable.
The word *koch* means *cook* in German. `koch` is used mainly to build the
The word *koch* means *cook* in German. `koch`:cmd: is used mainly to build the
Nim compiler, but it can also be used for other tasks. This document
describes the supported commands and their options.

Expand All @@ -33,12 +33,11 @@ boot command
The `boot`:idx: command bootstraps the compiler, and it accepts different
options:

-d:release
By default a debug version is created, passing this option will
-d:release By default a debug version is created, passing this option will
force a release build, which is much faster and should be preferred
unless you are debugging the compiler.
-d:nimUseLinenoise
Use the linenoise library for interactive mode (not needed on Windows).
-d:nimUseLinenoise Use the linenoise library for interactive mode
(not needed on Windows).

After compilation is finished you will hopefully end up with the nim
compiler in the `bin` directory. You can add Nim's `bin` directory to
Expand All @@ -56,16 +55,16 @@ temp command
------------

The temp command builds the Nim compiler but with a different final name
(`nim_temp`), so it doesn't overwrite your normal compiler. You can use
(`nim_temp`:cmd:), so it doesn't overwrite your normal compiler. You can use
this command to test different options, the same you would issue for the `boot
command <#commands-boot-command>`_.

test command
------------

The `test`:idx: command can also be invoked with the alias `tests`. This
command will compile and run `testament/tester.nim`, which is the main
driver of Nim's test suite. You can pass options to the `test` command,
The `test`:idx: command can also be invoked with the alias `tests`:option:. This
command will compile and run ``testament/tester.nim``, which is the main
driver of Nim's test suite. You can pass options to the `test`:option: command,
they will be forwarded to the tester. See its source code for available
options.

Expand All @@ -74,13 +73,13 @@ web command

The `web`:idx: command converts the documentation in the `doc` directory
from rst to HTML. It also repeats the same operation but places the result in
the `web/upload` which can be used to update the website at
the ``web/upload`` which can be used to update the website at
https://nim-lang.org.

By default, the documentation will be built in parallel using the number of
available CPU cores. If any documentation build sub-commands fail, they will
be rerun in serial fashion so that meaningful error output can be gathered for
inspection. The `--parallelBuild:n` switch or configuration option can be
inspection. The `--parallelBuild:n`:option: switch or configuration option can be
used to force a specific number of parallel jobs or run everything serially
from the start (`n == 1`).

Expand All @@ -89,4 +88,4 @@ pdf command

The `pdf`:idx: command builds PDF versions of Nim documentation: Manual,
Tutorial and a few other documents. To run it one needs to
`install Latex/pdflatex <https://www.latex-project.org/get>`_ first.
`install Latex/xelatex <https://www.latex-project.org/get>`_ first.
12 changes: 6 additions & 6 deletions doc/lib.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.. default-role:: code

====================
Nim Standard Library
====================

:Author: Andreas Rumpf
:Version: |nimversion|

.. default-role:: code
.. include:: rstcommon.rst
.. contents::

Nim's library is divided into *pure libraries*, *impure libraries*, and *wrappers*.

Pure libraries do not depend on any external `*.dll` or `lib*.so` binary
Pure libraries do not depend on any external ``*.dll`` or ``lib*.so`` binary
while impure libraries do. A wrapper is an impure library that is a very
low-level interface to a C library.

Expand Down Expand Up @@ -39,11 +39,11 @@ Automatic imports

* `threads <threads.html>`_
Basic Nim thread support. **Note:** This is part of the system module. Do not
import it explicitly. Enabled with `--threads:on`.
import it explicitly. Enabled with `--threads:on`:option:.

* `channels <channels_builtin.html>`_
Nim message passing support for threads. **Note:** This is part of the
system module. Do not import it explicitly. Enabled with `--threads:on`.
system module. Do not import it explicitly. Enabled with `--threads:on`:option:.


Core
Expand Down Expand Up @@ -366,7 +366,7 @@ Parsers

* `parsecfg <parsecfg.html>`_
The `parsecfg` module implements a high-performance configuration file
parser. The configuration file's syntax is similar to the Windows `.ini`
parser. The configuration file's syntax is similar to the Windows ``.ini``
format, but much more powerful, as it is not a line based parser. String
literals, raw string literals, and triple quote string literals are supported
as in the Nim programming language.
Expand Down
48 changes: 25 additions & 23 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ In the following examples, `-1` is a single token:
"abc";-1
In the following examples, `-1` is parsed as two separate tokens (as `- 1`):
In the following examples, `-1` is parsed as two separate tokens
(as `-`:tok: `1`:tok:):

.. code-block:: nim
Expand Down Expand Up @@ -2509,7 +2510,7 @@ of the argument.
range.
3. Generic match: `f` is a generic type and `a` matches, for
instance `a` is `int` and `f` is a generic (constrained) parameter
type (like in `[T]` or `[T: int|char]`.
type (like in `[T]` or `[T: int|char]`).
4. Subrange or subtype match: `a` is a `range[T]` and `T`
matches `f` exactly. Or: `a` is a subtype of `f`.
5. Integral conversion match: `a` is convertible to `f` and `f` and `a`
Expand Down Expand Up @@ -3840,7 +3841,7 @@ Type bound operators currently include:
(some of which are still implementation defined and not yet documented).

For more details on some of those procs, see
`lifetimeminustracking-hooks <destructors.html#lifetimeminustracking-hooks>`_.
`Lifetime-tracking hooks <destructors.html#lifetimeminustracking-hooks>`_.

Nonoverloadable builtins
------------------------
Expand Down Expand Up @@ -5283,7 +5284,7 @@ instantiations cross multiple different modules:
In module B has an `init` proc from module C in its scope that is not
taken into account when `genericB` is instantiated which leads to the
instantiation of `genericA`. The solution is to `forward`:idx these
instantiation of `genericA`. The solution is to `forward`:idx: these
symbols by a `bind` statement inside `genericB`.


Expand Down Expand Up @@ -7305,19 +7306,19 @@ Produces:
supplied pattern to denote the concrete type parameters of the generic type.
See the usage of the apostrophe operator in proc patterns for more details.

.. code-block:: nim
.. code-block:: nim
type
VectorIterator {.importcpp: "std::vector<'0>::iterator".} [T] = object
type
VectorIterator {.importcpp: "std::vector<'0>::iterator".} [T] = object
var x: VectorIterator[cint]
var x: VectorIterator[cint]
Produces:
Produces:

.. code-block:: C
.. code-block:: C
std::vector<int>::iterator x;
std::vector<int>::iterator x;
ImportJs pragma
Expand Down Expand Up @@ -7444,7 +7445,7 @@ compile-time define pragmas
---------------------------

The pragmas listed here can be used to optionally accept values from
the -d/--define option at compile time.
the `-d/--define`:option: option at compile time.

The implementation currently provides the following possible options (various
others may be added later).
Expand All @@ -7461,7 +7462,7 @@ pragma description
const FooBar {.intdefine.}: int = 5
echo FooBar
::
.. code:: cmd
nim c -d:FooBar=42 foobar.nim
In the above example, providing the `-d`:option: flag causes the symbol
Expand All @@ -7480,7 +7481,8 @@ pragma pragma
-------------

The `pragma` pragma can be used to declare user-defined pragmas. This is
useful because Nim's templates and macros do not affect pragmas. User-defined pragmas are in a different module-wide scope than all other symbols.
useful because Nim's templates and macros do not affect pragmas.
User-defined pragmas are in a different module-wide scope than all other symbols.
They cannot be imported from a module.

Example:
Expand Down Expand Up @@ -7553,18 +7555,18 @@ More examples with custom pragmas:

- Better serialization/deserialization control:

.. code-block:: nim
type MyObj = object
a {.dontSerialize.}: int
b {.defaultDeserialize: 5.}: int
c {.serializationKey: "_c".}: string
.. code-block:: nim
type MyObj = object
a {.dontSerialize.}: int
b {.defaultDeserialize: 5.}: int
c {.serializationKey: "_c".}: string
- Adopting type for gui inspector in a game engine:

.. code-block:: nim
type MyComponent = object
position {.editable, animatable.}: Vector3
alpha {.editRange: [0.0..1.0], animatable.}: float32
.. code-block:: nim
type MyComponent = object
position {.editable, animatable.}: Vector3
alpha {.editRange: [0.0..1.0], animatable.}: float32
Macro pragmas
Expand Down
Loading

0 comments on commit 8d3c470

Please sign in to comment.