diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7438d9fee0f..5f1199a3d8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -287,7 +287,7 @@ jobs: run: | cargo install --locked --debug --path ./forc-plugins/forc-doc - name: Build sway-lib-std docs - run: forc doc --manifest-path ./sway-lib-std + run: forc doc --path ./sway-lib-std build-forc-test-project: runs-on: buildjet-4vcpu-ubuntu-2204 diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index fa2ac16b866..7e3201451c5 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -50,7 +50,7 @@ jobs: run: mdbook build docs/reference - name: Build Sway std library - run: forc doc --manifest-path ./sway-lib-std + run: forc doc --path ./sway-lib-std - name: Deploy master std uses: peaceiris/actions-gh-pages@v3 diff --git a/forc-plugins/forc-doc/README.md b/forc-plugins/forc-doc/README.md index 90531e248cd..c82602aa225 100644 --- a/forc-plugins/forc-doc/README.md +++ b/forc-plugins/forc-doc/README.md @@ -78,7 +78,7 @@ $ cargo install --path forc-plugins/forc-doc Great! Let's check everything is working as intended. Try running `forc doc` on one of the test directories: ```sh -$ forc doc --manifest-path src/tests/data/impl_traits --open +$ forc doc --path src/tests/data/impl_traits --open ``` If it succeeded, you should be seeing the test docs in your browser. @@ -274,10 +274,10 @@ Now we can call this function anytime we need to generate a searchbar for our we Once you've made some changes, run the `forc doc` binary, passing it a path containing a `Forc.toml`: ```sh -cargo run -- --manifest-path path/to/manifest --open +cargo run -- --path path/to/manifest --open ``` -> **Tip:** VS Code user? Try the Live Server plugin to make viewing changes even easier. It will reload a webpage on updates, so you only need to rebuild the docs (`cargo run -- --manifest-path path/to/manifest`). Just right click the index file of docs produced by `forc doc` which can be found in the `out/doc` directory, and choose the option "open with Live Server". Voila! +> **Tip:** VS Code user? Try the Live Server plugin to make viewing changes even easier. It will reload a webpage on updates, so you only need to rebuild the docs (`cargo run -- --path path/to/manifest`). Just right click the index file of docs produced by `forc doc` which can be found in the `out/doc` directory, and choose the option "open with Live Server". Voila! [forc-reference]: https://fuellabs.github.io/sway/master/book/forc/index.html "forc reference" [manifest-reference]: https://fuellabs.github.io/sway/master/book/forc/manifest_reference.html "manifest reference" diff --git a/forc-plugins/forc-doc/src/cli.rs b/forc-plugins/forc-doc/src/cli.rs index 309bfb880d6..dff10298122 100644 --- a/forc-plugins/forc-doc/src/cli.rs +++ b/forc-plugins/forc-doc/src/cli.rs @@ -6,7 +6,7 @@ forc_util::cli_examples! { crate::cli::Command { [ Build the docs for a project in the current path => "forc doc"] [ Build the docs for a project in the current path and open it in the browser => "forc doc --open" ] - [ Build the docs for a project located in another path => "forc doc --manifest-path {path}" ] + [ Build the docs for a project located in another path => "forc doc --path {path}" ] [ Build the docs for the current project exporting private types => "forc doc --document-private-items" ] [ Build the docs offline without downloading any dependency from the network => "forc doc --offline" ] } @@ -20,10 +20,11 @@ forc_util::cli_examples! { version )] pub struct Command { - /// Path to the Forc.toml file. By default, forc-doc searches for the Forc.toml - /// file in the current directory or any parent directory. - #[clap(long)] - pub manifest_path: Option, + /// Path to the project. + /// + /// If not specified, current working directory will be used. + #[clap(short, long, alias = "manifest-path")] + pub path: Option, /// Include non-public items in the documentation. #[clap(long)] pub document_private_items: bool, diff --git a/forc-plugins/forc-doc/src/lib.rs b/forc-plugins/forc-doc/src/lib.rs index 4043cfde1f2..ffaf5a5dbe8 100644 --- a/forc-plugins/forc-doc/src/lib.rs +++ b/forc-plugins/forc-doc/src/lib.rs @@ -57,7 +57,7 @@ pub fn compile_html( get_doc_dir: &dyn Fn(&Command) -> String, ) -> Result<(PathBuf, Box)> { // get manifest directory - let dir = if let Some(ref path) = build_instructions.manifest_path { + let dir = if let Some(ref path) = build_instructions.path { PathBuf::from(path) } else { std::env::current_dir()? diff --git a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs index 602b66f49d7..555954ce244 100644 --- a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs +++ b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs @@ -21,7 +21,7 @@ fn test_impl_traits_default() { let doc_dir_name: &str = "impl_traits_default"; let project_name = "impl_traits"; let command = Command { - manifest_path: Some(format!("{}/{}", DATA_DIR, project_name)), + path: Some(format!("{}/{}", DATA_DIR, project_name)), doc_path: Some(doc_dir_name.into()), ..Default::default() }; @@ -171,7 +171,7 @@ fn test_impl_traits_no_deps() { let doc_dir_name: &str = "impl_traits_no_deps"; let project_name: &str = "impl_traits_clone"; let command = Command { - manifest_path: Some(format!("{}/{}", DATA_DIR, project_name)), + path: Some(format!("{}/{}", DATA_DIR, project_name)), doc_path: Some(doc_dir_name.into()), no_deps: true, ..Default::default() diff --git a/forc-plugins/forc-doc/tests/lib.rs b/forc-plugins/forc-doc/tests/lib.rs index 9624b656a4f..996e095645b 100644 --- a/forc-plugins/forc-doc/tests/lib.rs +++ b/forc-plugins/forc-doc/tests/lib.rs @@ -5,10 +5,10 @@ use std::path::Path; fn builds_lib_std_docs() { let path = Path::new("./../../sway-lib-std"); let build_instructions = Command { - manifest_path: Some(path.to_str().unwrap().to_string()), + path: Some(path.to_str().unwrap().to_string()), ..Default::default() }; - println!("Building docs for {:?}", build_instructions.manifest_path); + println!("Building docs for {:?}", build_instructions.path); let res = compile_html(&build_instructions, &get_doc_dir); assert!(res.is_ok()); } diff --git a/forc-plugins/forc-fmt/src/main.rs b/forc-plugins/forc-fmt/src/main.rs index fffefbbd840..331c3e51373 100644 --- a/forc-plugins/forc-fmt/src/main.rs +++ b/forc-plugins/forc-fmt/src/main.rs @@ -45,7 +45,9 @@ pub struct App { /// - Exits with `1` and prints a diff if formatting is required. #[clap(short, long)] pub check: bool, - /// Path to the project, if not specified, current working directory will be used. + /// Path to the project. + /// + /// If not specified, current working directory will be used. #[clap(short, long)] pub path: Option, #[clap(short, long)]