Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions docs/building-with-codegen/flagging-symbols.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: "Flagging Symbols"
description: "Learn how to use symbol flags for debugging, tracking changes, and marking code for review"
icon: "flag"
iconType: "solid"
---

# Flagging Symbols

Symbol flags are a powerful feature in Codegen that allow you to mark and track specific code elements during development, debugging, or code review processes. Flags can be used to visually highlight code in the editor and can also integrate with various messaging systems.

## Basic Usage

The simplest way to flag a symbol is to call the `flag()` method on any symbol:

```python
# Flag a function
function.flag(message="This function needs optimization")

# Flag a class
my_class.flag(message="Consider breaking this into smaller classes")

# Flag a variable
variable.flag(message="Type hints needed here")
```

When you flag a symbol, two things happen:
1. A visual flag emoji (🚩) is added as an inline comment
2. A `CodeFlag` object is created to track the flag in the system


## Language-Specific Behavior

The flag system adapts automatically to the programming language being used:

```python
# Python
# Results in: def my_function(): # 🚩 Review needed
python_function.flag(message="Review needed")

# TypeScript
# Results in: function myFunction() { // 🚩 Review needed
typescript_function.flag(message="Review needed")
```


## Example: Code Analysis

Here's an example of using flags during code analysis:

```python
def analyze_codebase(codebase):
for function in codebase.functions:
# Check documentation
if not function.docstring:
function.flag(
message="Missing docstring",
)

# Check error handling
if function.is_async and not function.has_try_catch:
function.flag(
message="Async function missing error handling",
)
```

This feature is particularly useful when building, and iterating on the symbols that you are trying to modify.
1 change: 1 addition & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"building-with-codegen/traversing-the-call-graph",
"building-with-codegen/react-and-jsx",
"building-with-codegen/codebase-visualization",
"building-with-codegen/flagging-symbols",
"building-with-codegen/calling-out-to-llms",
"building-with-codegen/reducing-conditions"
]
Expand Down
Loading