deploy-docs

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