Skip to main content

๐Ÿงญ Emoji + Metadata + Tree Layout

Here's a complete Python script that generates a visually appealing tree structure of your project folder using emoji icons and file metadata. The output is formatted as a Bash-style code block perfect for embedding in Docusaurus.

Emojis from Microsoft

Full Expressive Python Scriptโ€‹

https://copilot.microsoft.com/shares/B7pvjR59PwjbFEnyQNiEJ

generate_tree_md.py
import os
import datetime

# ๐Ÿ”ง Feature toggles
INCLUDE_EMOJI = True
INCLUDE_METADATA = False
INCLUDE_COMMENTS = True
SMART_FOLDER_LABELS = False

# ๐Ÿ—’๏ธ Manual file comments (extend as needed)
MANUAL_COMMENTS = {
"WebBrowser.js": "Main browser component",
"WebBrowser.module.css": "Browser styles",
"BrowserExamples.js": "Example components (optional)",
"README.md": "Project overview",
"config.json": "Configuration settings"
}

# ๐ŸŽญ Emoji mapping by file extension
def emoji_for_file(file_name):
ext = os.path.splitext(file_name)[1].lower()
return {
'.js': '๐Ÿ“œ',
'.ts': '๐Ÿ“˜',
'.css': '๐ŸŽจ',
'.scss': '๐Ÿงต',
'.html': '๐ŸŒ',
'.py': '๐Ÿ',
'.md': '๐Ÿ“',
'.json': '๐Ÿ”ง',
'.jpg': '๐Ÿ–ผ๏ธ',
'.png': '๐Ÿ–ผ๏ธ',
'.txt': '๐Ÿ“„',
'.test.js': '๐Ÿงช',
'.lock': '๐Ÿ”’',
}.get(ext, '๐Ÿ“„')

# ๐Ÿ“‚ Emoji by folder purpose
def emoji_for_folder(folder_name):
mapping = {
'test': '๐Ÿงช',
'tests': '๐Ÿงช',
'components': '๐Ÿงฉ',
'config': 'โš™๏ธ',
'public': '๐ŸŒ',
'docs': '๐Ÿ“š',
'scripts': '๐Ÿ“œ',
'assets': '๐ŸŽจ',
'utils': '๐Ÿงฐ',
}
for key, icon in mapping.items():
if key.lower() in folder_name.lower():
return icon
return '๐Ÿ“‚'

# ๐Ÿ“Š Generate metadata comment
def get_file_metadata_comment(file_path):
stats = os.stat(file_path)
size_kb = stats.st_size / 1024
mtime = datetime.datetime.fromtimestamp(stats.st_mtime)
ext = os.path.splitext(file_path)[1].lower().lstrip('.').upper() or "Unknown"
return f"{ext} file, {size_kb:.1f} KB, modified {mtime.strftime('%Y-%m-%d %H:%M')}"

# ๐ŸŒณ Recursive folder walker
def map_folder_structure(root_path, indent=""):
lines = []
items = sorted(os.listdir(root_path))
for idx, item in enumerate(items):
item_path = os.path.join(root_path, item)
is_last = idx == len(items) - 1
prefix = "โ””โ”€โ”€ " if is_last else "โ”œโ”€โ”€ "
line_prefix = indent + prefix
# Folder line
if os.path.isdir(item_path):
folder_emoji = emoji_for_folder(item) if SMART_FOLDER_LABELS and INCLUDE_EMOJI else ('๐Ÿ“' if INCLUDE_EMOJI else '')
spacing = ' ' if INCLUDE_EMOJI else ''
line = f"{line_prefix}{folder_emoji}{spacing}{item}/"
lines.append(line)
new_indent = indent + (" " if is_last else "โ”‚ ")
lines.extend(map_folder_structure(item_path, new_indent))
# File line
else:
file_emoji = emoji_for_file(item) if INCLUDE_EMOJI else ''
spacing = ' ' if INCLUDE_EMOJI else ''
comments = []

if INCLUDE_COMMENTS and item in MANUAL_COMMENTS:
comments.append(MANUAL_COMMENTS[item])
if INCLUDE_METADATA:
comments.append(get_file_metadata_comment(item_path))

comment_str = f" # {' | '.join(comments)}" if comments else ''
line = f"{line_prefix}{file_emoji}{spacing}{item}{comment_str}"
lines.append(line)

return lines

# ๐Ÿงช Wrap it all for Markdown embedding
def generate_docusaurus_bash_block(root_path):
root_name = os.path.basename(os.path.abspath(root_path))

if SMART_FOLDER_LABELS and INCLUDE_EMOJI:
top_icon = emoji_for_folder(root_name)
elif INCLUDE_EMOJI:
top_icon = '๐Ÿ“‚'
else:
top_icon = ''

spacing = ' ' if INCLUDE_EMOJI else ''
lines = [f"{top_icon}{spacing}{root_name}/"]
lines.extend(map_folder_structure(root_path))
return "```bash\n" + "\n".join(lines) + "\n```"

# โ–ถ๏ธ Example usage
output = generate_docusaurus_bash_block("src/components")
print(output)

with open("project-structure.md", "w", encoding="utf-8") as f:
f.write("## ๐Ÿ“‚ Project Structure\n\n")
f.write(output)

๐Ÿ“‚ Project Structureโ€‹

