Skip to content

Commit 5deeae9

Browse files
patiencedaurveod32p7novTotktonada
authored
Actualize the API documentation style guide
This guide aims to help Tarantool developers to document the API in a consistent manner. * Provide a better title for API documentation guidelines * Elaborate on best style practices * Restructure the guide * Add a CONTRIBUTING file * Separate version formatting guidelines for RN and API Use :tarantool-release: in release notes and :doc:`x.y.z </release/x.y.z>` in API reference. * Add complexity factor note and links * Give an example of optional parameters in square brackets * Make a stub "Possible errors" section Co-authored-by: Evgeniy Osintsev <[email protected]> Co-authored-by: Pavel Semyonov <[email protected]> Co-authored-by: Alexander Turenko <[email protected]>
1 parent 98f2bc9 commit 5deeae9

9 files changed

+220
-106
lines changed

CONTRIBUTING.rst

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Contributing
2+
============
3+
4+
Please see
5+
our `documentation and localization guidelines <https://www.tarantool.io/en/doc/latest/contributing/docs/>`_
6+
on the Tarantool website.
7+
8+
Хотите участвовать в локализации Tarantool на русский язык?
9+
Переходите в `эту GitHub-дискуссию <https://github.com/tarantool/doc/discussions/2738>`_.

doc/book/box/data_model.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ See reference on ``box.space`` for more
10351035
The client server protocol is open and documented.
10361036
See this :ref:`annotated BNF <box_protocol-iproto_protocol>`.
10371037

1038+
.. _index-box_complexity-factors:
10381039

10391040
Complexity factors
10401041
~~~~~~~~~~~~~~~~~~

doc/contributing/docs.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The guidelines are a work in progress, and we welcome all contributions.
1616
docs/localization
1717
docs/terms
1818
docs/markup
19-
docs/examples
19+
docs/api
2020
docs/build
2121
docs/sphinx-warnings
2222
docs/infra

doc/contributing/docs/_includes/confval_template.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. confval:: wal_dir
22

3-
Since version 1.6.2.
4-
A directory where write-ahead log (``.xlog``) files are stored.
3+
Since :tarantool-release:`1.6.2`.
4+
The directory where write-ahead log (``.xlog``) files are stored.
55
Can be relative to :ref:`work_dir <cfg_basic-work_dir>`.
66
Sometimes ``wal_dir`` and :ref:`memtx_dir <cfg_basic-memtx_dir>` are specified with different values,
77
so that write-ahead log files and snapshot files can be stored on different disks.

doc/contributing/docs/_includes/function_template.rst

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
:param function: the function to be associated with the fiber
88
:param function-arguments: what will be passed to function.
9-
If the arguments are optional, put them in
10-
square brackets in the function declaration.
119

1210
:return: created fiber object
1311
:rtype: userdata

