Skip to content

Commit

Permalink
Merge branch 'master' into tryfromb512foru256b256
Browse files Browse the repository at this point in the history
  • Loading branch information
SwayStar123 authored May 20, 2024
2 parents a58d012 + f9a72da commit 08f92c2
Show file tree
Hide file tree
Showing 35 changed files with 370 additions and 290 deletions.
246 changes: 134 additions & 112 deletions Cargo.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Cargo

<!-- markdown-link-check-disable -->
Cargo can be used to install the Sway toolchain with various [`plugins`](https://fuellabs.github.io/sway/v0.58.0/book/forc/plugins/index.html).
Cargo can be used to install the Sway toolchain with various [`plugins`](https://fuellabs.github.io/sway/v0.59.0/book/forc/plugins/index.html).
<!-- markdown-link-check-enable -->

## Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ The supported operating systems include Linux and macOS; however, Windows is [`u
`Cargo` may be used instead of [`Fuelup`](fuelup.md); however, the user needs to manage the toolchain themselves.

<!-- markdown-link-check-disable -->
The advantage of using `Cargo` is the installation of [`plugins`](https://fuellabs.github.io/sway/v0.58.0/book/forc/plugins/index.html) that have not been added into [`Fuelup`](fuelup.md).
The advantage of using `Cargo` is the installation of [`plugins`](https://fuellabs.github.io/sway/v0.59.0/book/forc/plugins/index.html) that have not been added into [`Fuelup`](fuelup.md).

The disadvantage occurs when [`Fuelup`](fuelup.md) and `Cargo` are used in tandem because the latest [`plugins`](https://fuellabs.github.io/sway/v0.58.0/book/forc/plugins/index.html) may not be recognized.
The disadvantage occurs when [`Fuelup`](fuelup.md) and `Cargo` are used in tandem because the latest [`plugins`](https://fuellabs.github.io/sway/v0.59.0/book/forc/plugins/index.html) may not be recognized.
<!-- markdown-link-check-enable -->

## Source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The `Sway toolchain` can be built directly from the [`Sway repository`](https://
## Installation & Updating

<!-- markdown-link-check-disable -->
In the root of the repository `/sway/<here>` build [`forc`](https://fuellabs.github.io/sway/v0.58.0/book/forc/commands/index.html) with the following command:
In the root of the repository `/sway/<here>` build [`forc`](https://fuellabs.github.io/sway/v0.59.0/book/forc/commands/index.html) with the following command:
<!-- markdown-link-check-enable -->

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/src/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The Sway Reference

<!-- markdown-link-check-disable -->
This is the technical reference for the Sway programming language. For a prose explanation and introduction to the language, please refer to the [Sway Book](https://fuellabs.github.io/sway/v0.58.0/book/).
This is the technical reference for the Sway programming language. For a prose explanation and introduction to the language, please refer to the [Sway Book](https://fuellabs.github.io/sway/v0.59.0/book/).
<!-- markdown-link-check-enable -->
14 changes: 7 additions & 7 deletions forc-pkg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "forc-pkg"
version = "0.58.0"
version = "0.59.0"
description = "Building, locking, fetching and updating Sway projects as Forc packages."
authors.workspace = true
edition.workspace = true
Expand All @@ -12,8 +12,8 @@ repository.workspace = true
ansi_term = "0.12"
anyhow = "1"
cid = "0.10"
forc-tracing = { version = "0.58.0", path = "../forc-tracing" }
forc-util = { version = "0.58.0", path = "../forc-util" }
forc-tracing = { version = "0.59.0", path = "../forc-tracing" }
forc-util = { version = "0.59.0", path = "../forc-util" }
fuel-abi-types = { workspace = true }
futures = "0.3"
git2 = { version = "0.17.2", features = [
Expand All @@ -30,10 +30,10 @@ serde = { version = "1.0", features = ["derive"] }
serde_ignored = "0.1.9"
serde_json = "1.0"
serde_with = "3.3.0"
sway-core = { version = "0.58.0", path = "../sway-core" }
sway-error = { version = "0.58.0", path = "../sway-error" }
sway-types = { version = "0.58.0", path = "../sway-types" }
sway-utils = { version = "0.58.0", path = "../sway-utils" }
sway-core = { version = "0.59.0", path = "../sway-core" }
sway-error = { version = "0.59.0", path = "../sway-error" }
sway-types = { version = "0.59.0", path = "../sway-types" }
sway-utils = { version = "0.59.0", path = "../sway-utils" }
tar = "0.4.38"
toml = { version = "0.7", features = ["parse"] }
tracing = "0.1"
Expand Down
18 changes: 9 additions & 9 deletions forc-plugins/forc-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "forc-client"
version = "0.58.0"
version = "0.59.0"
description = "A `forc` plugin for interacting with a Fuel node."
authors.workspace = true
edition.workspace = true
Expand All @@ -14,11 +14,11 @@ async-trait = "0.1.58"
chrono = { version = "0.4", default-features = false, features = ["std"] }
clap = { version = "4.5.4", features = ["derive", "env"] }
devault = "0.1"
forc = { version = "0.58.0", path = "../../forc" }
forc-pkg = { version = "0.58.0", path = "../../forc-pkg" }
forc-tracing = { version = "0.58.0", path = "../../forc-tracing" }
forc-tx = { version = "0.58.0", path = "../forc-tx" }
forc-util = { version = "0.58.0", path = "../../forc-util" }
forc = { version = "0.59.0", path = "../../forc" }
forc-pkg = { version = "0.59.0", path = "../../forc-pkg" }
forc-tracing = { version = "0.59.0", path = "../../forc-tracing" }
forc-tx = { version = "0.59.0", path = "../forc-tx" }
forc-util = { version = "0.59.0", path = "../../forc-util" }
forc-wallet = { workspace = true }
fuel-abi-types = { workspace = true }
fuel-core-client = { workspace = true, features = ["subscriptions"] }
Expand All @@ -34,9 +34,9 @@ rand = "0.8"
rpassword = "7.2"
serde = "1.0"
serde_json = "1"
sway-core = { version = "0.58.0", path = "../../sway-core" }
sway-types = { version = "0.58.0", path = "../../sway-types" }
sway-utils = { version = "0.58.0", path = "../../sway-utils" }
sway-core = { version = "0.59.0", path = "../../sway-core" }
sway-types = { version = "0.59.0", path = "../../sway-types" }
sway-utils = { version = "0.59.0", path = "../../sway-utils" }
tokio = { version = "1.8", features = ["macros", "rt-multi-thread", "process"] }
tracing = "0.1"

Expand Down
6 changes: 3 additions & 3 deletions forc-plugins/forc-crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "forc-crypto"
version = "0.58.0"
version = "0.59.0"
description = "A `forc` plugin for handling various cryptographic operations and conversions."
authors.workspace = true
edition.workspace = true
Expand All @@ -13,8 +13,8 @@ anyhow = "1.0.75"
async-trait = "0.1.58"
atty = "0.2.14"
clap = { version = "4.5.4", features = ["derive", "env"] }
forc-tracing = { version = "0.58.0", path = "../../forc-tracing" }
forc-util = { version = "0.58.0", path = "../../forc-util" }
forc-tracing = { version = "0.59.0", path = "../../forc-tracing" }
forc-util = { version = "0.59.0", path = "../../forc-util" }
fuel-core-types = { workspace = true }
fuel-crypto = { workspace = true, features = ["random"] }
fuels-core = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions forc-plugins/forc-debug/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "forc-debug"
version = "0.58.0"
version = "0.59.0"
description = "Supports debugging Sway code via CLI and DAP server."
authors.workspace = true
edition.workspace = true
Expand All @@ -12,17 +12,17 @@ repository.workspace = true
anyhow = "1.0" # Used by the examples and for conversion only
clap = { version = "4.5.4", features = ["derive", "env"] }
dap = "0.4.1-alpha1"
forc-pkg = { version = "0.58.0", path = "../../forc-pkg" }
forc-test = { version = "0.58.0", path = "../../forc-test" }
forc-pkg = { version = "0.59.0", path = "../../forc-pkg" }
forc-test = { version = "0.59.0", path = "../../forc-test" }
fuel-core-client = { workspace = true }
fuel-types = { workspace = true, features = ["serde"] }
fuel-vm = { workspace = true, features = ["serde"] }
rayon = "1.7.0"
serde = "1.0"
serde_json = "1.0"
shellfish = { version = "0.6.0", features = ["rustyline", "async", "tokio"] }
sway-core = { version = "0.58.0", path = "../../sway-core" }
sway-types = { version = "0.58.0", path = "../../sway-types" }
sway-core = { version = "0.59.0", path = "../../sway-core" }
sway-types = { version = "0.59.0", path = "../../sway-types" }
thiserror = "1.0"
tokio = { version = "1.8", features = [
"net",
Expand Down
16 changes: 8 additions & 8 deletions forc-plugins/forc-doc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "forc-doc"
version = "0.58.0"
version = "0.59.0"
description = "Build the documentation for the local package and all dependencies. The output is placed in `out/doc` in the same format as the project."
authors.workspace = true
edition.workspace = true
Expand All @@ -13,19 +13,19 @@ anyhow = "1.0.65"
clap = { version = "4.5.4", features = ["derive"] }
colored = "2.0.0"
comrak = "0.16"
forc-pkg = { version = "0.58.0", path = "../../forc-pkg" }
forc-util = { version = "0.58.0", path = "../../forc-util" }
forc-pkg = { version = "0.59.0", path = "../../forc-pkg" }
forc-util = { version = "0.59.0", path = "../../forc-util" }
horrorshow = "0.8.4"
include_dir = "0.7.3"
minifier = "0.3.0"
opener = "0.5.0"
serde = "1.0"
serde_json = "1.0"
sway-ast = { version = "0.58.0", path = "../../sway-ast" }
sway-core = { version = "0.58.0", path = "../../sway-core" }
sway-lsp = { version = "0.58.0", path = "../../sway-lsp" }
sway-types = { version = "0.58.0", path = "../../sway-types" }
swayfmt = { version = "0.58.0", path = "../../swayfmt" }
sway-ast = { version = "0.59.0", path = "../../sway-ast" }
sway-core = { version = "0.59.0", path = "../../sway-core" }
sway-lsp = { version = "0.59.0", path = "../../sway-lsp" }
sway-types = { version = "0.59.0", path = "../../sway-types" }
swayfmt = { version = "0.59.0", path = "../../swayfmt" }

[dev-dependencies]
dir_indexer = "0.0.2"
Expand Down
76 changes: 41 additions & 35 deletions forc-plugins/forc-doc/src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,48 +79,54 @@ impl Documentation {
let mut impl_trait_vec: Vec<DocImplTrait> = Vec::new();
let mut inherent_impl_vec: Vec<DocImplTrait> = Vec::new();

match doc.item_body.ty_decl {
let decl_name = match doc.item_body.ty_decl {
TyDecl::StructDecl(ref decl) => {
for (impl_trait, module_info) in impl_traits.iter_mut() {
let struct_decl = engines.de().get_struct(&decl.decl_id);
let struct_name = struct_decl.name().as_str();

// Check if this implementation is for this struct.
if struct_name == impl_trait.implementing_for.span.as_str() {
let module_info_override = if let Some(decl_module_info) =
trait_decls.get(&impl_trait.trait_name.suffix)
{
Some(decl_module_info.module_prefixes.clone())
} else {
impl_trait.trait_name = impl_trait
.trait_name
.to_fullpath(engines, &typed_program.root.namespace);
None
};

if struct_name == impl_trait.trait_name.suffix.span().as_str() {
// If the trait name is the same as the struct name, it's an inherent implementation.
inherent_impl_vec.push(DocImplTrait {
impl_for_module: module_info.clone(),
impl_trait: impl_trait.clone(),
module_info_override: None,
});
} else {
// Otherwise, it's an implementation for a trait.
impl_trait_vec.push(DocImplTrait {
impl_for_module: module_info.clone(),
impl_trait: impl_trait.clone(),
module_info_override,
});
}
let struct_decl = engines.de().get_struct(&decl.decl_id);
Some(struct_decl.name().to_string())
}
TyDecl::EnumDecl(ref decl) => {
let enum_decl = engines.de().get_enum(&decl.decl_id);
Some(enum_decl.name().to_string())
}
_ => None,
};

if let Some(decl_name) = decl_name {
for (impl_trait, module_info) in impl_traits.iter_mut() {
// Check if this implementation is for this struct/enum.
if decl_name.as_str() == impl_trait.implementing_for.span.as_str() {
let module_info_override = if let Some(decl_module_info) =
trait_decls.get(&impl_trait.trait_name.suffix)
{
Some(decl_module_info.module_prefixes.clone())
} else {
impl_trait.trait_name = impl_trait
.trait_name
.to_fullpath(engines, &typed_program.root.namespace);
None
};

if decl_name.as_str() == impl_trait.trait_name.suffix.span().as_str() {
// If the trait name is the same as the declaration's name, it's an inherent implementation.
inherent_impl_vec.push(DocImplTrait {
impl_for_module: module_info.clone(),
impl_trait: impl_trait.clone(),
module_info_override: None,
});
} else {
// Otherwise, it's an implementation for a trait.
impl_trait_vec.push(DocImplTrait {
impl_for_module: module_info.clone(),
impl_trait: impl_trait.clone(),
module_info_override,
});
}
}
}
_ => continue,
}

if !impl_trait_vec.is_empty() {
doc.item_body.item_context.impl_traits = Some(impl_trait_vec.clone());
doc.item_body.item_context.impl_traits = Some(impl_trait_vec);
}

if !inherent_impl_vec.is_empty() {
Expand Down
56 changes: 46 additions & 10 deletions forc-plugins/forc-doc/src/render/item/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,42 @@ impl ItemContext {
}
}
}

if let Some(inherent_impls) = &self.inherent_impls {
let mut doc_links = Vec::new();
for inherent_impl in inherent_impls {
for item in &inherent_impl.impl_trait.items {
if let TyTraitItem::Fn(item_fn) = item {
let method_name = item_fn.name().to_string();
doc_links.push(DocLink {
name: method_name.clone(),
module_info: inherent_impl.impl_for_module.clone(),
html_filename: format!("{}method.{}", IDENTITY, method_name),
preview_opt: None,
})
}
}
}
links.insert(BlockTitle::ImplMethods, doc_links);
}

if let Some(impl_traits) = &self.impl_traits {
let doc_links = impl_traits
.iter()
.map(|impl_trait| DocLink {
name: impl_trait.impl_trait.trait_name.suffix.as_str().to_string(),
module_info: impl_trait.impl_for_module.clone(),
html_filename: format!(
"{}impl-{}",
IDENTITY,
impl_trait.impl_trait.trait_name.suffix.as_str()
),
preview_opt: None,
})
.collect();
links.insert(BlockTitle::ImplTraits, doc_links);
}

DocLinks {
style: DocStyle::Item {
title: None,
Expand Down Expand Up @@ -407,11 +443,11 @@ impl Renderable for ItemContext {
: Raw(context);
}
@ if !inherent_impls.is_empty() {
h2(id="inherent-implementations", class="small-section-header") {
h2(id="methods", class="small-section-header") {
: "Implementations";
a(href=format!("{IDENTITY}inherent-implementations"), class="anchor");
a(href=format!("{IDENTITY}methods"), class="anchor");
}
div(id="inherent-implementations-list") {
div(id="methods-list") {
@ for inherent_impl in inherent_impls {
: inherent_impl;
}
Expand Down Expand Up @@ -472,17 +508,17 @@ impl Renderable for DocImplTrait {
a(href=format!("{IDENTITY}impl-{}", trait_name.suffix.as_str()), class="anchor");
h3(class="code-header in-band") {
: "impl ";
@ if no_deps && is_external_item {
: trait_name.suffix.as_str();
} else {
a(class="trait", href=format!("{trait_link}")) {
@ if !is_inherent {
@ if no_deps && is_external_item {
: trait_name.suffix.as_str();
} else {
a(class="trait", href=format!("{trait_link}")) {
: trait_name.suffix.as_str();
}
}
}
@ if !is_inherent {
: " for ";
: implementing_for.span.as_str();
}
: implementing_for.span.as_str();
}
}
}
Expand Down
17 changes: 11 additions & 6 deletions forc-plugins/forc-doc/src/render/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,18 @@ impl Renderable for Sidebar {
}
_ => box_html! {
div(class="sidebar-elems") {
section {
div(class="block") {
ul {
@ for (title, _) in self.nav.links {
@ for (title, doc_links) in self.nav.links {
section {
h3 {
a(href=format!("{}{}", IDENTITY, title.html_title_string())) {
: title.as_str();
}
}
ul(class="block method") {
@ for doc_link in doc_links {
li {
a(href=format!("{}{}", IDENTITY, title.html_title_string())) {
: title.as_str();
a(href=format!("{}", doc_link.html_filename)) {
: doc_link.name;
}
}
}
Expand Down
Loading

0 comments on commit 08f92c2

Please sign in to comment.