Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename forc doc --manifest-path to --path #6797

Merged
merged 8 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions forc-plugins/forc-doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand Down
11 changes: 6 additions & 5 deletions forc-plugins/forc-doc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
Expand All @@ -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<String>,
/// Path to the project.
///
/// If not specified, current working directory will be used.
#[clap(short, long, alias = "manifest-path")]
pub path: Option<String>,
/// Include non-public items in the documentation.
#[clap(long)]
pub document_private_items: bool,
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn compile_html(
get_doc_dir: &dyn Fn(&Command) -> String,
) -> Result<(PathBuf, Box<PackageManifestFile>)> {
// 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()?
Expand Down
4 changes: 2 additions & 2 deletions forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions forc-plugins/forc-doc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
4 changes: 3 additions & 1 deletion forc-plugins/forc-fmt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
#[clap(short, long)]
Expand Down
Loading