doc/contributing/docs/api.rst

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
Documenting the API
2+
===================
3+
4+
This document contains general guidelines for describing the Tarantool API,
5+
as well as examples and templates.
6+
7+
Style
8+
-----
9+
10+
Please write as simply as possible. Describe functionality using short sentences in the present simple tense.
11+
A short sentence consists of no more than two clauses.
12+
Consider using `LanguageTool <https://languagetool.org/>`_ or `Grammarly <https://www.grammarly.com/>`_
13+
to check your English.
14+
For more style-related specifics, consult the :doc:`Language and style </contributing/docs/style>` section.
15+
16+
.. _contributing-docs-api_version:
17+
18+
Indicating the version
19+
----------------------
20+
21+
For every new module, function, or method, specify the version it first appears in.
22+
23+
For a new parameter, specify the version it first appears in if this parameter is a "feature"
24+
and the version it's been introduced in differs from
25+
the version introducing the function/method and all other parameters.
26+
27+
To specify the version, use the following Sphinx directive:
28+
29+
.. code-block:: rst
30+
31+
Since :doc:`2.10.0 </release/2.10.0>`.
32+
This is a link to the release notes on the Tarantool documentation website.
33+
34+
The result looks like this:
35+
36+
Since Tarantool :doc:`2.10.0 </release/2.10.0>`.
37+
This is a link to the release notes on the Tarantool documentation website.
38+
39+
.. _contributing-api-docs_general-description:
40+
41+
Language of the general description
42+
-----------------------------------
43+
44+
Use one of the two options:
45+
46+
* Start with a verb in the imperative mood. Example: *Create a fiber.*
47+
* Start with a noun. Example: *The directory where memtx stores snapshot files.*
48+
49+
Checklist
50+
---------
51+
52+
Each list item is a characteristic to be described. Some items can be optional.
53+
54+
Function or method
55+
^^^^^^^^^^^^^^^^^^
56+
57+
* :ref:`Since which Tarantool version <contributing-docs-api_version>`
58+
* :ref:`General description <contributing-api-docs_general-description>`
59+
* :ref:`Parameters <documenting_parameters>`
60+
* What this function returns (if nothing, write 'none')
61+
* Return type (if exists)
62+
* :ref:`Possible errors <contributing-docs-possible_errors>` (if exist)
63+
* :ref:`Complexity factors <index-box_complexity-factors>`
64+
(for :doc:`CRUD operations </reference/reference_lua/box_space>` and
65+
:doc:`index access functions </reference/reference_lua/box_index/>`)
66+
* Usage with memtx and vinyl (if differs)
67+
* Example(s)
68+
* Extra information (if needed)
69+
70+
See :ref:`module function example <contributing-api-docs_function-example>`,
71+
:ref:`class method example <contributing-api-docs_class-example>`.
72+
73+
Data
74+
^^^^
75+
76+
* :ref:`Since which Tarantool version <contributing-docs-api_version>`
77+
* :ref:`General description <contributing-api-docs_general-description>`
78+
* Return type
79+
* Example
80+
81+
See :ref:`class data example <contributing-api-docs_class-example>`.
82+
83+
.. _documenting_parameters:
84+
85+
Function and method parameters
86+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87+
88+
* :ref:`Since which Tarantool version <contributing-docs-api_version>`
89+
(if added later)
90+
* :ref:`General description <contributing-api-docs_general-description>`
91+
* Type
92+
* Default value (if optional), possible values
93+
94+
If the parameter is optional, make sure it is enclosed in square brackets
95+
in the function declaration (in the "heading").
96+
Do not mark parameters additionaly as "optional" or "required":
97+
98+
.. code-block:: rst
99+
100+
.. function:: format(URI-components-table[, include-password])
101+
102+
Construct a URI from components.
103+
104+
:param URI-components-table: a series of ``name:value`` pairs, one for each component
105+
:param include-password: boolean. If this is supplied and is ``true``, then
106+
the password component is rendered in clear text,
107+
otherwise it is omitted.
108+
109+
.. _documenting_confvals:
110+
111+
Configuration parameters
112+
^^^^^^^^^^^^^^^^^^^^^^^^
113+
114+
Configuration parameters are not to be confused with class and method parameters.
115+
Configuration parameters are passed to Tarantool via the command line or in an initialization file.
116+
You can find a list of Tarantool configuration parameters in the :doc:`configuration reference </reference/configuration/index>`.
117+
118+
* :ref:`Since which Tarantool version <contributing-docs-api_version>`
119+
* :ref:`General description <contributing-api-docs_general-description>`
120+
* Type
121+
* Corresponding environment variable (if applicable)
122+
* Default value
123+
* Possible values (can be included in the general description, for example, as a list)
124+
* Dynamic (yes or no)
125+
126+
See :ref:`configuration parameter example <contributing-api-docs_confval-example>`.
127+
128+
.. _contributing-docs-possible_errors:
129+
130+
Documenting possible errors
131+
---------------------------
132+
133+
In the "Possible errors" section of a function or class method,
134+
consider explaining what happens if any parameter hasn't been defined or has the wrong value.
135+
136+
Examples and templates
137+
----------------------
138+
139+
.. _contributing-api-docs_function-example:
140+
141+
Module functions
142+
^^^^^^^^^^^^^^^^
143+
144+
We use the Sphinx directives ``.. module::``
145+
and ``.. function::`` to describe functions of Tarantool modules:
146+
147+
.. literalinclude:: ./_includes/function_template.rst
148+
:language: rst
149+
150+
The resulting output looks like this:
151+
152+
.. include:: ./_includes/function_template.rst
153+
154+
155+
.. _contributing-api-docs_class-example:
156+
157+
Class methods and data
158+
^^^^^^^^^^^^^^^^^^^^^^
159+
160+
Methods are described similarly to functions, but the ``.. class::``
161+
directive, unlike ``.. module::``, requires nesting.
162+
163+
As for data, it's enough to write the description, the return type, and an example.
164+
165+
Here is the example documentation describing
166+
the method and data of the ``index_object`` class:
167+
168+
.. literalinclude:: ./_includes/class_template.rst
169+
:language: rst
170+
171+
And the resulting output looks like this:
172+
173+
.. include:: ./_includes/class_template.rst
174+
175+
.. _contributing-api-docs_confval-example:
176+
177+
Configuration parameters
178+
^^^^^^^^^^^^^^^^^^^^^^^^
179+
180+
Example:
181+
182+
.. literalinclude:: ./_includes/confval_template.rst
183+
:language: rst
184+
185+
Result:
186+
187+
.. include:: ./_includes/confval_template.rst

doc/contributing/docs/examples.rst

-100
This file was deleted.

doc/contributing/docs/style.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ Use the US English spelling.
213213
Check your spelling and punctuation
214214
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215215

216-
Consider checking spelling, grammar, and punctuation with special tools.
216+
Consider checking spelling, grammar, and punctuation with special tools like
217+
`LanguageTool <https://languagetool.org/>`_ or `Grammarly <https://www.grammarly.com/>`_.
217218

218219
Dashes
219220
~~~~~~

doc/contributing/release_notes.rst

+18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ How to write release notes
33

44
Below are some best practices to make changelogs consistent, neat, and human-oriented.
55

6+
Language
7+
--------
8+
69
* Use the past tense to describe changed or fixed behavior.
710

811
.. admonition:: Examples
@@ -23,3 +26,18 @@ Below are some best practices to make changelogs consistent, neat, and human-ori
2326

2427
Note that these guidelines differ from the best practice for commit message titles
2528
that suggests using the imperative mood.
29+
30+
Formatting
31+
----------
32+
33+
In release notes, use the following Sphinx syntax when referring to a specific version of Tarantool:
34+
35+
.. code-block:: rst
36+
37+
Tarantool :tarantool-release:`2.10.0`.
38+
This is a link to the release notes on GitHub.
39+
40+
The result looks like this:
41+
42+
Tarantool :tarantool-release:`2.10.0`.
43+
This is a link to the release notes on GitHub.

0 commit comments

Comments
 (0)