docs/en/contribute/creating-examples.rst
:link_to_translation:zh_CN:[中文]
Each ESP-IDF example is a complete project that someone else can copy and adapt the code to solve their own problem. Examples should demonstrate ESP-IDF functionality, while keeping this purpose in mind.
main directory should contain a source file named (something)_example_main.c with the main functionality.main and place a corresponding header file in the same directory.components directory to the example project and make some example-specific components with library functionality. Only do this if the components are specific to the example, if they are generic or common functionality then they should be added to ESP-IDF itself.README.md file. Use the :idf_file:template example README <docs/TEMPLATE_EXAMPLE_README.md> and adapt it for your particular example.pytest_<example name>.py file for running an automated example test. If submitting a GitHub Pull Request which includes an example, it is OK not to include this file initially. The details can be discussed as part of the Pull Request <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request>_. Please refer to :doc:IDF Tests with Pytest Guide <esp-idf-tests-with-pytest> for details.Example code should follow the :doc:style-guide.
Checklist before submitting a new example:
README.md file which is similar to the :idf_file:template example README <docs/TEMPLATE_EXAMPLE_README.md>.naming section of the style guide <style-guide-naming>. For non-static names which are only specific to the example's source files, you can use example or something similar as a prefix.Kconfig.projbuild file with a menu named "Example Configuration". See existing example projects to see how this is done.