> ## Documentation Index
> Fetch the complete documentation index at: https://codegeninc-jay-docs-fixes-24.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Directory

> Directory representation for codebase. GraphSitter abstraction of a file directory that can be used to look for files and symbols within a specific directory.

export const Attribute = ({type, description}) => <div className="pl-4 py-6 first:pt-3 dark:border-zinc-300/[0.06] text-sm font-normal">
    <div className="inline-grid grid-cols-[auto_auto] gap-1 font-mono py-2">
      {type}
    </div>
    <p className="mt-2">{description}</p>
  </div>;

export const GithubLinkNote = ({link}) => <Info>
      <div className="flex gap-2 items-center">View Source on <a target="_blank" rel="noopener noreferrer" href={link}>Github</a></div>
   </Info>;

export const HorizontalDivider = ({light = false}) => <div className="divide-y">
        <div className={`divide-y ${light ? "dark:border-zinc-300/[0.06]" : "border-zinc-600"}`}></div>
        <div className={`divide-y ${light ? "dark:border-zinc-300/[0.06]" : "border-zinc-600"}`}></div>
    </div>;

export const Return = ({return_type, description}) => <div className="pl-6 divide-y">
    <h4 className="font-bold">Returns</h4>
    <div className="dark:border-zinc-300/[0.06] ">
        <div className="py-6 first:pt-3 text-sm font-normal">
            <div className="flex gap-4 items-center">
                <div className="inline-grid grid-cols-[auto_auto] gap-1 font-mono py-2">
                    {return_type}
                </div>
            </div>
            <p className="mt-2">{description}</p>
        </div>
    </div>
  </div>;

export const ParameterWrapper = ({children}) => <div className="pl-6 divide-y">
    <h4 className="font-bold">Parameters</h4>
    <div className="divide-y dark:border-zinc-300/[0.06]">
      {children}
    </div>
  </div>;

export const Parameter = ({name, type, description, defaultValue}) => <div className="py-6 first:pt-3 dark:border-zinc-300/[0.06] text-sm font-normal">
    <div className="flex justify-between items-start font-mono">
      <div className="flex gap-4 items-start">
        <div className="flex gap-1 items-center text-sm text-primary mt-2">
          {name}
        </div>
        <div className="inline-grid grid-cols-[auto_auto] gap-1 py-2">
          {type}
        </div>
      </div>

      <div className="flex-shrink-0 mt-2">
        {defaultValue ? <div className="flex gap-1 items-center text-sm border border-purple-500 px-2 py-0.5 rounded">
            <span className="text-zinc-500">default:</span>
            <span className="text-purple-500">{defaultValue}</span>
          </div> : <span className="text-sm border border-purple-500 px-2 py-0.5 rounded">
            required
          </span>}
      </div>
    </div>
    <p className="mt-2">{description}</p>
  </div>;

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L30-L216" />

## Attributes

<HorizontalDivider />

### <span className="text-primary">classes</span>

<HorizontalDivider light={true} />

<Attribute type={ <><span>list[</span> <a href="/api-reference/core/Class" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Class</a> <span>]</span></> } description="Get a recursive list of all classes in the directory and its subdirectories." />

### <span className="text-primary">dirpath</span>

<HorizontalDivider light={true} />

<Attribute
  type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">str</code> }
  description="
"
/>

### <span className="text-primary">files</span>

<HorizontalDivider light={true} />

<Attribute type={ <><span>list[</span> <a href="/api-reference/core/File" style={ {fontWeight: "inherit", fontSize: "inherit"} }>File</a> <span>]</span></> } description="Get a recursive list of all files in the directory and its subdirectories." />

### <span className="text-primary">functions</span>

<HorizontalDivider light={true} />

<Attribute type={ <><span>list[</span> <a href="/api-reference/core/Function" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Function</a> <span>]</span></> } description="Get a recursive list of all functions in the directory and its subdirectories." />

### <span className="text-primary">global\_vars</span>

<HorizontalDivider light={true} />

<Attribute type={ <><span>list[</span> <a href="/api-reference/core/Assignment" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Assignment</a> <span>]</span></> } description="Get a recursive list of all global variables in the directory and its subdirectories." />

### <span className="text-primary">import\_statements</span>

<HorizontalDivider light={true} />

<Attribute type={ <><span>list[</span> <a href="/api-reference/core/ImportStatement" style={ {fontWeight: "inherit", fontSize: "inherit"} }>ImportStatement</a> <span>]</span></> } description="Get a recursive list of all import statements in the directory and its subdirectories." />

