---
name: watsonx-code-assistant-wca-generate-doc
title: Documenting code
description: Generate comment lines that document what your code does.
last-updated: 2025-06-11
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/watsonx-code-assistant?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

# Documenting code
{: #wca-generate-doc}

[watsonx Code Assistant]{: tag-blue}

Generate comment lines that document what your code does.
{: shortdesc}

## Language support and standards
{: #wca-generate-doc-languages}

The following table lists code languages and the corresponding documentation standard for each code language.

| Code | Documentation standard |
| --- | --- |
| C | doxygen |
| C++ | doxygen |
| Go | GoDoc |
| Java | JavaDoc |
| JavaScript | JSDoc |
| TypeScript | JSDoc |
| All others | Markdown |
{: caption="Documentation standards" caption-side="bottom"}

When you reference a file, the size limit is 50 KB. If you reach this limit, split the file into individual functions and reference each function. Or, split the file at 49 KB, taking care of function boundaries, and reference the file at each split. With either approach, you need to merge the results.

## Using a chat command to generate documentation
{: #wca-generate-doc-chat-command}

You can use the `/document` command in chat to generate documentation for a referenced file or a method or a class in the active workspace.

Use this syntax:

`/document <code reference> [additional instructions]`

- Make sure to start the prompt with `/document`, followed by the rest of the syntax.

- For `<code reference>`, type the `@` symbol to see a list of files, classes, and methods from your workspace. Use one file, method, class reference at a time.

- The `[additional instructions]` are optional. Add instructions if you want specific details.

**Known issue** If you are using the watsonx Code Assistant for Enterprise Java Applications extension, upon startup it might take a few seconds for the enhanced Java capabilities to be available from the CodeLens.
{: note}

## Using the CodeLens in the editor to generate documentation
{: #wca-generate-doc-document-option}

In the IDE editor, the CodeLens shows a line of generative AI options that precedes code blocks and snippets.  

1. Click the **Document** option that immediately precedes a code block or snippet to generate its documentation.

   In the following code example, the `Explain | Document | Unit Test` options immediately precede the `protected void` keywords.

   ![CodeLens example](images/codelens.png){: caption="CodeLens example"}

1. The watsonx Code Assistant chat window opens, displays the `/document @<*item name*>` command, runs the command, and displays the code with documentation added as comments.

### Disabling CodeLens
{: #wca-generate-doc-disable-codelens}

If you want to disable the CodeLens options, you can change the setting for the extension or plug-in.

In Visual Studio Code:

1. Open the settings for the extension.

1. Clear the `Enable CodeLens` setting.

In Eclipse:

1. Open the settings for the Eclipse IDE.

1. In the **watsonx Code Assistant Settings** entry, clear the `Enable CodeLens` setting.

1. Click **Apply and close**.