From 3210d367277c9b6ffae19f31fcb6471e90e9ee0b Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 20 Nov 2023 16:13:18 -0500 Subject: [PATCH 1/3] Create deploy-docs --- script/deploy-docs | 195 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 script/deploy-docs diff --git a/script/deploy-docs b/script/deploy-docs new file mode 100644 index 0000000000..0e6fcd6d6f --- /dev/null +++ b/script/deploy-docs @@ -0,0 +1,195 @@ +#!/bin/bash + +# Set the environment variables +TARGET_DIR="../zed-docs" +PUSH_CHANGES=false +CLEAN_FOLDERS=false + +# Parse command line arguments +while getopts "pc" opt; do + case ${opt} in + p ) + PUSH_CHANGES=true + ;; + c ) + CLEAN_FOLDERS=true + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + exit 1 + ;; + esac +done + +if "$CLEAN_FOLDERS"; then + echo "Cleaning ./doc and ./debug folders..." + rm -rf "$TARGET_DIR/doc" + rm -rf "$TARGET_DIR/debug" +fi + +# Check if the target documentation directory exists +if [ ! -d "$TARGET_DIR" ]; then + # Prompt the user for input + read -p "The zed-docs directory does not exist. Make sure you are running this from the zed repo root." -n 1 -r + read -p "Do you want to clone the repository (y/n)? " -n 1 -r + echo # Move to a new line + + if [[ $REPLY =~ ^[Yy]$ ]]; then + # Clone the repo if the user agrees + git clone https://github.com/zed-industries/zed-docs.git "$TARGET_DIR" + else + # Exit if the user does not agree to clone the repo + echo "Exiting without cloning the repository." + exit 1 + fi +else + # If the directory exists, pull the latest changes + pushd "$TARGET_DIR" > /dev/null + git pull + popd > /dev/null +fi + +# Build the documentation +CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \ +--exclude activity_indicator \ +--exclude ai \ +--exclude ai2 \ +--exclude assistant \ +--exclude audio \ +--exclude audio2 \ +--exclude auto_update \ +--exclude auto_update2 \ +--exclude breadcrumbs \ +--exclude call \ +--exclude call2 \ +--exclude channel \ +--exclude channel2 \ +--exclude cli \ +--exclude client \ +--exclude client2 \ +--exclude clock \ +--exclude collab \ +--exclude collab2 \ +--exclude collab_ui \ +--exclude collab_ui2 \ +--exclude collections \ +--exclude command_palette \ +--exclude command_palette2 \ +--exclude component_test \ +--exclude context_menu \ +--exclude copilot \ +--exclude copilot2 \ +--exclude copilot_button \ +--exclude db \ +--exclude db2 \ +--exclude diagnostics \ +--exclude diagnostics2 \ +--exclude drag_and_drop \ +--exclude editor \ +--exclude feature_flags \ +--exclude feature_flags2 \ +--exclude feedback \ +--exclude file_finder \ +--exclude file_finder2 \ +--exclude fs \ +--exclude fs2 \ +--exclude fsevent \ +--exclude fuzzy \ +--exclude fuzzy2 \ +--exclude git \ +--exclude git3 \ +--exclude go_to_line \ +--exclude go_to_line2 \ +--exclude gpui \ +--exclude gpui_macros \ +--exclude install_cli \ +--exclude install_cli2 \ +--exclude journal \ +--exclude journal2 \ +--exclude language \ +--exclude language2 \ +--exclude language_selector \ +--exclude language_tools \ +--exclude live_kit_client \ +--exclude live_kit_client2 \ +--exclude live_kit_server \ +--exclude lsp \ +--exclude lsp2 \ +--exclude media \ +--exclude menu \ +--exclude menu2 \ +--exclude multi_buffer \ +--exclude multi_buffer2 \ +--exclude node_runtime \ +--exclude notifications \ +--exclude notifications2 \ +--exclude outline \ +--exclude picker \ +--exclude picker2 \ +--exclude plugin \ +--exclude plugin_macros \ +--exclude plugin_runtime \ +--exclude prettier \ +--exclude prettier2 \ +--exclude project \ +--exclude project2 \ +--exclude project_panel \ +--exclude project_panel2 \ +--exclude project_symbols \ +--exclude quick_action_bar \ +--exclude recent_projects \ +--exclude refineable \ +--exclude rich_text \ +--exclude rich_text2 \ +--exclude rope \ +--exclude rope2 \ +--exclude rpc \ +--exclude rpc2 \ +--exclude search \ +--exclude semantic_index \ +--exclude settings \ +--exclude settings2 \ +--exclude snippet \ +--exclude sqlez \ +--exclude sqlez_macros \ +--exclude storybook2 \ +--exclude storybook3 \ +--exclude sum_tree \ +--exclude terminal \ +--exclude terminal2 \ +--exclude terminal_view \ +--exclude terminal_view2 \ +--exclude text \ +--exclude text2 \ +--exclude theme \ +--exclude theme_importer \ +--exclude theme_selector \ +--exclude util \ +--exclude vcs_menu \ +--exclude vim \ +--exclude welcome \ +--exclude workspace2 \ +--exclude xtask \ +--exclude zed \ +--exclude zed-actions \ +--exclude zed_actions2 + +if "$PUSH_CHANGES"; then + # Commit the changes and push + pushd "$TARGET_DIR" > /dev/null + # Check if there are any changes to commit + if git diff --quiet && git diff --staged --quiet; then + echo "No changes to the documentation." + else + # Staging the changes + git add . + + # Creating a commit with the current datetime + DATETIME=$(date +"%Y-%m-%d %H:%M:%S") + git commit -m "Update docs – $DATETIME" + + # Pushing the changes + git push + fi + popd > /dev/null +fi From a87ffa58ff32347aa3831ba4d701c218eccd27c8 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 20 Nov 2023 17:07:14 -0500 Subject: [PATCH 2/3] Add more crates --- script/deploy-docs | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) mode change 100644 => 100755 script/deploy-docs diff --git a/script/deploy-docs b/script/deploy-docs old mode 100644 new mode 100755 index 0e6fcd6d6f..ce606e0327 --- a/script/deploy-docs +++ b/script/deploy-docs @@ -53,114 +53,76 @@ fi CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \ --exclude activity_indicator \ --exclude ai \ ---exclude ai2 \ --exclude assistant \ --exclude audio \ ---exclude audio2 \ --exclude auto_update \ ---exclude auto_update2 \ --exclude breadcrumbs \ --exclude call \ ---exclude call2 \ --exclude channel \ ---exclude channel2 \ --exclude cli \ --exclude client \ ---exclude client2 \ --exclude clock \ --exclude collab \ ---exclude collab2 \ --exclude collab_ui \ ---exclude collab_ui2 \ --exclude collections \ --exclude command_palette \ ---exclude command_palette2 \ --exclude component_test \ --exclude context_menu \ --exclude copilot \ ---exclude copilot2 \ --exclude copilot_button \ --exclude db \ ---exclude db2 \ --exclude diagnostics \ ---exclude diagnostics2 \ --exclude drag_and_drop \ --exclude editor \ --exclude feature_flags \ ---exclude feature_flags2 \ --exclude feedback \ --exclude file_finder \ ---exclude file_finder2 \ --exclude fs \ ---exclude fs2 \ --exclude fsevent \ --exclude fuzzy \ ---exclude fuzzy2 \ --exclude git \ ---exclude git3 \ --exclude go_to_line \ ---exclude go_to_line2 \ --exclude gpui \ --exclude gpui_macros \ --exclude install_cli \ ---exclude install_cli2 \ --exclude journal \ ---exclude journal2 \ --exclude language \ ---exclude language2 \ --exclude language_selector \ --exclude language_tools \ --exclude live_kit_client \ ---exclude live_kit_client2 \ --exclude live_kit_server \ --exclude lsp \ ---exclude lsp2 \ --exclude media \ --exclude menu \ ---exclude menu2 \ --exclude multi_buffer \ ---exclude multi_buffer2 \ --exclude node_runtime \ --exclude notifications \ ---exclude notifications2 \ --exclude outline \ --exclude picker \ ---exclude picker2 \ --exclude plugin \ --exclude plugin_macros \ --exclude plugin_runtime \ --exclude prettier \ ---exclude prettier2 \ --exclude project \ ---exclude project2 \ --exclude project_panel \ ---exclude project_panel2 \ --exclude project_symbols \ --exclude quick_action_bar \ --exclude recent_projects \ --exclude refineable \ --exclude rich_text \ ---exclude rich_text2 \ --exclude rope \ ---exclude rope2 \ --exclude rpc \ ---exclude rpc2 \ --exclude search \ --exclude semantic_index \ --exclude settings \ ---exclude settings2 \ --exclude snippet \ --exclude sqlez \ --exclude sqlez_macros \ ---exclude storybook2 \ --exclude storybook3 \ --exclude sum_tree \ --exclude terminal \ ---exclude terminal2 \ --exclude terminal_view \ ---exclude terminal_view2 \ --exclude text \ ---exclude text2 \ --exclude theme \ --exclude theme_importer \ --exclude theme_selector \ @@ -168,11 +130,9 @@ CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \ --exclude vcs_menu \ --exclude vim \ --exclude welcome \ ---exclude workspace2 \ --exclude xtask \ --exclude zed \ ---exclude zed-actions \ ---exclude zed_actions2 +--exclude zed-actions if "$PUSH_CHANGES"; then # Commit the changes and push From a83d62691203f5933d670c19fe78883d87512bd3 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 20 Nov 2023 17:50:25 -0500 Subject: [PATCH 3/3] Make the script a bit more resilient --- script/deploy-docs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/script/deploy-docs b/script/deploy-docs index ce606e0327..9632215ff4 100755 --- a/script/deploy-docs +++ b/script/deploy-docs @@ -1,5 +1,11 @@ #!/bin/bash +# Check if the script is run from the root of the repository +if [ ! -f "Cargo.toml" ] || [ ! -d "crates/zed" ]; then + echo "Please run the script from the root of the repository." + exit 1 +fi + # Set the environment variables TARGET_DIR="../zed-docs" PUSH_CHANGES=false @@ -21,17 +27,10 @@ while getopts "pc" opt; do esac done -if "$CLEAN_FOLDERS"; then - echo "Cleaning ./doc and ./debug folders..." - rm -rf "$TARGET_DIR/doc" - rm -rf "$TARGET_DIR/debug" -fi - # Check if the target documentation directory exists if [ ! -d "$TARGET_DIR" ]; then # Prompt the user for input - read -p "The zed-docs directory does not exist. Make sure you are running this from the zed repo root." -n 1 -r - read -p "Do you want to clone the repository (y/n)? " -n 1 -r + read -p "Can't find ../zed-docs. Do you want to clone the repository (y/n)?" -n 1 -r echo # Move to a new line if [[ $REPLY =~ ^[Yy]$ ]]; then @@ -49,6 +48,12 @@ else popd > /dev/null fi +if "$CLEAN_FOLDERS"; then + echo "Cleaning ./doc and ./debug folders..." + rm -rf "$TARGET_DIR/doc" + rm -rf "$TARGET_DIR/debug" +fi + # Build the documentation CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \ --exclude activity_indicator \