### <span className="text-primary">items</span>

<HorizontalDivider light={true} />

<Attribute
  type={ <><span>dict[str,</span> <a href="/api-reference/core/File" style={ {fontWeight: "inherit", fontSize: "inherit"} }>File</a> <span>|</span> <a href="/api-reference/core/Directory" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Directory</a> <span>]</span></> }
  description="
"
/>

### <span className="text-primary">name</span>

<HorizontalDivider light={true} />

<Attribute type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">str</code> } description="Get the base name of the directory's path." />

### <span className="text-primary">parent</span>

<HorizontalDivider light={true} />

<Attribute
  type={ <><a href="/api-reference/core/Directory" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Directory</a> <span>| None</span></> }
  description="
"
/>

### <span className="text-primary">path</span>

<HorizontalDivider light={true} />

<Attribute
  type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">Path</code> }
  description="
"
/>

### <span className="text-primary">subdirectories</span>

<HorizontalDivider light={true} />

<Attribute type={ <><span>list[</span> <a href="/api-reference/core/Directory" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Directory</a> <span>]</span></> } description="Get a recursive list of all subdirectories in the directory and its subdirectories." />

### <span className="text-primary">symbols</span>

<HorizontalDivider light={true} />

<Attribute type={ <><span>list[</span> <a href="/api-reference/core/Symbol" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Symbol</a> <span>]</span></> } description="Get a recursive list of all symbols in the directory and its subdirectories." />

## Methods

<HorizontalDivider />

### <span className="text-primary">add\_file</span>

Add a file to the directory.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L156-L159" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />

### <span className="text-primary">add\_subdirectory</span>

Add a subdirectory to the directory.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L179-L182" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />

### <span className="text-primary">get\_class</span>

Get a class by name in the directory and its subdirectories.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L148-L150" />

<Return return_type={ <><a href="/api-reference/core/Class" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Class</a> <span>| None</span></> } description="" />

### <span className="text-primary">get\_file</span>

Get a file by its name relative to the directory.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L171-L177" />

<Return return_type={ <><a href="/api-reference/core/File" style={ {fontWeight: "inherit", fontSize: "inherit"} }>File</a> <span>| None</span></> } description="" />

### <span className="text-primary">get\_function</span>

Get a function by name in the directory and its subdirectories.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L152-L154" />

<Return return_type={ <><a href="/api-reference/core/Function" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Function</a> <span>| None</span></> } description="" />

### <span className="text-primary">get\_global\_var</span>

Get a global variable by name in the directory and its subdirectories.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L144-L146" />

<Return return_type={ <><a href="/api-reference/core/Assignment" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Assignment</a> <span>| None</span></> } description="" />

### <span className="text-primary">get\_import\_statement</span>

Get an import statement by name in the directory and its subdirectories.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L140-L142" />

<Return return_type={ <><a href="/api-reference/core/ImportStatement" style={ {fontWeight: "inherit", fontSize: "inherit"} }>ImportStatement</a> <span>| None</span></> } description="" />

### <span className="text-primary">get\_subdirectory</span>

Get a subdirectory by its path relative to the directory.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L194-L196" />

<Return return_type={ <><a href="/api-reference/core/Directory" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Directory</a> <span>| None</span></> } description="" />

### <span className="text-primary">get\_symbol</span>

Get a symbol by name in the directory and its subdirectories.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L136-L138" />

<Return return_type={ <><a href="/api-reference/core/Symbol" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Symbol</a> <span>| None</span></> } description="" />

### <span className="text-primary">remove</span>

Remove the directory and all its files and subdirectories.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L198-L201" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />

### <span className="text-primary">remove\_file</span>

Remove a file from the directory.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L161-L164" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />

### <span className="text-primary">remove\_file\_by\_path</span>

Remove a file from the directory by its path.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L166-L169" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />

### <span className="text-primary">remove\_subdirectory</span>

Remove a subdirectory from the directory.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L184-L187" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />

### <span className="text-primary">remove\_subdirectory\_by\_path</span>

Remove a subdirectory from the directory by its path.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L189-L192" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />

### <span className="text-primary">rename</span>

Rename the directory.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L212-L216" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />

### <span className="text-primary">update\_filepath</span>

Update the filepath of the directory.

<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/directory.py#L203-L210" />

<Return return_type={ <code className="text-sm bg-gray-100 px-2 py-0.5 rounded">None</code> } description="" />
