Skip to main content

Overview

Exclusion patterns allow you to control which files and folders appear in your generated structure. This is essential for creating clean, focused documentation by omitting build artifacts, dependencies, and other irrelevant items.

How Exclusion Patterns Work

The extension uses glob pattern syntax to match files and folders for exclusion. Patterns are matched against the full path of each item relative to your project root.
The extension uses the fast-glob library for pattern matching, which supports standard glob syntax.

Glob Pattern Syntax

Understanding glob patterns is key to effective exclusions:

Basic Wildcards

* - Matches any characters except /
"*.log"  // Matches: error.log, debug.log
** - Matches any characters including / (recursive)
"**/node_modules"  // Matches node_modules at any depth
? - Matches exactly one character
"file?.txt"  // Matches: file1.txt, fileA.txt
[abc] - Matches any character in the set
"file[123].txt"  // Matches: file1.txt, file2.txt, file3.txt
[a-z] - Matches any character in the range
"[A-Z]*.js"  // Matches: App.js, Button.js, etc.
[!abc] - Matches any character NOT in the set
"file[!0-9].txt"  // Matches: fileA.txt, but not file1.txt
{a,b,c} - Matches any of the comma-separated patterns
"*.{js,ts,jsx,tsx}"  // Matches JS and TS files
"**/{dist,build,out}"  // Matches dist, build, or out folders
!pattern - Includes items that match the pattern (overrides exclusions)
[
  "**/test",      // Exclude all test folders
  "!**/test/fixtures"  // But include test/fixtures
]
Negation patterns must come after the patterns they’re overriding.

Default Exclusion Patterns

The extension comes with sensible defaults that exclude common build artifacts and dependencies:
[
  "**/node_modules",
  "**/.git",
  "**/dist",
  "**/.next",
  "**/out"
]

Why These Defaults?

  • **/node_modules - npm/yarn dependencies (can contain thousands of files)
  • **/.git - Git internal files (not relevant for structure documentation)
  • **/dist - Compiled/built files
  • **/.next - Next.js build output
  • **/out - Common output directory name
These defaults are a starting point. You can modify or extend them based on your project’s needs.

Common Exclusion Patterns

Exclude by Folder Name

Exclude specific folders anywhere in your project:
{
  "draw.folder.structure.exclude": [
    "**/node_modules",
    "**/dist",
    "**/build",
    "**/coverage",
    "**/.vscode",
    "**/.idea",
    "**/temp",
    "**/tmp"
  ]
}

Exclude by File Extension

Exclude all files with specific extensions:
{
  "draw.folder.structure.exclude": [
    "**/*.log",      // Log files
    "**/*.tmp",      // Temporary files
    "**/*.cache",    // Cache files
    "**/*.lock",     // Lock files
    "**/*.map",      // Source maps
    "**/*.min.js",   // Minified JavaScript
    "**/*.min.css"   // Minified CSS
  ]
}

Exclude Specific Files

Exclude specific files by name:
{
  "draw.folder.structure.exclude": [
    "**/package-lock.json",
    "**/yarn.lock",
    "**/.DS_Store",
    "**/Thumbs.db",
    "**/.env",
    "**/.env.local"
  ]
}

Framework-Specific Patterns

{
  "draw.folder.structure.exclude": [
    "**/node_modules",
    "**/.next",
    "**/out",
    "**/build",
    "**/.cache",
    "**/public/static"
  ]
}

Advanced Pattern Examples

Exclude Multiple File Types

Use brace expansion for multiple extensions:
{
  "draw.folder.structure.exclude": [
    "**/*.{log,tmp,cache,swp,bak}"
  ]
}

Exclude Test Files

Exclude various test file patterns:
{
  "draw.folder.structure.exclude": [
    "**/*.test.{js,ts,jsx,tsx}",
    "**/*.spec.{js,ts,jsx,tsx}",
    "**/__tests__",
    "**/test",
    "**/tests"
  ]
}

Exclude Hidden Files and Folders

Exclude items starting with a dot:
{
  "draw.folder.structure.exclude": [
    "**/.*",           // All hidden files and folders
    "!**/.gitignore",  // But keep .gitignore visible
    "!**/.env.example" // And keep .env.example visible
  ]
}

Platform-Specific Files

Exclude OS-specific files:
{
  "draw.folder.structure.exclude": [
    "**/.DS_Store",      // macOS
    "**/Thumbs.db",      // Windows
    "**/desktop.ini",    // Windows
    "**/.Spotlight-V100", // macOS
    "**/.Trashes"        // macOS
  ]
}

Pattern Matching Examples

Here are some real-world examples showing what different patterns match:
Matches:
  ✓ node_modules
  ✓ packages/app/node_modules
  ✓ src/lib/node_modules
  ✗ node_modules_backup

Combining with .gitignore

When you enable the respectGitignore setting, exclusion patterns work alongside your .gitignore rules:
{
  "draw.folder.structure.exclude": [
    "**/node_modules",
    "**/dist"
  ],
  "draw.folder.structure.respectGitignore": true
}
Files matching EITHER your exclusion patterns OR .gitignore rules will be excluded. They work additively, not as overrides.

When to Use Each

Exclusion Patterns:
  • Project structure standards
  • Build artifacts
  • Documentation-specific exclusions
.gitignore Integration:
  • Version control exclusions
  • Environment-specific files
  • Generated code
See the Advanced Usage guide for more details on combining these features.

Testing Your Patterns

To test if your patterns work as expected:
  1. Configure your exclusion patterns
  2. Right-click on a folder in VS Code
  3. Select “Generate Markdown structure”
  4. Review the generated output
  5. Adjust patterns as needed
Start with broad patterns and refine them based on the output. It’s easier to remove exclusions than to add them iteratively.

Common Mistakes

Wrong: "node_modules"This only matches node_modules at the root.Correct: "**/node_modules"This matches node_modules at any level.
Wrong: "**\\dist"Always use forward slashes in glob patterns.Correct: "**/dist"Forward slashes work on all platforms.
Wrong:
[
  "!**/important.log",
  "**/*.log"
]
Correct:
[
  "**/*.log",
  "!**/important.log"
]
Negation patterns must come after what they’re overriding.
Be careful not to exclude important project files:Too broad: "**/src"This excludes your entire source directory!Better: "**/src/generated"Be specific about what you want to exclude.

Configuration Templates

Minimal (Keep Defaults)

{
  "draw.folder.structure.exclude": [
    "**/node_modules",
    "**/.git",
    "**/dist",
    "**/.next",
    "**/out"
  ]
}

Comprehensive Web Project

{
  "draw.folder.structure.exclude": [
    "**/node_modules",
    "**/.git",
    "**/dist",
    "**/build",
    "**/.next",
    "**/out",
    "**/coverage",
    "**/.cache",
    "**/*.log",
    "**/.DS_Store",
    "**/Thumbs.db",
    "**/.vscode",
    "**/.idea",
    "**/*.min.js",
    "**/*.min.css",
    "**/*.map"
  ]
}

Documentation-Focused

{
  "draw.folder.structure.exclude": [
    "**/node_modules",
    "**/.git",
    "**/dist",
    "**/build",
    "**/*.test.{js,ts}",
    "**/*.spec.{js,ts}",
    "**/__tests__",
    "**/coverage",
    "**/.vscode",
    "**/*.log",
    "**/package-lock.json",
    "**/yarn.lock"
  ]
}

Next Steps

Configuration

Learn about all configuration options

Advanced Usage

Combine exclusions with other advanced features

Styling Options

Customize the visual appearance of your structure

Build docs developers (and LLMs) love