Skip to content

Commit b5636cb

Browse files
NickVolynkinpatiencedaurmaryartkey
authored
Fix links, wording and formatting in the Connectors section
Resolves #2365, #2320 Written by Nick Volynkin Translated by Maria Kovalevskaya, translation reviewed by Patience Daur Co-authored-by: Nick Volynkin <[email protected]> Co-authored-by: Patience Daur <[email protected]> Co-authored-by: Maria Kovalevskaya <[email protected]>
1 parent 4ce1848 commit b5636cb

26 files changed

+1921
-266
lines changed

doc/book/connectors/index.rst renamed to doc/book/connectors.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
This chapter documents APIs for various programming languages:
88

9-
* :doc:`C++ <cxx/tntcxx_api>`
9+
* :doc:`C++ <connectors/cxx/tntcxx_api>`
1010
* :ref:`Java <index_connector_java>`
1111
* :ref:`Go <index_connector_go>`
1212
* :ref:`R <index_connector_r>`
@@ -21,7 +21,7 @@ This chapter documents APIs for various programming languages:
2121
.. toctree::
2222
:hidden:
2323

24-
C++ <cxx/tntcxx_api>
24+
C++ <connectors/cxx/tntcxx_api>
2525

2626
=====================================================================
2727
Protocol
@@ -124,42 +124,42 @@ script:
124124
125125
.. _index_connector_java:
126126

127-
.. include:: __java.rst
127+
.. include:: connectors/__java.rst
128128

129129
.. _index_connector_go:
130130

131-
.. include:: __go.rst
131+
.. include:: connectors/__go.rst
132132

133133
.. _index_connector_r:
134134

135-
.. include:: __r.rst
135+
.. include:: connectors/__r.rst
136136

137137
.. _index_connector_erlang:
138138

139-
.. include:: __erlang.rst
139+
.. include:: connectors/__erlang.rst
140140

141141
.. _index_connector_perl:
142142

143-
.. include:: __perl.rst
143+
.. include:: connectors/__perl.rst
144144

145145
.. _index_connector_php:
146146

147-
.. include:: __php.rst
147+
.. include:: connectors/__php.rst
148148

149149
.. _index_connector_py:
150150

151-
.. include:: __python.rst
151+
.. include:: connectors/__python.rst
152152

153153
.. _index_connector_nodejs:
154154

155-
.. include:: __nodejs.rst
155+
.. include:: connectors/__nodejs.rst
156156

157157
.. _index_connector_csharp:
158158

159-
.. include:: __csharp.rst
159+
.. include:: connectors/__csharp.rst
160160

161161
.. _index_connector_c:
162162

163-
.. include:: __c.rst
163+
.. include:: connectors/__c.rst
164164

165-
.. include:: __results.rst
165+
.. include:: connectors/__results.rst

doc/book/connectors/__c.rst

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
=====================================================================
2-
C
3-
=====================================================================
1+
C
2+
=
43

54
Here follow two examples of using Tarantool's high-level C API.
65

7-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8-
Example 1
9-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
Example 1
7+
---------
108

119
Here is a complete C program that inserts :code:`[99999,'B']` into
1210
space :code:`examples` via the high-level C API.
1311

14-
.. code-block:: c
12+
.. code-block:: c
1513
1614
#include <stdio.h>
1715
#include <stdlib.h>
@@ -44,7 +42,7 @@ space :code:`examples` via the high-level C API.
4442
Paste the code into a file named :file:`example.c` and install ``tarantool-c``.
4543
One way to install ``tarantool-c`` (using Ubuntu) is:
4644

47-
.. code-block:: console
45+
.. code-block:: console
4846
4947
$ git clone git://github.com/tarantool/tarantool-c.git ~/tarantool-c
5048
$ cd ~/tarantool-c
@@ -54,9 +52,9 @@ One way to install ``tarantool-c`` (using Ubuntu) is:
5452
$ make
5553
$ make install
5654
57-
To compile and link the program, say:
55+
To compile and link the program, run:
5856

59-
.. code-block:: console
57+
.. code-block:: console
6058
6159
$ # sometimes this is necessary:
6260
$ export LD_LIBRARY_PATH=/usr/local/lib
@@ -72,11 +70,14 @@ If Tarantool is not running on localhost with listen address = 3301, the program
7270
will print “Connection refused”.
7371
If the insert fails, the program will print "Insert failed" and an error number
7472
(see all error codes in the source file
75-
`/src/box/errcode.h <https://github.com/tarantool/tarantool/blob/2.1/src/box/errcode.h>`_).
73+
`/src/box/errcode.h <https://github.com/tarantool/tarantool/blob/2.1/src/box/errcode.h>`__).
7674

7775
Here are notes corresponding to comments in the example program.
7876

79-
**SETUP:** The setup begins by creating a stream.
77+
SETUP
78+
~~~~~
79+
80+
The setup begins by creating a stream.
8081

8182
.. code-block:: c
8283
@@ -96,28 +97,34 @@ Function description:
9697
struct tnt_stream *tnt_net(struct tnt_stream *s)
9798
int tnt_set(struct tnt_stream *s, int option, variant option-value)
9899
99-
**CONNECT:** Now that the stream named ``tnt`` exists and is associated with a
100+
CONNECT
101+
~~~~~~~
102+
103+
Now that the stream named ``tnt`` exists and is associated with a
100104
URI, this example program can connect to a server instance.
101105

