Commit graph

12 commits

Author SHA1 Message Date
Joshua Batty
c7ff31207a
Add parallel processing to forc-doc using rayon to improve performance (#7296)
Some checks are pending
CI / forc-fmt-check-panic (push) Waiting to run
CI / check-sdk-harness-test-suite-compatibility (push) Waiting to run
CI / build-mdbook (push) Waiting to run
CI / build-forc-doc-sway-lib-std (push) Waiting to run
CI / build-forc-test-project (push) Waiting to run
CI / cargo-build-workspace (push) Waiting to run
CI / cargo-clippy (push) Waiting to run
CI / cargo-toml-fmt-check (push) Waiting to run
CI / cargo-fmt-check (push) Waiting to run
CI / cargo-test-lib-std (push) Waiting to run
CI / forc-unit-tests (push) Waiting to run
CI / forc-pkg-fuels-deps-check (push) Waiting to run
CI / cargo-test-forc-debug (push) Blocked by required conditions
CI / cargo-test-forc-client (push) Blocked by required conditions
CI / cargo-test-forc-mcp (push) Blocked by required conditions
CI / cargo-test-forc-node (push) Blocked by required conditions
CI / cargo-test-sway-lsp (push) Waiting to run
CI / cargo-test-forc (push) Waiting to run
CI / cargo-test-workspace (push) Waiting to run
CI / cargo-unused-deps-check (push) Waiting to run
CI / notify-slack-on-failure (push) Blocked by required conditions
CI / pre-publish-check (push) Waiting to run
CI / publish (push) Blocked by required conditions
CI / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
CI / cargo-run-e2e-test (push) Blocked by required conditions
CI / cargo-run-e2e-test-release (push) Blocked by required conditions
CI / cargo-run-e2e-test-evm (push) Waiting to run
CI / forc-run-benchmarks (push) Waiting to run
## Description
Key changes:
  - Parallelize document rendering and link generation
- Add type aliases for complex nested types (`DocLinkMap`, `ModuleMap`,
`RenderResult`)
  - Remove unnecessary wrapper functions and clones

The parallel processing maintains insertion order through sequential
merging, ensuring identical documentation output.

Not sure why the codspeed report isn't showing this below but when I run
`cargo bench` locally i'm seeing these results.

| Metric | Before | After | Improvement |
|--------|--------|-------|-------------|
| build_std_lib_docs | 70.069 ms | 43.227 ms | **43.2% faster** |

## Checklist

- [ ] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2025-07-30 14:21:46 +04:00
Joshua Batty
ceedc94283
Add criterion benchmark to forc-doc + initial code quality pass (#7242)
Some checks are pending
CI / cargo-test-forc-node (push) Blocked by required conditions
CI / cargo-test-sway-lsp (push) Waiting to run
CI / forc-fmt-check-sway-examples (push) Waiting to run
CI / forc-fmt-check-panic (push) Waiting to run
CI / check-sdk-harness-test-suite-compatibility (push) Waiting to run
CI / build-mdbook (push) Waiting to run
CI / build-forc-doc-sway-lib-std (push) Waiting to run
CI / build-forc-test-project (push) Waiting to run
CI / cargo-build-workspace (push) Waiting to run
CI / cargo-clippy (push) Waiting to run
CI / cargo-toml-fmt-check (push) Waiting to run
CI / cargo-fmt-check (push) Waiting to run
CI / cargo-run-e2e-test (push) Blocked by required conditions
CI / cargo-run-e2e-test-release (push) Blocked by required conditions
CI / cargo-run-e2e-test-evm (push) Waiting to run
CI / cargo-test-lib-std (push) Waiting to run
CI / forc-run-benchmarks (push) Waiting to run
CI / forc-unit-tests (push) Waiting to run
CI / forc-pkg-fuels-deps-check (push) Waiting to run
CI / cargo-test-forc-debug (push) Blocked by required conditions
CI / cargo-test-forc-client (push) Blocked by required conditions
CI / cargo-test-forc (push) Waiting to run
CI / cargo-test-workspace (push) Waiting to run
CI / cargo-unused-deps-check (push) Waiting to run
CI / notify-slack-on-failure (push) Blocked by required conditions
CI / pre-publish-check (push) Waiting to run
CI / publish (push) Blocked by required conditions
CI / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Description
Doing some general code quality changes at the same time. 

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
2025-06-30 08:34:43 +00:00
Igor Rončević
76268dcff7
Add support for experimental features in the parsing phase (#7124)
## Description

This PR brings support for experimental features to the parsing phase.
This is needed so that we can support use cases like, e.g., adding new
language keywords behind a feature flag.

A concrete example would be the `panic` keyword added in #7073. The
parsing of the `panic` token differs if it is interpreted as a keyword
(when the `error_type` experimental feature is active) or as a regular
identifier (when `error_type` is off).

Because `ExperimentalFeatures` are needed in the `Parse::parse(parser:
&mut Parser)` methods, the `Parser` got extended with the `experimental`
field.

The consequence of bringing the `ExperimentalFeatures` to the parsing
phase is, that `swayfmt` and `forc fmt` can also require an experimental
feature to be set, to properly parse a project. In those tools,
`ExperimentalFeatures` are passed as a field on the `Formatter`.

Note that this PR does not put the provided experimental flags into use.
The first concrete usage will be in #7073.

This PR is a prerequisite for #7073. 

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2025-04-29 11:36:37 +12:00
Sophie Dankel
f342f52381
feat: Add primitive types to forc-doc (#6032)
## Description

Closes https://github.com/FuelLabs/sway/issues/5968

Adds a new "Primitive" type in the sidebar and to the search bar. The
descriptions are hard coded since there is nowhere to parse the
documentation from. The list of primitives is also hardcoded, so we will
need to update forc-doc if/when new primitives are added to the
language.

Primitives will be documented show up in the side bar for any package
that has implementations for a primitive. This is why it currently shows
up for both std and core.

Side bar nav:
![May-27-2024
16-54-34](30efc6d9-43d3-455b-baac-5daf7b19955f)

Search bar:
![May-27-2024
16-54-53](9e988c12-f84d-4012-bd88-a646514841ce)

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-05-29 09:40:10 +10:00
Sophie Dankel
d4f0c12c85
feat: Add implementations to forc-doc (#6017)
## Description

Closes https://github.com/FuelLabs/sway/issues/5957

Also tweaked the CSS to make:
- the subheaders inside of implementations smaller than the impl header
- the colors a little less stark
- the impl toggle blocks open by default (same as crates.io)

Discovered two issues, relating to enums and the sidebar, which I'll
solve separately: https://github.com/FuelLabs/sway/issues/6018


![image](907f59c9-8555-4f0f-9ab2-353d4c17fa12)

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-05-15 16:23:53 -07:00
Joshua Batty
b7a87f34a4
Code quality pass on forc doc (#5962) 2024-05-06 22:14:34 +00:00
Marcos Henrich
1e12d5d13f
Changes ConcurrentSlab to no longer clone values (#5313)
## Description

`ConcurrentSlab` now stores and returns an Arc, and on `get` it only
clones an Arc which is much cheaper than cloning the whole values.

The type engine is still cloning every TypeInfo we should be able to
also avoid that and get further improvements in speed.

With these changes core + std-lib compilation improved from around 3
secs to 1.5 secs.
`cargo run --bin test --release` is running in around 8min versus 16min
in master.

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-12-02 14:08:32 -05:00
Chris-san
503c192b02
Adds a README to forc-doc (#5126)
Adds a `README` to forc-doc, as well as some general clean up and documentation.
2023-09-21 11:37:18 -05:00
Sophie Dankel
985e055854
Fix forc-fmt panic when lexing fails (#5011)
## Description

Closes https://github.com/FuelLabs/sway/issues/5010

Now instead of a panic, the user sees this: 

<img width="836" alt="image"
src="2da2e075-8a10-4ed4-8892-1c95cc42af63">

With debug logging they can see the compiler error, or they can simply
run the compiler.

## Checklist

- [x] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
2023-08-25 10:11:23 +00:00
Chris-san
bbe746dafa
feat(forc doc): Add impl_trait representation to ItemBody (#4389)
## Description
Adds a trait implementation section to item declarations & fixes CSS for
required methods on traits.



https://user-images.githubusercontent.com/57543709/236067329-11bb66bd-b7b9-4a46-81d6-520d0e2ece83.mov



## Checklist

- [x] I have linked to any relevant issues. Closes #3972 
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2023-05-04 10:18:26 -05:00
Joshua Batty
7011edd02e
Refactor TyDecl Enum and Separate Structs for Improved Code Organization (#4457)
## Description
This PR refactors the `TyDecl` enum by separating its variants into
individual structs and simplifying the enum itself, leading to better
code organization and maintainability.

This refactoring enhances modularity making it easier to implement a
Parse trait on these types in the language server when matching on the
variants during AST traversal, which is required to unblock #3799. I had
attempted to do this in #4247 but it was reverted by @emilyaherbert.
Hopefully, this new approach is acceptable.

The main change is

```rust
#[derive(Clone, Debug)]
pub enum TyDecl {
    ConstantDecl {
        name: Ident,
        decl_id: DeclId<TyConstantDecl>,
        decl_span: Span,
    },
    FunctionDecl {
        name: Ident,
        decl_id: DeclId<TyFunctionDecl>,
        subst_list: Template<SubstList>,
        decl_span: Span,
    },
    ....
}
```

Has been changed to 

```rust
#[derive(Clone, Debug)]
pub enum TyDecl {
    ConstantDecl(ConstantDecl),
    FunctionDecl(FunctionDecl),
    ....
}

#[derive(Clone, Debug)]
pub struct ConstantDecl {
    pub name: Ident,
    pub decl_id: DeclId<TyConstantDecl>,
    pub decl_span: Span,
}

#[derive(Clone, Debug)]
pub struct FunctionDecl {
    pub name: Ident,
    pub decl_id: DeclId<TyFunctionDecl>,
    pub subst_list: Template<SubstList>,
    pub decl_span: Span,
}
```

## Checklist

- [x] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-04-18 23:13:48 +10:00
Chris-san
085175a7a4
chore(forc-doc): Reorganizes the file tree (#4382)
## Description
Just a clean up PR to make finding & understanding things much easier.

## Checklist

- [x] I have linked to any relevant issues. #3656 #3659
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-04-03 00:13:37 +00:00
Renamed from forc-plugins/forc-doc/src/descriptor.rs (Browse further)