# ๐Ÿ”ง Feature toggles
INCLUDE_EMOJI = True
INCLUDE_METADATA = True
INCLUDE_COMMENTS = True
SMART_FOLDER_LABELS = True
๐Ÿงฉ components/
โ”œโ”€โ”€ ๐Ÿ“œ BashTerminal.js # JS file, 5.3 KB, modified 2025-07-22 08:59
โ”œโ”€โ”€ ๐ŸŽจ BashTerminal.module.css # CSS file, 3.1 KB, modified 2025-07-22 08:59
โ”œโ”€โ”€ ๐Ÿ“œ BrowserExamples.js # Example components (optional) | JS file, 3.5 KB, modified 2025-07-22 08:59
โ”œโ”€โ”€ ๐Ÿ“‚ BrowserWindow/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“œ index.js # JS file, 1.1 KB, modified 2025-07-22 08:59
โ”‚ โ””โ”€โ”€ ๐ŸŽจ styles.module.css # CSS file, 1.6 KB, modified 2025-07-22 08:59
โ”œโ”€โ”€ ๐Ÿ“‚ HomepageFeatures/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“œ index.js # JS file, 1.7 KB, modified 2025-07-22 08:59
โ”‚ โ””โ”€โ”€ ๐ŸŽจ styles.module.css # CSS file, 0.1 KB, modified 2025-07-22 08:59
โ”œโ”€โ”€ ๐Ÿ“œ TerminalExamples.js # JS file, 1.4 KB, modified 2025-07-22 08:59
โ”œโ”€โ”€ ๐Ÿ“œ WebBrowser.js # Main browser component | JS file, 7.1 KB, modified 2025-07-22 08:59
โ”œโ”€โ”€ ๐ŸŽจ WebBrowser.module.css # Browser styles | CSS file, 7.0 KB, modified 2025-07-22 08:59
โ””โ”€โ”€ ๐Ÿ“œ YouTubeEmbed.js # JS file, 1.1 KB, modified 2025-07-22 08:59
# ๐Ÿ”ง Feature toggles
INCLUDE_EMOJI = True
INCLUDE_METADATA = False
INCLUDE_COMMENTS = True
SMART_FOLDER_LABELS = True
๐Ÿงฉ components/
โ”œโ”€โ”€ ๐Ÿ“œ BashTerminal.js
โ”œโ”€โ”€ ๐ŸŽจ BashTerminal.module.css
โ”œโ”€โ”€ ๐Ÿ“œ BrowserExamples.js # Example components (optional)
โ”œโ”€โ”€ ๐Ÿ“‚ BrowserWindow/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“œ index.js
โ”‚ โ””โ”€โ”€ ๐ŸŽจ styles.module.css
โ”œโ”€โ”€ ๐Ÿ“‚ HomepageFeatures/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“œ index.js
โ”‚ โ””โ”€โ”€ ๐ŸŽจ styles.module.css
โ”œโ”€โ”€ ๐Ÿ“œ TerminalExamples.js
โ”œโ”€โ”€ ๐Ÿ“œ WebBrowser.js # Main browser component
โ”œโ”€โ”€ ๐ŸŽจ WebBrowser.module.css # Browser styles
โ””โ”€โ”€ ๐Ÿ“œ YouTubeEmbed.js
# ๐Ÿ”ง Feature toggles
INCLUDE_EMOJI = True
INCLUDE_METADATA = False
INCLUDE_COMMENTS = True
SMART_FOLDER_LABELS = False
๐Ÿ“‚ components/
โ”œโ”€โ”€ ๐Ÿ“œ BashTerminal.js
โ”œโ”€โ”€ ๐ŸŽจ BashTerminal.module.css
โ”œโ”€โ”€ ๐Ÿ“œ BrowserExamples.js # Example components (optional)
โ”œโ”€โ”€ ๐Ÿ“‚ BrowserWindow/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“œ index.js
โ”‚ โ””โ”€โ”€ ๐ŸŽจ styles.module.css
โ”œโ”€โ”€ ๐Ÿ“‚ HomepageFeatures/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“œ index.js
โ”‚ โ””โ”€โ”€ ๐ŸŽจ styles.module.css
โ”œโ”€โ”€ ๐Ÿ“œ TerminalExamples.js
โ”œโ”€โ”€ ๐Ÿ“œ WebBrowser.js # Main browser component
โ”œโ”€โ”€ ๐ŸŽจ WebBrowser.module.css # Browser styles
โ””โ”€โ”€ ๐Ÿ“œ YouTubeEmbed.js
# ๐Ÿ”ง Feature toggles
INCLUDE_EMOJI = False
INCLUDE_METADATA = False
INCLUDE_COMMENTS = True
SMART_FOLDER_LABELS = False
components/
โ”œโ”€โ”€ BashTerminal.js
โ”œโ”€โ”€ BashTerminal.module.css
โ”œโ”€โ”€ BrowserExamples.js # Example components (optional)
โ”œโ”€โ”€ BrowserWindow/
โ”‚ โ”œโ”€โ”€ index.js
โ”‚ โ””โ”€โ”€ styles.module.css
โ”œโ”€โ”€ HomepageFeatures/
โ”‚ โ”œโ”€โ”€ index.js
โ”‚ โ””โ”€โ”€ styles.module.css
โ”œโ”€โ”€ TerminalExamples.js
โ”œโ”€โ”€ WebBrowser.js # Main browser component
โ”œโ”€โ”€ WebBrowser.module.css # Browser styles
โ””โ”€โ”€ YouTubeEmbed.js