Skip to main content

Apex

Work In Progress
This page is a work in progress, accuracy of the content is not guaranteed and is subject to change at any time.

This section guides the documentation of Apex APIs. This includes best practices and formatting niches for writing ApexDocs 'doc comments' above components, with the goal of generating API documentation.

Apex APIs are documented with Javadoc-style doc comments. In this section, Javadoc-style doc comments for Apex code are referred to as ApexDocs comments or doc comments. Although these guidelines should provide clarity for most use cases, refer to Oracle's article How to Write Doc Comments for the Javadoc Tool for further reading.

tip

See the Java™ Platform, Standard Edition 7 API Specification for an example of API documentation.

Use the Visual Studio Code extension Apex Javadoc to generate an empty doc comment when you type /** above a component such as a class, method, enum or property. This prompts you to enter a description after the @description tag:

/**
* @description This is a doc comment with a `@description` tag
*/

Below is an example of a method doc comment:

/**
* @description Scans the database for the search term
* @param searchTerm The string to be searched for
* @return List of results
*/
public List<SearchResult> search(String searchTerm)

If doc comments are formatted as required by the open-source library ApexDocs, API documentation in the Markdown language can be generated via the command line.