cp_docs is a small Rust command-line tool.
It recursively finds all docs/ directories within a specified path and copies their contents to a target directory, preserving the original folder structure.
- Rust (https://www.rust-lang.org/)
- Cargo (Rust's package manager)
cargo install cp_docsgit clone https://github.com/bhanuwealthy/docs-helper.git
cd docs-helper
cargo build --release$ cp_docs <source> <target>
# OR cargo run
$ cargo r -- ../docs-test ../docs-test-result$ tree ../docs-test ../docs-test-result
# src dir
../docs-test
└── A
├── B
│ ├── C
│ │ └── docs
│ │ ├── a-b-c.md
│ │ └── c.md
│ └── docs
│ ├── E
│ │ ├── a-b-e.md
│ │ └── e.md
│ └── b.md
├── D
│ └── d.md
└── docs
└── A.md
# target dir
../docs-test-result
└── A
├── A.md
└── B
├── C
│ ├── a-b-c.md
│ └── c.md
├── E
│ ├── a-b-e.md
│ └── e.md
└── b.md
8 directories, 6 filesTo use docs-helper within a Docker container, follow these steps:
-
Build the Docker image: Navigate to the root of your
docs-helperproject (where theDockerfileis located) in your terminal and run:docker build -t cp_docs .This command builds a Docker image named
cp_docs. -
Run the Docker container: You'll need to mount your source and target directories from your host machine into the container using volume mounts (
-v).Example: If your project with
docs/folders is inmy_project_rooton your host and you want the output inmy_project_root/dist:# From your 'my_project_root' directory docker run -v $(pwd):/app/source_code -v $(pwd)/dist:/app/output_docs cp_docs /app/source_code /app/output_docs
-
-v $(pwd):/app/source_code: Mounts your current host directory ($(pwd)) as/app/source_codeinside the container. This should be the root path wherecp_docswill start searching fordocs/directories. -
-v $(pwd)/dist:/app/output_docs: Mounts your host'sdistdirectory as/app/output_docsinside the container. This is where the processed documentation will be written. -
cp_docs: The name of the Docker image you built. -
/app/source_code /app/output_docs: These are the arguments passed to thecp_docsexecutable inside the container, specifying the root to scan and the target output directory, respectively.
-