102-
.. code-block:: c
106+
.. code-block:: c
103107
104108
if (tnt_connect(tnt) < 0)
105109
{ printf("Connection refused\n"); exit(-1); }
106110
107111
Function description:
108112

109-
.. code-block:: text
113+
.. code-block:: text
110114
111115
int tnt_connect(struct tnt_stream *s)
112116
113117
The connection might fail for a variety of reasons, such as:
114118
the server is not running, or the URI contains an invalid :ref:`password<authentication-passwords>`.
115119
If the connection fails, the return value will be -1.
116120

117-
**MAKE REQUEST:** Most requests require passing a structured value, such as
121+
MAKE REQUEST
122+
~~~~~~~~~~~~
123+
124+
Most requests require passing a structured value, such as
118125
the contents of a tuple.
119126

120-
.. code-block:: c
127+
.. code-block:: c
121128
122129
struct tnt_stream *tuple = tnt_object(NULL);
123130
tnt_object_format(tuple, "[%d%s]", 99999, "B");
@@ -133,14 +140,17 @@ then the integer value, then a pointer to the string value.
133140

134141
Function description:
135142

136-
.. code-block:: text
143+
.. code-block:: text
137144
138145
ssize_t tnt_object_format(struct tnt_stream *s, const char *fmt, ...)
139146
140-
**SEND REQUEST:** The database-manipulation requests are analogous to the
147+
SEND REQUEST
148+
~~~~~~~~~~~~
149+
150+
The database-manipulation requests are analogous to the
141151
requests in the box library.
142152

143-
.. code-block:: c
153+
.. code-block:: c
144154
145155
tnt_insert(tnt, 999, tuple);
146156
tnt_flush(tnt);
@@ -152,7 +162,7 @@ the program passes the ``tnt_stream`` that was used for connection
152162

153163
Function description:
154164

155-
.. code-block:: text
165+
.. code-block:: text
156166
157167
ssize_t tnt_insert(struct tnt_stream *s, uint32_t space, struct tnt_stream *tuple)
158168
ssize_t tnt_replace(struct tnt_stream *s, uint32_t space, struct tnt_stream *tuple)
@@ -162,10 +172,13 @@ Function description:
162172
ssize_t tnt_update(struct tnt_stream *s, uint32_t space, uint32_t index,
163173
struct tnt_stream *key, struct tnt_stream *ops)
164174
165-
**GET REPLY:** For most requests, the client will receive a reply containing some
175+
GET REPLY
176+
~~~~~~~~~
177+
178+
For most requests, the client will receive a reply containing some
166179
indication whether the result was successful, and a set of tuples.
167180

168-
.. code-block:: c
181+
.. code-block:: c
169182
170183
struct tnt_reply reply; tnt_reply_init(&reply);
171184
tnt->read_reply(tnt, &reply);
@@ -176,40 +189,42 @@ This program checks for success but does not decode the rest of the reply.
176189

177190
Function description:
178191

179-
.. code-block:: text
192+
.. code-block:: text
180193
181194
struct tnt_reply *tnt_reply_init(struct tnt_reply *r)
182195
tnt->read_reply(struct tnt_stream *s, struct tnt_reply *r)
183196
void tnt_reply_free(struct tnt_reply *r)
184197
185-
**TEARDOWN:** When a session ends, the connection that was made with
198+
TEARDOWN
199+
~~~~~~~~
200+
201+
When a session ends, the connection that was made with
186202
:c:func:`tarantoolc:tnt_connect()` should be closed, and the objects that were
187203
made in the setup should be destroyed.
188204

189-
.. code-block:: c
205+
.. code-block:: c
190206
191207
tnt_close(tnt);
192208
tnt_stream_free(tuple);
193209
tnt_stream_free(tnt);
194210
195211
Function description:
196212

197-
.. code-block:: text
213+
.. code-block:: text
198214
199215
void tnt_close(struct tnt_stream *s)
200216
void tnt_stream_free(struct tnt_stream *s)
201217
202-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203-
Example 2
204-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
218+
Example 2
219+
---------
205220

206221
Here is a complete C program that selects, using index key ``[99999]``, from
207222
space ``examples`` via the high-level C API.
208223
To display the results, the program uses functions in the
209-
`MsgPuck <https://github.com/tarantool/msgpuck>`_ library which allow decoding of
210-
`MessagePack <https://en.wikipedia.org/wiki/MessagePack>`_ arrays.
224+
`MsgPuck <https://github.com/tarantool/msgpuck>`__ library which allow decoding of
225+
`MessagePack <https://en.wikipedia.org/wiki/MessagePack>`__ arrays.
211226

212-
.. code-block:: c
227+
.. code-block:: c
213228
214229
#include <stdio.h>
215230
#include <stdlib.h>
@@ -281,13 +296,13 @@ Similarly to the first example, paste the code into a file named
281296

282297
To compile and link the program, say:
283298

284-
.. code-block:: console
299+
.. code-block:: console
285300
286301
$ gcc -o example2 example2.c -ltarantool
287302
288303
To run the program, say :samp:`./example2`.
289304

290305
The two example programs only show a few requests and do not show all that's
291306
necessary for good practice. See more in the
292-
`tarantool-c documentation at GitHub <http://github.com/tarantool/tarantool-c>`_.
307+
`tarantool-c documentation at GitHub <http://github.com/tarantool/tarantool-c>`__.
293308

0 commit comments

Comments
 (0)