aboutsummaryrefslogtreecommitdiff
path: root/docs/src
diff options
context:
space:
mode:
authorraisinten <raisinten@gmail.com>2020-12-29 19:53:16 +0530
committerSantiago Gimeno <santiago.gimeno@gmail.com>2021-02-14 09:13:34 +0100
commitc3d08b5d63267c70554da081ce9f35dfb81132e2 (patch)
tree62af85169a3a644606ef8e9417d5fe853dd114e5 /docs/src
parent4b0d8b2c93a8fdff91ce7566ba8e1089e547afc4 (diff)
downloadlibuv-c3d08b5d63267c70554da081ce9f35dfb81132e2.tar.gz
libuv-c3d08b5d63267c70554da081ce9f35dfb81132e2.zip
doc: fix code highlighting
Affected docs: * basics.rst * filesystem.rst * eventloops.rst * networking.rst * processes.rst * threads.rst * utilities.rst Fixes: https://github.com/libuv/libuv/issues/3033 PR-URL: https://github.com/libuv/libuv/pull/3082 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Diffstat (limited to 'docs/src')
-rw-r--r--docs/src/guide/basics.rst2
-rw-r--r--docs/src/guide/eventloops.rst2
-rw-r--r--docs/src/guide/filesystem.rst9
-rw-r--r--docs/src/guide/networking.rst7
-rw-r--r--docs/src/guide/processes.rst15
-rw-r--r--docs/src/guide/threads.rst12
-rw-r--r--docs/src/guide/utilities.rst13
7 files changed, 60 insertions, 0 deletions
diff --git a/docs/src/guide/basics.rst b/docs/src/guide/basics.rst
index 1da8d5ef..e55a20cf 100644
--- a/docs/src/guide/basics.rst
+++ b/docs/src/guide/basics.rst
@@ -87,6 +87,7 @@ nothing, except start a loop which will exit immediately.
.. rubric:: helloworld/main.c
.. literalinclude:: ../../code/helloworld/main.c
+ :language: c
:linenos:
This program quits immediately because it has no events to process. A libuv
@@ -202,6 +203,7 @@ event watchers are active.
.. rubric:: idle-basic/main.c
.. literalinclude:: ../../code/idle-basic/main.c
+ :language: c
:emphasize-lines: 6,10,14-17
Storing context
diff --git a/docs/src/guide/eventloops.rst b/docs/src/guide/eventloops.rst
index fd9df5fb..12244ff6 100644
--- a/docs/src/guide/eventloops.rst
+++ b/docs/src/guide/eventloops.rst
@@ -20,6 +20,7 @@ these things can be a bit difficult to understand, so let's look at
.. rubric:: src/unix/core.c - uv_run
.. literalinclude:: ../../../src/unix/core.c
+ :language: c
:linenos:
:lines: 304-324
:emphasize-lines: 10,19,21
@@ -43,6 +44,7 @@ iteration of the loop still takes places.
.. rubric:: uvstop/main.c
.. literalinclude:: ../../code/uvstop/main.c
+ :language: c
:linenos:
:emphasize-lines: 11
diff --git a/docs/src/guide/filesystem.rst b/docs/src/guide/filesystem.rst
index e89d4cd5..2d5f6cb9 100644
--- a/docs/src/guide/filesystem.rst
+++ b/docs/src/guide/filesystem.rst
@@ -54,6 +54,7 @@ a callback for when the file is opened:
.. rubric:: uvcat/main.c - opening a file
.. literalinclude:: ../../code/uvcat/main.c
+ :language: c
:linenos:
:lines: 41-53
:emphasize-lines: 4, 6-7
@@ -63,6 +64,7 @@ The ``result`` field of a ``uv_fs_t`` is the file descriptor in case of the
.. rubric:: uvcat/main.c - read callback
.. literalinclude:: ../../code/uvcat/main.c
+ :language: c
:linenos:
:lines: 26-40
:emphasize-lines: 2,8,12
@@ -87,6 +89,7 @@ callbacks.
.. rubric:: uvcat/main.c - write callback
.. literalinclude:: ../../code/uvcat/main.c
+ :language: c
:linenos:
:lines: 16-24
:emphasize-lines: 6
@@ -100,6 +103,7 @@ We set the dominos rolling in ``main()``:
.. rubric:: uvcat/main.c
.. literalinclude:: ../../code/uvcat/main.c
+ :language: c
:linenos:
:lines: 55-
:emphasize-lines: 2
@@ -203,6 +207,7 @@ opened as bidirectional by default.
.. rubric:: uvtee/main.c - read on pipes
.. literalinclude:: ../../code/uvtee/main.c
+ :language: c
:linenos:
:lines: 61-80
:emphasize-lines: 4,5,15
@@ -218,6 +223,7 @@ these buffers.
.. rubric:: uvtee/main.c - reading buffers
.. literalinclude:: ../../code/uvtee/main.c
+ :language: c
:linenos:
:lines: 19-22,44-60
@@ -242,6 +248,7 @@ point there is nothing to be read. Most applications will just ignore this.
.. rubric:: uvtee/main.c - Write to pipe
.. literalinclude:: ../../code/uvtee/main.c
+ :language: c
:linenos:
:lines: 9-13,23-42
@@ -282,6 +289,7 @@ The file change notification is started using ``uv_fs_event_init()``:
.. rubric:: onchange/main.c - The setup
.. literalinclude:: ../../code/onchange/main.c
+ :language: c
:linenos:
:lines: 26-
:emphasize-lines: 15
@@ -320,6 +328,7 @@ In our example we simply print the arguments and run the command using
.. rubric:: onchange/main.c - file change notification callback
.. literalinclude:: ../../code/onchange/main.c
+ :language: c
:linenos:
:lines: 9-24
diff --git a/docs/src/guide/networking.rst b/docs/src/guide/networking.rst
index b2f3fc77..50a191dd 100644
--- a/docs/src/guide/networking.rst
+++ b/docs/src/guide/networking.rst
@@ -38,6 +38,7 @@ Here is a simple echo server
.. rubric:: tcp-echo-server/main.c - The listen socket
.. literalinclude:: ../../code/tcp-echo-server/main.c
+ :language: c
:linenos:
:lines: 68-
:emphasize-lines: 4-5,7-10
@@ -60,6 +61,7 @@ In this case we also establish interest in reading from this stream.
.. rubric:: tcp-echo-server/main.c - Accepting the client
.. literalinclude:: ../../code/tcp-echo-server/main.c
+ :language: c
:linenos:
:lines: 51-66
:emphasize-lines: 9-10
@@ -108,6 +110,7 @@ address from a `DHCP`_ server -- DHCP Discover.
.. rubric:: udp-dhcp/main.c - Setup and send UDP packets
.. literalinclude:: ../../code/udp-dhcp/main.c
+ :language: c
:linenos:
:lines: 7-11,104-
:emphasize-lines: 8,10-11,17-18,21
@@ -143,6 +146,7 @@ the OS will discard the data that could not fit* (That's UDP for you!).
.. rubric:: udp-dhcp/main.c - Reading packets
.. literalinclude:: ../../code/udp-dhcp/main.c
+ :language: c
:linenos:
:lines: 17-40
:emphasize-lines: 1,23
@@ -193,6 +197,7 @@ Freenode to see an example of DNS resolution.
.. rubric:: dns/main.c
.. literalinclude:: ../../code/dns/main.c
+ :language: c
:linenos:
:lines: 61-
:emphasize-lines: 12
@@ -209,6 +214,7 @@ call ``uv_freeaddrinfo`` in the callback.
.. rubric:: dns/main.c
.. literalinclude:: ../../code/dns/main.c
+ :language: c
:linenos:
:lines: 42-60
:emphasize-lines: 8,16
@@ -227,6 +233,7 @@ useful to allow your service to bind to IP addresses when it starts.
.. rubric:: interfaces/main.c
.. literalinclude:: ../../code/interfaces/main.c
+ :language: c
:linenos:
:emphasize-lines: 9,17
diff --git a/docs/src/guide/processes.rst b/docs/src/guide/processes.rst
index cbd8bce7..c1278f17 100644
--- a/docs/src/guide/processes.rst
+++ b/docs/src/guide/processes.rst
@@ -27,6 +27,7 @@ exits. This is achieved using ``uv_spawn``.
.. rubric:: spawn/main.c
.. literalinclude:: ../../code/spawn/main.c
+ :language: c
:linenos:
:lines: 6-8,15-
:emphasize-lines: 11,13-17
@@ -54,6 +55,7 @@ which caused the exit.
.. rubric:: spawn/main.c
.. literalinclude:: ../../code/spawn/main.c
+ :language: c
:linenos:
:lines: 9-12
:emphasize-lines: 3
@@ -104,6 +106,7 @@ does not affect it.
.. rubric:: detach/main.c
.. literalinclude:: ../../code/detach/main.c
+ :language: c
:linenos:
:lines: 9-30
:emphasize-lines: 12,19
@@ -140,6 +143,7 @@ stop watching. Here is a small example demonstrating the various possibilities:
.. rubric:: signal/main.c
.. literalinclude:: ../../code/signal/main.c
+ :language: c
:linenos:
:emphasize-lines: 17-18,27-28
@@ -172,6 +176,7 @@ which is:
.. rubric:: proc-streams/test.c
.. literalinclude:: ../../code/proc-streams/test.c
+ :language: c
The actual program ``proc-streams`` runs this while sharing only ``stderr``.
The file descriptors of the child process are set using the ``stdio`` field in
@@ -199,6 +204,7 @@ Then we set the ``fd`` to ``stderr``.
.. rubric:: proc-streams/main.c
.. literalinclude:: ../../code/proc-streams/main.c
+ :language: c
:linenos:
:lines: 15-17,27-
:emphasize-lines: 6,10,11,12
@@ -217,12 +223,14 @@ A sample CGI script/executable is:
.. rubric:: cgi/tick.c
.. literalinclude:: ../../code/cgi/tick.c
+ :language: c
The CGI server combines the concepts from this chapter and :doc:`networking` so
that every client is sent ten ticks after which that connection is closed.
.. rubric:: cgi/main.c
.. literalinclude:: ../../code/cgi/main.c
+ :language: c
:linenos:
:lines: 49-63
:emphasize-lines: 10
@@ -232,6 +240,7 @@ Here we simply accept the TCP connection and pass on the socket (*stream*) to
.. rubric:: cgi/main.c
.. literalinclude:: ../../code/cgi/main.c
+ :language: c
:linenos:
:lines: 16, 25-45
:emphasize-lines: 8-9,18,20
@@ -291,6 +300,7 @@ messaging is no different from TCP, so we'll re-use the echo server example.
.. rubric:: pipe-echo-server/main.c
.. literalinclude:: ../../code/pipe-echo-server/main.c
+ :language: c
:linenos:
:lines: 70-
:emphasize-lines: 5,10,14
@@ -330,6 +340,7 @@ it by the master.
.. rubric:: multi-echo-server/worker.c
.. literalinclude:: ../../code/multi-echo-server/worker.c
+ :language: c
:linenos:
:lines: 7-9,81-
:emphasize-lines: 6-8
@@ -343,6 +354,7 @@ standard input of the worker, we connect the pipe to ``stdin`` using
.. rubric:: multi-echo-server/worker.c
.. literalinclude:: ../../code/multi-echo-server/worker.c
+ :language: c
:linenos:
:lines: 51-79
:emphasize-lines: 10,15,20
@@ -361,6 +373,7 @@ allow load balancing.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
+ :language: c
:linenos:
:lines: 9-13
@@ -369,6 +382,7 @@ master and the individual process.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
+ :language: c
:linenos:
:lines: 51,61-95
:emphasize-lines: 17,20-21
@@ -387,6 +401,7 @@ worker in the round-robin.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
+ :language: c
:linenos:
:lines: 31-49
:emphasize-lines: 9,12-13
diff --git a/docs/src/guide/threads.rst b/docs/src/guide/threads.rst
index c610d47c..3990e442 100644
--- a/docs/src/guide/threads.rst
+++ b/docs/src/guide/threads.rst
@@ -39,6 +39,7 @@ wait for it to close using ``uv_thread_join()``.
.. rubric:: thread-create/main.c
.. literalinclude:: ../../code/thread-create/main.c
+ :language: c
:linenos:
:lines: 26-36
:emphasize-lines: 3-7
@@ -55,6 +56,7 @@ thread, scheduled pre-emptively by the operating system:
.. rubric:: thread-create/main.c
.. literalinclude:: ../../code/thread-create/main.c
+ :language: c
:linenos:
:lines: 6-14
:emphasize-lines: 2
@@ -124,6 +126,7 @@ example.
.. rubric:: locks/main.c - simple rwlocks
.. literalinclude:: ../../code/locks/main.c
+ :language: c
:linenos:
:emphasize-lines: 13,16,27,31,42,55
@@ -208,6 +211,7 @@ event loop from performing other activities.
.. rubric:: queue-work/main.c - lazy fibonacci
.. literalinclude:: ../../code/queue-work/main.c
+ :language: c
:linenos:
:lines: 17-29
@@ -221,6 +225,7 @@ The trigger is ``uv_queue_work``:
.. rubric:: queue-work/main.c
.. literalinclude:: ../../code/queue-work/main.c
+ :language: c
:linenos:
:lines: 31-44
:emphasize-lines: 10
@@ -248,6 +253,7 @@ up a signal handler for termination.
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
+ :language: c
:linenos:
:lines: 43-
@@ -256,6 +262,7 @@ When the user triggers the signal by pressing ``Ctrl+C`` we send
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
+ :language: c
:linenos:
:lines: 33-41
:emphasize-lines: 6
@@ -265,6 +272,7 @@ with ``status`` set to ``UV_ECANCELED``.
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
+ :language: c
:linenos:
:lines: 28-31
:emphasize-lines: 2
@@ -292,6 +300,7 @@ informing the user of the status of running downloads.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
+ :language: c
:linenos:
:lines: 7-8,35-
:emphasize-lines: 2,11
@@ -317,6 +326,7 @@ with the async watcher whenever it receives a message.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
+ :language: c
:linenos:
:lines: 10-24
:emphasize-lines: 7-8
@@ -327,6 +337,7 @@ non-blocking and will return immediately.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
+ :language: c
:linenos:
:lines: 31-34
@@ -336,6 +347,7 @@ Finally it is important to remember to clean up the watcher.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
+ :language: c
:linenos:
:lines: 26-29
:emphasize-lines: 3
diff --git a/docs/src/guide/utilities.rst b/docs/src/guide/utilities.rst
index a863c5ea..4657b1b0 100644
--- a/docs/src/guide/utilities.rst
+++ b/docs/src/guide/utilities.rst
@@ -87,6 +87,7 @@ JS object and can be ref/unrefed.
.. rubric:: ref-timer/main.c
.. literalinclude:: ../../code/ref-timer/main.c
+ :language: c
:linenos:
:lines: 5-8, 17-
:emphasize-lines: 9
@@ -111,6 +112,7 @@ idle watcher to keep the UI operational.
.. rubric:: idle-compute/main.c
.. literalinclude:: ../../code/idle-compute/main.c
+ :language: c
:linenos:
:lines: 5-9, 34-
:emphasize-lines: 13
@@ -123,6 +125,7 @@ keep calling the idle callback again.
.. rubric:: idle-compute/main.c
.. literalinclude:: ../../code/idle-compute/main.c
+ :language: c
:linenos:
:lines: 10-19
@@ -215,6 +218,7 @@ progress with the download whenever libuv notifies of I/O readiness.
.. rubric:: uvwget/main.c - The setup
.. literalinclude:: ../../code/uvwget/main.c
+ :language: c
:linenos:
:lines: 1-9,140-
:emphasize-lines: 7,21,24-25
@@ -235,6 +239,7 @@ So we add each argument as an URL
.. rubric:: uvwget/main.c - Adding urls
.. literalinclude:: ../../code/uvwget/main.c
+ :language: c
:linenos:
:lines: 39-56
:emphasize-lines: 13-14
@@ -251,6 +256,7 @@ on sockets whenever ``handle_socket`` is called.
.. rubric:: uvwget/main.c - Setting up polling
.. literalinclude:: ../../code/uvwget/main.c
+ :language: c
:linenos:
:lines: 102-140
:emphasize-lines: 9,11,15,21,24
@@ -271,6 +277,7 @@ mask with the new value. ``curl_perform`` is the crux of this program.
.. rubric:: uvwget/main.c - Driving libcurl.
.. literalinclude:: ../../code/uvwget/main.c
+ :language: c
:linenos:
:lines: 81-95
:emphasize-lines: 2,6-7,12
@@ -288,6 +295,7 @@ transfers are done.
.. rubric:: uvwget/main.c - Reading transfer status.
.. literalinclude:: ../../code/uvwget/main.c
+ :language: c
:linenos:
:lines: 58-79
:emphasize-lines: 6,9-10,13-14
@@ -312,6 +320,7 @@ Let us first look at the interface provided to plugin authors.
.. rubric:: plugin/plugin.h
.. literalinclude:: ../../code/plugin/plugin.h
+ :language: c
:linenos:
You can similarly add more functions that plugin authors can use to do useful
@@ -319,6 +328,7 @@ things in your application [#]_. A sample plugin using this API is:
.. rubric:: plugin/hello.c
.. literalinclude:: ../../code/plugin/hello.c
+ :language: c
:linenos:
Our interface defines that all plugins should have an ``initialize`` function
@@ -340,6 +350,7 @@ This is done by using ``uv_dlopen`` to first load the shared library
.. rubric:: plugin/main.c
.. literalinclude:: ../../code/plugin/main.c
+ :language: c
:linenos:
:lines: 7-
:emphasize-lines: 15, 18, 24
@@ -393,6 +404,7 @@ Here is a simple example which prints white text on a red background:
.. rubric:: tty/main.c
.. literalinclude:: ../../code/tty/main.c
+ :language: c
:linenos:
:emphasize-lines: 11-12,14,17,27
@@ -403,6 +415,7 @@ escape codes.
.. rubric:: tty-gravity/main.c
.. literalinclude:: ../../code/tty-gravity/main.c
+ :language: c
:linenos:
:emphasize-lines: 19,25,38