1#!/bin/bash
2
3# Set the environment variables
4TARGET_DIR="../zed-docs"
5PUSH_CHANGES=false
6CLEAN_FOLDERS=false
7
8# Parse command line arguments
9while getopts "pc" opt; do
10 case ${opt} in
11 p )
12 PUSH_CHANGES=true
13 ;;
14 c )
15 CLEAN_FOLDERS=true
16 ;;
17 \? )
18 echo "Invalid option: $OPTARG" 1>&2
19 exit 1
20 ;;
21 esac
22done
23
24if "$CLEAN_FOLDERS"; then
25 echo "Cleaning ./doc and ./debug folders..."
26 rm -rf "$TARGET_DIR/doc"
27 rm -rf "$TARGET_DIR/debug"
28fi
29
30# Check if the target documentation directory exists
31if [ ! -d "$TARGET_DIR" ]; then
32 # Prompt the user for input
33 read -p "The zed-docs directory does not exist. Make sure you are running this from the zed repo root." -n 1 -r
34 read -p "Do you want to clone the repository (y/n)? " -n 1 -r
35 echo # Move to a new line
36
37 if [[ $REPLY =~ ^[Yy]$ ]]; then
38 # Clone the repo if the user agrees
39 git clone https://github.com/zed-industries/zed-docs.git "$TARGET_DIR"
40 else
41 # Exit if the user does not agree to clone the repo
42 echo "Exiting without cloning the repository."
43 exit 1
44 fi
45else
46 # If the directory exists, pull the latest changes
47 pushd "$TARGET_DIR" > /dev/null
48 git pull
49 popd > /dev/null
50fi
51
52# Build the documentation
53CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \
54--exclude activity_indicator \
55--exclude ai \
56--exclude assistant \
57--exclude audio \
58--exclude auto_update \
59--exclude breadcrumbs \
60--exclude call \
61--exclude channel \
62--exclude cli \
63--exclude client \
64--exclude clock \
65--exclude collab \
66--exclude collab_ui \
67--exclude collections \
68--exclude command_palette \
69--exclude component_test \
70--exclude context_menu \
71--exclude copilot \
72--exclude copilot_button \
73--exclude db \
74--exclude diagnostics \
75--exclude drag_and_drop \
76--exclude editor \
77--exclude feature_flags \
78--exclude feedback \
79--exclude file_finder \
80--exclude fs \
81--exclude fsevent \
82--exclude fuzzy \
83--exclude git \
84--exclude go_to_line \
85--exclude gpui \
86--exclude gpui_macros \
87--exclude install_cli \
88--exclude journal \
89--exclude language \
90--exclude language_selector \
91--exclude language_tools \
92--exclude live_kit_client \
93--exclude live_kit_server \
94--exclude lsp \
95--exclude media \
96--exclude menu \
97--exclude multi_buffer \
98--exclude node_runtime \
99--exclude notifications \
100--exclude outline \
101--exclude picker \
102--exclude plugin \
103--exclude plugin_macros \
104--exclude plugin_runtime \
105--exclude prettier \
106--exclude project \
107--exclude project_panel \
108--exclude project_symbols \
109--exclude quick_action_bar \
110--exclude recent_projects \
111--exclude refineable \
112--exclude rich_text \
113--exclude rope \
114--exclude rpc \
115--exclude search \
116--exclude semantic_index \
117--exclude settings \
118--exclude snippet \
119--exclude sqlez \
120--exclude sqlez_macros \
121--exclude storybook3 \
122--exclude sum_tree \
123--exclude terminal \
124--exclude terminal_view \
125--exclude text \
126--exclude theme \
127--exclude theme_importer \
128--exclude theme_selector \
129--exclude util \
130--exclude vcs_menu \
131--exclude vim \
132--exclude welcome \
133--exclude xtask \
134--exclude zed \
135--exclude zed-actions
136
137if "$PUSH_CHANGES"; then
138 # Commit the changes and push
139 pushd "$TARGET_DIR" > /dev/null
140 # Check if there are any changes to commit
141 if git diff --quiet && git diff --staged --quiet; then
142 echo "No changes to the documentation."
143 else
144 # Staging the changes
145 git add .
146
147 # Creating a commit with the current datetime
148 DATETIME=$(date +"%Y-%m-%d %H:%M:%S")
149 git commit -m "Update docs – $DATETIME"
150
151 # Pushing the changes
152 git push
153 fi
154 popd > /dev/null
155fi