Skip to content

Commit 078d355

Browse files
authored
Add a guideline for describing method/function parameters and configuration parameters (#2869)
* Add guidelines * Update examples so they match the requirements
1 parent 78fee07 commit 078d355

File tree

3 files changed

+83
-17
lines changed

3 files changed

+83
-17
lines changed

doc/contributing/docs/_includes/class_template.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
Search for a tuple :ref:`via the given index <box_index-note>`.
66

7-
:param index_object index_object: an :ref:`object reference
8-
<app_server-object_reference>`.
7+
:param index_object index_object: :ref:`object reference
8+
<app_server-object_reference>`
99
:param scalar/table key: values to be matched against the index key
1010

1111
:return: the tuple whose index-key fields are equal to the passed key values
1212
:rtype: tuple
1313

1414
**Possible errors:**
1515

16-
* no such index;
17-
* wrong type;
18-
* more than one tuple matches.
16+
* No such index
17+
* Wrong type
18+
* More than one tuple matches
1919

20-
**Complexity factors:** Index size, Index type.
20+
**Complexity factors:** index size, index type.
2121
See also :ref:`space_object:get() <box_space-get>`.
2222

2323
**Example:**
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. confval:: wal_dir
2+
3+
Since version 1.6.2.
4+
A directory where write-ahead log (``.xlog``) files are stored.
5+
Can be relative to :ref:`work_dir <cfg_basic-work_dir>`.
6+
Sometimes ``wal_dir`` and :ref:`memtx_dir <cfg_basic-memtx_dir>` are specified with different values,
7+
so that write-ahead log files and snapshot files can be stored on different disks.
8+
If not specified, defaults to ``work_dir``.
9+
10+
| Type: string
11+
| Default: "."
12+
| Environment variable: TT_WAL_DIR
13+
| Dynamic: no

doc/contributing/docs/examples.rst

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ as well as examples and templates.
66

77
Use this checklist for documenting a function or a method:
88

9-
* Base description
10-
* Parameters
11-
* What this function returns (if nothing, write 'none')
12-
* Return type (if exists)
13-
* Possible errors (if exist)
14-
* Complexity factors (if exist)
15-
* Usage with memtx and vinyl (if differs)
16-
* Example(s)
17-
* Extra information (if needed)
9+
* General description
10+
* :ref:`Parameters <documenting_parameters>`
11+
* What this function returns (if nothing, write 'none')
12+
* Return type (if exists)
13+
* Possible errors (if exist)
14+
* Complexity factors (if exist)
15+
* Usage with memtx and vinyl (if differs)
16+
* Example(s)
17+
* Extra information (if needed)
1818

1919
Documenting functions
20-
~~~~~~~~~~~~~~~~~~~~~
20+
---------------------
2121

2222
We use the Sphinx directives ``.. module::``
2323
and ``.. function::`` to describe functions of Tarantool modules:
@@ -29,8 +29,12 @@ The resulting output looks like this:
2929

3030
.. include:: ./_includes/function_template.rst
3131

32+
.. note::
33+
34+
The best practices for :ref:`parameter description <documenting_parameters>` are listed below.
35+
3236
Documenting class methods and data
33-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37+
----------------------------------
3438

3539
Methods are described similarly to functions, but the ``.. class::``
3640
directive, unlike ``.. module::``, requires nesting.
@@ -46,3 +50,52 @@ the method and data of the ``index_object`` class:
4650
And the resulting output looks like this:
4751

4852
.. include:: ./_includes/class_template.rst
53+
54+
.. note::
55+
56+
The best practices for :ref:`parameter description <documenting_parameters>` are listed below.
57+
58+
.. _documenting_parameters:
59+
60+
Parameters in functions and classes
61+
-----------------------------------
62+
63+
This section explains how to document specific function or class method parameters as described above.
64+
To learn how to document :doc:`configuration parameters </reference/configuration/index>`
65+
passed to Tarantool via the command line or in an initialization file,
66+
see the :ref:`next section <documenting_confvals>`.
67+
68+
For every function or class method parameter, list the following details:
69+
70+
* General description
71+
* Type
72+
* If optional, indicate *(optional)* in parentheses
73+
* Default value (if optional), possible values
74+
75+
In the "Possible errors" section of the function or class method,
76+
consider explaining what happens if the parameter hasn't been defined or has the wrong value.
77+
78+
.. _documenting_confvals:
79+
80+
Configuration parameters
81+
------------------------
82+
83+
For every configuration parameter, list the following details:
84+
85+
* Since which Tarantool version
86+
* General description
87+
* Type
88+
* Corresponding environment variable (if applicable)
89+
* Default value
90+
* Possible values
91+
* Dynamic (yes or no)
92+
93+
Example
94+
^^^^^^^
95+
96+
.. literalinclude:: ./_includes/confval_template.rst
97+
:language: rst
98+
99+
Result:
100+
101+
.. include:: ./_includes/confval_template.rst

0 commit comments

Comments
 (0)