### Setup and Run VuePress Development Server Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/README.md Commands to install VuePress globally, clone the repository, and launch the local development environment. ```sh # vuepress yarn global add vuepress # 本地开发 git clone https://github.com/gdut-yy/Clean-Architecture-zh.git cd Clean-Architecture-zh/ yarn docs:dev # 本地阅读 http://localhost:8080/doc-cleanarch/ ``` -------------------------------- ### Run Development Server Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/PROJECT_OVERVIEW.md Starts the VuePress development server at http://localhost:8080/doc-cleanarch/. ```bash yarn docs:dev ``` -------------------------------- ### Install Missing Dependencies Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/BUILD_AND_DEPLOYMENT.md Run after cloning the repository to ensure all required packages are installed. ```bash yarn install # or npm install ``` -------------------------------- ### Initialize and Build Project Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/README.md Commands for cloning the repository, installing dependencies, and building the documentation for production. ```bash git clone https://github.com/gdut-yy/Clean-Architecture-zh.git cd clean-architecture-zh ``` ```bash yarn install ``` ```bash yarn docs:dev ``` ```bash yarn docs:build ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/PROJECT_OVERVIEW.md Use Yarn to install all required project dependencies. ```bash yarn install ``` ```bash yarn ``` -------------------------------- ### Hardware Platform Setup Functions Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch29.md Functions used to configure the hardware platform and handle button interactions. ```c ISR(TIMER1_vect) { ... }* ISR(INT2_vect) { ... } void uC_Sleep(void) { ... } Functions that react to the on off button press void btn_Handler(void) { ... } void Dev_Control(char Activation) { ... } ``` -------------------------------- ### Example Dispatch URI Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch9.md A sample URI format used for dispatching a taxi driver. ```text purplecab.com/driver/Bob ``` -------------------------------- ### Development and Build Commands Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/README.md Use these commands to manage the project lifecycle, including dependency installation, local development, and production builds. ```bash # Install dependencies yarn install # Start development server yarn docs:dev # Visit: http://localhost:8080/doc-cleanarch/ # Build for production yarn docs:build # Preview production build locally cd docs/.vuepress/dist python3 -m http.server 8000 # Visit: http://localhost:8000/doc-cleanarch/ # Deploy to Gitee Pages (after build) bash gitee-deploy.sh # Clear build cache rm -rf docs/.vuepress/.cache rm -rf node_modules/.cache # Full clean rebuild rm -rf node_modules yarn.lock yarn install yarn docs:build ``` -------------------------------- ### Simple C Copy Program Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch5.md A basic example of polymorphic behavior where getchar and putchar interact with devices via STDIN and STDOUT. ```c #include void copy() { int c; while ((c=getchar()) != EOF) putchar(c); } ``` -------------------------------- ### Conditional Dispatch Logic Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch9.md An example of an anti-pattern where specific vendor logic is hardcoded into the system. ```java if (driver.getDispatchUri().startsWith("acme.com"))… ``` -------------------------------- ### Initialize Game Map in Main Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch26.md This method demonstrates the Main component setting up initial game conditions, including cavern generation and entity placement. ```java private static void createMap() { int nCaverns = (int) (Math.random() * 30.0 + 10.0); while (nCaverns-- > 0) caverns.add(makeName()); for (String cavern : caverns) { maybeConnectCavern(cavern, NORTH); maybeConnectCavern(cavern, SOUTH); maybeConnectCavern(cavern, EAST); maybeConnectCavern(cavern, WEST); } String playerCavern = anyCavern(); game.setPlayerCavern(playerCavern); game.setWumpusCavern(anyOther(playerCavern)); game.addBatCavern(anyOther(playerCavern)); game.addBatCavern(anyOther(playerCavern)); game.addBatCavern(anyOther(playerCavern)); game.addPitCavern(anyOther(playerCavern)); game.addPitCavern(anyOther(playerCavern)); game.addPitCavern(anyOther(playerCavern)); game.setQuiver(5); } // much code removed… } ``` -------------------------------- ### Define Chapter Heading Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/DOCUMENTATION_STRUCTURE.md Standard format for the level-1 heading at the start of each chapter file. ```markdown # Chap{N}. ENGLISH_TITLE_HERE 中文标题在这里 ``` -------------------------------- ### Example PUT Request Payload Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch9.md The structure of the dispatch information appended to the URI for a PUT request. ```text purplecab.com/driver/Bob /pickupAddress/24 Maple St. /pickupTime/153 /destination/ORD ``` -------------------------------- ### Build Production Site Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/PROJECT_OVERVIEW.md Generates the static site files in the docs/.vuepress/dist/ directory. ```bash yarn docs:build ``` -------------------------------- ### Define Code Block Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/DOCUMENTATION_STRUCTURE.md Standard markdown syntax for including code examples with language-specific highlighting. ```markdown ```language code here ``` ``` -------------------------------- ### Build Output Directory Structure Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/BUILD_AND_DEPLOYMENT.md Visual representation of the generated static site files within the dist directory. ```text docs/.vuepress/dist/ ├── index.html # Homepage ├── ch1.html through ch34.html # Chapter pages ├── part1.html through part6.html ├── afterword.html ├── assets/ │ ├── css/ │ │ ├── styles.{hash}.css # Main stylesheet │ │ └── {other}.{hash}.css # Vendor stylesheets │ ├── js/ │ │ ├── app.{hash}.js # Application bundle │ │ ├── vendors~app.{hash}.js # Vendor code │ │ └── {chunk-id}.{hash}.js # Code-split chunks │ ├── fonts/ │ │ └── {font-files} # Web fonts │ └── img/ │ ├── {images}.{hash}.{ext} # Optimized images │ └── cover.{hash}.jpg ├── manifest.json # PWA manifest ├── sitemap.xml # Search engine sitemap └── service-worker.js # Service worker for offline ``` -------------------------------- ### Restart Development Server Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/BUILD_AND_DEPLOYMENT.md Standard procedure to refresh the development environment. ```bash # Kill existing server # Restart yarn docs:dev ``` -------------------------------- ### Incorrect Encryption Architecture Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch19.md An example of poor architecture where high-level logic directly depends on low-level I/O functions. ```javascript function encrypt() { while (true) writeChar(translate(readChar())); } ``` -------------------------------- ### Implement Main Execution Loop Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch26.md Handles game initialization via factory and manages the primary input loop, delegating logic to higher-level components. ```java public static void main(String[] args) throws IOException { game = HtwFactory.makeGame("htw.game.HuntTheWumpusFacade", new Main()); createMap(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); game.makeRestCommand().execute(); while (true) { System.out.println(game.getPlayerCavern()); System.out.println("Health: " + hitPoints + " arrows: " + game.getQuiver()); HuntTheWumpus.Command c = game.makeRestCommand(); System.out.println(">"); String command = br.readLine(); if (command.equalsIgnoreCase("e")) c = game.makeMoveCommand(EAST); else if (command.equalsIgnoreCase("w")) c = game.makeMoveCommand(WEST); else if (command.equalsIgnoreCase("n")) c = game.makeMoveCommand(NORTH); else if (command.equalsIgnoreCase("s")) c = game.makeMoveCommand(SOUTH); else if (command.equalsIgnoreCase("r")) c = game.makeRestCommand(); else if (command.equalsIgnoreCase("sw")) c = game.makeShootCommand(WEST); else if (command.equalsIgnoreCase("se")) c = game.makeShootCommand(EAST); else if (command.equalsIgnoreCase("sn")) c = game.makeShootCommand(NORTH); else if (command.equalsIgnoreCase("ss")) c = game.makeShootCommand(SOUTH); else if (command.equalsIgnoreCase("q")) return; c.execute(); } } ``` -------------------------------- ### Part Overview File Structure Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/DOCUMENTATION_STRUCTURE.md Simplified template for part overview files used for navigation and context setting. ```markdown # Part1. 概述 Brief introduction explaining the scope and goals of this part. Lists chapters included: - [Chapter 1](./ch1.md) - [Chapter 2](./ch2.md) ``` -------------------------------- ### PDP-8 Assembly Program with GETSTR Subroutine Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/docs/ch12.md A historical example of an assembly program that uses an origin statement to define memory placement and includes a library subroutine directly in the source. ```Assembly *200 TLS START, CLA TAD BUFR JMS GETSTR CLA TAD BUFR JMS PUTSTR JMP START BUFR, 3000 GETSTR, 0 DCA PTR NXTCH, KSF JMP -1 KRB DCA I PTR TAD I PTR AND K177 ISZ PTR TAD MCR SZA JMP NXTCH K177, 177 MCR, -15 ``` -------------------------------- ### Define Deployment Access Structure Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/FILE_MANIFEST.md Represents the directory structure for the final build output. ```text docs/.vuepress/dist/ (entire directory copied to server) ``` -------------------------------- ### Define Link Paths Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/VUEPRESS_CONFIGURATION.md Correct and incorrect formats for referencing files in the sidebar configuration. ```text "ch1.md" ``` ```text "/ch1.md" ``` ```text "./ch1.md" ``` -------------------------------- ### Define Build System Access Structure Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/FILE_MANIFEST.md Represents the files and directories required for the build process. ```text package.json (for build scripts) docs/.vuepress/config.js (for configuration) docs/ (all .md files scanned) docs/un/ (images copied to dist) ``` -------------------------------- ### Specify Build Output Directory Source: https://github.com/leewaiho/clean-architecture-zh/blob/master/_autodocs/VUEPRESS_CONFIGURATION.md The default directory where static assets are generated after running the build command. ```text docs/.vuepress/dist/ ```