1API Documentation Template 2========================== 3 4.. note:: 5 6 *INSTRUCTIONS* 7 8 1. Use this file (:idf_file:`docs/en/api-reference/template.rst`) as a template to document API. 9 2. Change the file name to the name of the header file that represents documented API. 10 3. Include respective files with descriptions from the API folder using ``..include::`` 11 12 * README.rst 13 * example.rst 14 * ... 15 16 4. Optionally provide description right in this file. 17 5. Once done, remove all instructions like this one and any superfluous headers. 18 19Overview 20-------- 21 22.. note:: 23 24 *INSTRUCTIONS* 25 26 1. Provide overview where and how this API may be used. 27 2. Where applicable include code snippets to illustrate functionality of particular functions. 28 3. To distinguish between sections, use the following `heading levels <http://www.sphinx-doc.org/en/stable/rest.html#sections>`_: 29 30 * ``#`` with overline, for parts 31 * ``*`` with overline, for chapters 32 * ``=``, for sections 33 * ``-``, for subsections 34 * ``^``, for subsubsections 35 * ``"``, for paragraphs 36 37Application Example 38------------------- 39 40.. note:: 41 42 *INSTRUCTIONS* 43 44 1. Prepare one or more practical examples to demonstrate functionality of this API. 45 2. Each example should follow pattern of projects located in ``esp-idf/examples/`` folder. 46 3. Place example in this folder complete with ``README.md`` file. 47 4. Provide overview of demonstrated functionality in ``README.md``. 48 5. With good overview reader should be able to understand what example does without opening the source code. 49 6. Depending on complexity of example, break down description of code into parts and provide overview of functionality of each part. 50 7. Include flow diagram and screenshots of application output if applicable. 51 8. Finally add in this section synopsis of each example together with link to respective folder in ``esp-idf/examples/``. 52 53API Reference 54------------- 55 56.. highlight:: none 57 58.. note:: 59 60 *INSTRUCTIONS* 61 62 1. This repository provides for automatic update of API reference documentation using :doc:`code markup retrieved by Doxygen from header files <../contribute/documenting-code>`. 63 64 1. Update is done on each documentation build by invoking Sphinx extension :`esp_extensions/run_doxygen.py` for all header files listed in the ``INPUT`` statement of :idf_file:`docs/doxygen/Doxyfile`. 65 66 1. Each line of the ``INPUT`` statement (other than a comment that begins with ``##``) contains a path to header file ``*.h`` that will be used to generate corresponding ``*.inc`` files:: 67 68 ## 69 ## Wi-Fi - API Reference 70 ## 71 ../components/esp32/include/esp_wifi.h \ 72 ../components/esp32/include/esp_smartconfig.h \ 73 74 1. When the headers are expanded, any macros defined by default in ``sdkconfig.h`` as well as any macros defined in SOC-specific ``include/soc/*_caps.h`` headers will be expanded. This allows the headers to include/exclude material based on the ``IDF_TARGET`` value. 75 76 1. The ``*.inc`` files contain formatted reference of API members generated automatically on each documentation build. All ``*.inc`` files are placed in Sphinx ``_build`` directory. To see directives generated for e.g. ``esp_wifi.h``, run ``python gen-dxd.py esp32/include/esp_wifi.h``. 77 78 1. To show contents of ``*.inc`` file in documentation, include it as follows:: 79 80 .. include-build-file:: inc/esp_wifi.inc 81 82 For example see :idf_file:`docs/en/api-reference/network/esp_wifi.rst` 83 84 1. Optionally, rather that using ``*.inc`` files, you may want to describe API in you own way. See :idf_file:`docs/en/api-guides/ulp.rst` for example. 85 86 Below is the list of common ``.. doxygen...::`` directives: 87 88 * Functions - ``.. doxygenfunction:: name_of_function`` 89 * Unions -``.. doxygenunion:: name_of_union`` 90 * Structures -``.. doxygenstruct:: name_of_structure`` together with ``:members:`` 91 * Macros - ``.. doxygendefine:: name_of_define`` 92 * Type Definitions - ``.. doxygentypedef:: name_of_type`` 93 * Enumerations - ``.. doxygenenum:: name_of_enumeration`` 94 95 See `Breathe documentation <https://breathe.readthedocs.io/en/latest/directives.html>`_ for additional information. 96 97 To provide a link to header file, use the `link custom role` directive as follows:: 98 99 * :component_file:`path_to/header_file.h` 100 101 1. In any case, to generate API reference, the file :idf_file:`docs/doxygen/Doxyfile` should be updated with paths to ``*.h`` headers that are being documented. 102 103 1. When changes are committed and documentation is build, check how this section has been rendered. :doc:`Correct annotations <../contribute/documenting-code>` in respective header files, if required. 104