Writing Code Snippets

A specification for writing code snippets for the Unreal Engine API reference manual.

Choose your operating system:

Windows

macOS

Linux

Prerequisite Topics

In order to understand and use the content on this page, make sure you are familiar with the following topics:

Before continuing with this guide:

To improve Unreal Engine's API reference, we add Code Snippets, which are small chunks of sample code that demonstrate how to use the C++ API for Unreal Engine projects. If you would like to contribute code snippets to the Unreal Engine API Reference , follow this specification.

General Standards

  1. Code snippets must follow the Coding Standard .

  2. Comments should comply with the Coding Standard.

  3. Code snippets should be thoroughly commented.

  4. When appropriate, code snippets may be self-documenting.

  5. Code snippets should be brief, and no longer than twenty-five lines deep.

  6. Minimize line lengths so that readers do not have to rely on line wraps or scroll bars.

  7. Submit zipped projects containing snippet code on GitHub to EpicGames/Unreal Engine .

Functions

  1. There should be one code snippet for any given function.

  2. Functions must produce meaningful output that is visible to the user.

  3. Do not obfuscate a function's meaning with expressions that are difficult to interpret.

  4. Demonstrate functions as clearly as possible, favoring reasonable and simple use cases.

Expressions and Statements

  1. Do not sacrifice an expression's readibility for optimized performance.

  2. Expressions and statements should be meaningful, clear, and transparent.

  3. Conditional expressions should mimic the logic's natural language expression.

Snippet Blocks

  1. Do not place two consecutive blank lines between any two lines of text in a snippet block.

  2. Place ///CODE_SNIPPET_START:<class1::func1><classN::funcN> above the code snippet.

  3. Place ///CODE_SNIPPET_END below the code snippet.

Quality Assurance

  1. Tag code snippet submissions with #UE4Docs .

  2. All code snippets will be code reviewed before being published.

  3. After a code snippet has been published, its content should be maintained for clarity and correctness.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss