Writing Code Snippets

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

Windows
MacOS
Linux
Prerequisite Topics

This page assumes you have prior knowledge of the following topics. Please read them before proceeding.

Before continuing with this guide: Install the latest updates for Visual Studio 2017. Download and install the Learning Resources UE4Snippets Visual Studio extension. * Download and extract this Example Snippet Project .

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.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback