8000 change README (#818) · IntelPython/sdc@e4d2e06 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit e4d2e06

Browse files
authored
change README (#818)
* change README * change README for doc * add refs * change ref * change ref * change ref * change readme
1 parent 296ff8b commit e4d2e06

File tree

2 files changed

+146
-138
lines changed

2 files changed

+146
-138
lines changed

README.rst

Lines changed: 1 addition & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -176,146 +176,9 @@ To build HTML documentation you will need to run:
176176
The built documentation will be located in the ``./sdc/docs/build/html`` directory.
177177
To preview the documentation open ``index.html`` file.
178178

179-
`Sphinx*`_ Generation Internals
180-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181179

182-
The documentation generation is controlled by ``conf.py`` script automatically invoked by `Sphinx*`_.
183-
See `Sphinx documentation <http://www.sphinx-doc.org/en/master/usage/configuration.html>`_ for details.
180+
More information about building and adding documentation can be found `here <docs/README.rst>`_.
184181

185-
The API Reference for Intel® SDC User's Guide is auto-generated by inspecting ``pandas`` and ``sdc`` modules.
186-
That's why these modules must be pre-installed for documentation generation using `Sphinx*`_.
187-
However, there is a possibility to skip API Reference auto-generation by setting environment variable ``SDC_DOC_NO_API_REF_STR=1``.
188-
189-
If the environment variable ``SDC_DOC_NO_API_REF_STR`` is unset then Sphinx's ``conf.py``
190-
invokes ``generate_api_reference()`` function located in ``./sdc/docs/source/buildscripts/apiref_generator`` module.
191-
This function parses ``pandas`` and ``sdc`` docstrings for each API, combines those into single docstring and
192-
writes it into RST file with respective `Pandas*`_ API name. The auto-generated RST files are
193-
located at ``./sdc/docs/source/_api_ref`` directory.
194-
195-
.. note::
196-
`Sphinx*`_ will automatically clean the ``_api_ref`` directory on the next invocation of the documenation build.
197-
198-
Intel® SDC docstring decoration rules
199-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200-
201-
Since Intel® SDC API Reference is auto-generated from respective `Pandas*`_ and Intel® SDC docstrings there are certain rules that must be
202-
followed to accurately generate the API description.
203-
204-
1. Every Intel® SDC API must have the docstring.
205-
If developer does not provide the docstring then `Sphinx*`_ will not be able to match `Pandas*`_ docstring with respective SDC one.
206-
In this situation `Sphinx*`_ assumes that SDC does not support such API and will include respective note in the API Reference that
207-
**This API is currently unsupported**.
208-
209-
2. Follow 'one function - one docstring' rule.
210-
You cannot have one docstring for multiple APIs, even if those are very similar. Auto-generator assumes every SDC API is covered by
211-
respective docstring. If `Sphinx*`_ does not find the docstring for particular API then it assumes that SDC does not support such API
212-
and will include respective note in the API Reference that **This API is currently unsupported**.
213-
214-
3. Description (introductory section, the very first few paragraphs without a title) is taken from `Pandas*`_.
215-
Intel® SDC developers should not include API description in SDC docstring.
216-
But developers are encouraged to follow Pandas API description naming conventions
217-
so that the combined docstring appears consistent.
218-
219-
4. Parameters, Returns, and Raises sections' description is taken from `Pandas*`_ docstring.
220-
Intel® SDC developers should not include such descriptions in their SDC docstrings.
221-
Rather developers are encouraged to follow Pandas naming conventions
222-
so that the combined docstring appears consistent.
223-
224-
5. Every SDC docstring must be of the follwing structure:
225-
::
226-
227-
"""
228-
Intel Scalable Dataframe Compiler User Guide
229-
********************************************
230-
Pandas API: <full pandas name, e.g. pandas.Series.nlargest>
231-
232-
<Intel® SDC specific sections>
233-
234-
Intel Scalable Dataframe Compiler Developer Guide
235-
*************************************************
236-
<Developer's Guide specific sections>
237-
"""
238-
239-
The first two lines must be the User Guide header. This is an indication to `Sphinx*`_ that this section is intended for public API
240-
and it will be combined with repsective Pandas API docstring.
241-
242-
Line 3 must specify what Pandas API this Intel® SDC docstring does correspond to. It must start with ``Pandas API:`` followed by
243-
full Pandas API name that corresponds to this SDC docstring. Remember to include full name, for example, ``nlargest`` is not
244-
sufficient for auto-generator to perform the match. The full name must be ``pandas.Series.nlargest``.
245-
246-
After User Guide sections in the docstring there can be another header indicating that the remaining part of the docstring belongs to
247-
Developer's Guide and must not be included into User's Guide.
248-
249-
6. Examples, See Also, References sections are **NOT** taken from Pandas docstring. SDC developers are expected to complete these sections in SDC doctrings.
250-
This is so because respective Pandas sections are sometimes too Pandas specific and are not relevant to SDC. SDC developers have to
251-
rewrite those sections in Intel® SDC style. Do not forget about User Guide header and Pandas API name prior to adding SDC specific
252-
sections.
253-
254-
7. Examples section is mandatory for every SDC API. 'One API - at least one example' rule is applied.
255-
Examples are essential part of user experience and must accompany every API docstring.
256-
257-
8. Embed examples into Examples section from ``./sdc/examples``.
258-
Rather than writing example in the docstring (which is error-prone) embed relevant example scripts into the docstring. For example,
259-
here is an example how to embed example for ``pandas.Series.get()`` function into respective Intel® SDC docstring:
260-
261-
::
262-
263-
"""
264-
...
265-
Examples
266-
--------
267-
.. literalinclude:: ../../../examples/series_getitem.py
268-
:language: python
269-
:lines: 27-
270-
:caption: Getting Pandas Series elements
271-
:name: ex_series_getitem
272-
273-
.. code-block:: console
274-
275-
> python ./series_getitem.py
276-
55
277-
278-
In the above snapshot the script ``series_getitem.py`` is embedded into the docstring. ``:lines: 27-`` allows to skip lengthy
279-
copyright header of the file. ``:caption:`` provides meaningful description of the example. It is a good tone to have the caption
280-
for every example. ``:name:`` is the `Sphinx*`_ name that allows referencing example from other parts of the documentation. It is a good
281-
tone to include this field. Please follow the naming convention ``ex_<example file name>`` for consistency.
282-
283-
Accompany every example with the expected output using ``.. code-block:: console`` decorator.
284-
285-
286-
**Every Examples section must come with one or more examples illustrating all major variations of supported API parameter combinations. It is highly recommended to illustrate SDC API limitations (e.g. unsupported parameters) in example script comments.**
287-
288-
9. See Also sections are highly encouraged.
289-
This is a good practice to include relevant references into the See Also section. Embedding references which are not directly
290-
related to the topic may be distructing if those appear across API description. A good style is to have a dedicated section for
291-
relevant topics.
292-
293-
See Also section may include references to relevant SDC and Pandas as well as to external topics.
294-
295-
A special form of See Also section is References to publications. Pandas documentation sometimes uses References section to refer to
296-
external projects. While it is not prohibited to use References section in SDC docstrings, it is better to combine all references
297-
under See Also umbrella.
298-
299-
10. Notes and Warnings must be decorated with ``.. note::`` and ``.. warning::`` respectively.
300-
Do not use
301-
::
302-
Notes
303-
-----
304-
305-
Warning
306-
-------
307-
308-
Pay attention to indentation and required blank lines. `Sphinx*`_ is very sensitive to that.
309-
310-
11. If SDC API does not support all variations of respective Pandas API then Limitations section is mandatory.
311-
While there is not specific guideline how Limitations section must be written, a good style is to follow Pandas Parameters section
312-
description style and naming conventions.
313-
314-
12. Before committing your code for public SDC API you are expected to:
315-
316-
- have SDC docstring implemented;
317-
- have respective SDC examples implemented and tested
318-
- API Reference documentation generated and visually inspected. New warnings in the documentation build are not allowed.
319182

320183
Running unit tests
321184
------------------

docs/README.rst

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
Intel® SDC docstring decoration rules
2+
#####################################
3+
4+
.. _Numba*: https://numba.pydata.org/
5+
.. _Pandas*: https://pandas.pydata.org/
6+
.. _Sphinx*: https://www.sphinx-doc.org/
7+
8+
Since Intel® SDC API Reference is auto-generated from respective `Pandas*`_ and Intel® SDC docstrings there are certain rules that must be
9+
followed to accurately generate the API description.
10+
11+
1. Every Intel® SDC API must have the docstring.
12+
If developer does not provide the docstring then `Sphinx*`_ will not be able to match `Pandas*`_ docstring with respective SDC one.
13+
In this situation `Sphinx*`_ assumes that SDC does not support such API and will include respective note in the API Reference that
14+
**This API is currently unsupported**.
15+
16+
2. Follow 'one function - one docstring' rule.
17+
You cannot have one docstring for multiple APIs, even if those are very similar. Auto-generator assumes every SDC API is covered by
18+
respective docstring. If `Sphinx*`_ does not find the docstring for particular API then it assumes that SDC does not support such API
19+
and will include respective note in the API Reference that **This API is currently unsupported**.
20+
21+
3. Description (introductory section, the very first few paragraphs without a title) is taken from `Pandas*`_.
22+
Intel® SDC developers should not include API description in SDC docstring.
23+
But developers are encouraged to follow Pandas API description naming conventions
24+
so that the combined docstring appears consistent.
25+
26+
4. Parameters, Returns, and Raises sections' description is taken from `Pandas*`_ docstring.
27+
Intel® SDC developers should not include such descriptions in their SDC docstrings.
28+
Rather developers are encouraged to follow Pandas naming conventions
29+
so that the combined docstring appears consistent.
30+
31+
5. Every SDC docstring must be of the follwing structure:
32+
::
33+
34+
"""
35+
Intel Scalable Dataframe Compiler User Guide
36+
********************************************
37+
Pandas API: <full pandas name, e.g. pandas.Series.nlargest>
38+
39+
<Intel® SDC specific sections>
40+
41+
Intel Scalable Dataframe Compiler Developer Guide
42+
*************************************************
43+
<Developer's Guide specific sections>
44+
"""
45+
46+
The first two lines must be the User Guide header. This is an indication to `Sphinx*`_ that this section is intended for public API
47+
and it will be combined with repsective Pandas API docstring.
48+
49+
Line 3 must specify what Pandas API this Intel® SDC docstring does correspond to. It must start with ``Pandas API:`` followed by
50+
full Pandas API name that corresponds to this SDC docstring. Remember to include full name, for example, ``nlargest`` is not
51+
sufficient for auto-generator to perform the match. The full name must be ``pandas.Series.nlargest``.
52+
53+
After User Guide sections in the docstring there can be another header indicating that the remaining part of the docstring belongs to
54+
Developer's Guide and must not be included into User's Guide.
55+
56+
6. Examples, See Also, References sections are **NOT** taken from Pandas docstring. SDC developers are expected to complete these sections in SDC doctrings.
57+
This is so because respective Pandas sections are sometimes too Pandas specific and are not relevant to SDC. SDC developers have to
58+
rewrite those sections in Intel® SDC style. Do not forget about User Guide header and Pandas API name prior to adding SDC specific
59+
sections.
60+
61+
7. Examples section is mandatory for every SDC API. 'One API - at least one example' rule is applied.
62+
Examples are essential part of user experience and must accompany every API docstring.
63+
64+
8. Embed examples into Examples section from ``./sdc/examples``.
65+
Rather than writing example in the docstring (which is error-prone) embed relevant example scripts into the docstring. For example,
66+
here is an example how to embed example for ``pandas.Series.get()`` function into respective Intel® SDC docstring:
67+
68+
::
69+
70+
"""
71+
...
72+
Examples
73+
--------
74+
.. literalinclude:: ../../../examples/series_getitem.py
75+
:language: python
76+
:lines: 27-
77+
:caption: Getting Pandas Series elements
78+
:name: ex_series_getitem
79+
80+
.. code-block:: console
81+
82+
> python ./series_getitem.py
83+
55
84+
85+
In the above snapshot the script ``series_getitem.py`` is embedded into the docstring. ``:lines: 27-`` allows to skip lengthy
86+
copyright header of the file. ``:caption:`` provides meaningful description of the example. It is a good tone to have the caption
87+
for every example. ``:name:`` is the `Sphinx*`_ name that allows referencing example from other parts of the documentation. It is a good
88+
tone to include this field. Please follow the naming convention ``ex_<example file name>`` for consistency.
89+
90+
Accompany every example with the expected output using ``.. code-block:: console`` decorator.
91+
92+
93+
**Every Examples section must come with one or more examples illustrating all major variations of supported API parameter combinations. It is highly recommended to illustrate SDC API limitations (e.g. unsupported parameters) in example script comments.**
94+
95+
9. See Also sections are highly encouraged.
96+
This is a good practice to include relevant references into the See Also section. Embedding references which are not directly
97+
related to the topic may be distructing if those appear across API description. A good style is to have a dedicated section for
98+
relevant topics.
99+
100+
See Also section may include references to relevant SDC and Pandas as well as to external topics.
101+
102+
A special form of See Also section is References to publications. Pandas documentation sometimes uses References section to refer to
103+
external projects. While it is not prohibited to use References section in SDC docstrings, it is better to combine all references
104+
under See Also umbrella.
105+
106+
10. Notes and Warnings must be decorated with ``.. note::`` and ``.. warning::`` respectively.
107+
Do not use
108+
::
109+
Notes
110+
-----
111+
112+
Warning
113+
-------
114+
115+
Pay attention to indentation and required blank lines. `Sphinx*`_ is very sensitive to that.
116+
117+
11. If SDC API does not support all variations of respective Pandas API then Limitations section is mandatory.
118+
While there is not specific guideline how Limitations section must be written, a good style is to follow Pandas Parameters section
119+
description style and naming conventions.
120+
121+
12. Before committing your code for public SDC API you are expected to:
122+
123+
- have SDC docstring implemented;
124+
- have respective SDC examples implemented and tested
125+
- API Reference documentation generated and visually inspected. New warnings in the documentation build are not allowed.
126+
127+
Sphinx Generation Internals
128+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129+
130+
The documentation generation is controlled by ``conf.py`` script automatically invoked by `Sphinx*`_.
131+
See `Sphinx documentation <http://www.sphinx-doc.org/en/master/usage/configuration.html>`_ for details.
132+
133+
The API Reference for Intel® SDC User's Guide is auto-generated by inspecting ``pandas`` and ``sdc`` modules.
134+
That's why these modules must be pre-installed for documentation generation using `Sphinx*`_.
135+
However, there is a possibility to skip API Reference auto-generation by setting environment variable ``SDC_DOC_NO_API_REF_STR=1``.
136+
137+
If the environment variable ``SDC_DOC_NO_API_REF_STR`` is unset then Sphinx's ``conf.py``
138+
invokes ``generate_api_reference()`` function located in ``./sdc/docs/source/buildscripts/apiref_generator`` module.
139+
This function parses ``pandas`` and ``sdc`` docstrings for each API, combines those into single docstring and
140+
writes it into RST file with respective `Pandas*`_ API name. The auto-generated RST files are
141+
located at ``./sdc/docs/source/_api_ref`` directory.
142+
143+
.. note::
144+
`Sphinx*`_ will automatically clean the ``_api_ref`` directory on the next invocation of the documenation build.
145+

0 commit comments

Comments
 (0)
0